private void processLine(List<byte[]> parts,Channel channel,ChannelHandlerContext channelHandlerContext) throws UnknownCommandException, MalformedCommandException {
  final int numParts=parts.size();
  Op op;
  try {
    op=Op.findOp(parts.get(0));
  }
 catch (  IllegalArgumentException e) {
    throw new UnknownCommandException("unknown operation: " + new String(parts.get(0)));
  }
  CommandMessage cmd=CommandMessage.command(op);
switch (op) {
case DELETE:
    if (numParts < 2 || numParts > 4)     throw new MalformedCommandException("invalid delete command");
  cmd.setKey(parts.get(1));
if (numParts > 2) {
  if (Arrays.equals(parts.get(numParts - 1),NOREPLY)) {
    cmd.noreply=true;
    if (numParts == 4)     cmd.time=BufferUtils.atoi((parts.get(2)));
  }
 else   if (numParts == 3) {
    cmd.time=BufferUtils.atoi((parts.get(2)));
  }
 else {
    throw new MalformedCommandException("invalid delete command");
  }
}
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
case DECR:
case INCR:
if (numParts < 3 || numParts > 4) throw new MalformedCommandException("invalid incr/decr command");
cmd.setKey(parts.get(1));
cmd.incrAmount=BufferUtils.atoi(parts.get(2));
if (numParts == 4 && Arrays.equals(parts.get(3),NOREPLY)) {
cmd.noreply=true;
}
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
case FLUSH_ALL:
if (numParts >= 1) {
if (Arrays.equals(parts.get(numParts - 1),NOREPLY)) {
cmd.noreply=true;
if (numParts == 3) cmd.time=BufferUtils.atoi((parts.get(1)));
}
 else if (numParts == 2) cmd.time=BufferUtils.atoi((parts.get(1)));
}
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
case VERBOSITY:
if (numParts < 2 || numParts > 3) throw new MalformedCommandException("invalid verbosity command");
cmd.time=BufferUtils.atoi((parts.get(1)));
if (numParts > 1 && Arrays.equals(parts.get(2),NOREPLY)) cmd.noreply=true;
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
case APPEND:
case PREPEND:
case REPLACE:
case ADD:
case SET:
case CAS:
if (numParts < 5) {
throw new MalformedCommandException("invalid command length");
}
int size=BufferUtils.atoi(parts.get(4));
int expire=BufferUtils.atoi(parts.get(3));
int flags=BufferUtils.atoi(parts.get(2));
if (expire == 0) {
expire=Integer.MAX_VALUE;
}
 else if (expire > SpaceCache.THIRTY_DAYS) {
expire=LocalCacheElement.Now() - expire;
}
cmd.element=new LocalCacheElement(new Key(parts.get(1)),flags,expire,0L);
if (numParts > 5) {
int noreply=op == Op.CAS ? 6 : 5;
if (op == Op.CAS) {
cmd.cas_key=BufferUtils.atol(parts.get(5));
}
if (numParts == noreply + 1 && Arrays.equals(parts.get(noreply),NOREPLY)) cmd.noreply=true;
}
status.needMore(size,cmd);
break;
case GET:
case GETS:
case STATS:
cmd.setKeys(parts.subList(1,numParts));
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
case VERSION:
case QUIT:
if (numParts > 1) {
throw new MalformedCommandException("invalid command length");
}
Channels.fireMessageReceived(channelHandlerContext,cmd,channel.getRemoteAddress());
break;
default :
throw new UnknownCommandException("unknown command: " + op);
}
}

private void processLine ( List < byte [ ] > parts , Channel channel , ChannelHandlerContext channelHandlerContext ) throws UnknownCommandException , MalformedCommandException { final int numParts = parts . size ( ) ; Op op ; try { op = Op . findOp ( parts . get ( 0 ) ) ; } catch ( IllegalArgumentException e ) { throw new UnknownCommandException ( "unknown operation: " + new String ( parts . get ( 0 ) ) ) ; } CommandMessage cmd = CommandMessage . command ( op ) ; switch ( op ) { case DELETE : if ( numParts < 2 || numParts > 4 ) throw new MalformedCommandException ( "invalid delete command" ) ; cmd . setKey ( parts . get ( 1 ) ) ; if ( numParts > 2 ) { if ( Arrays . equals ( parts . get ( numParts - 1 ) , NOREPLY ) ) { cmd . noreply = true ; if ( numParts == 4 ) cmd . time = BufferUtils . atoi ( ( parts . get ( 2 ) ) ) ; } else if ( numParts == 3 ) { cmd . time = BufferUtils . atoi ( ( parts . get ( 2 ) ) ) ; } else { throw new MalformedCommandException ( "invalid delete command" ) ; } } Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; case DECR : case INCR : if ( numParts < 3 || numParts > 4 ) throw new MalformedCommandException ( "invalid incr/decr command" ) ; cmd . setKey ( parts . get ( 1 ) ) ; cmd . incrAmount = BufferUtils . atoi ( parts . get ( 2 ) ) ; if ( numParts == 4 && Arrays . equals ( parts . get ( 3 ) , NOREPLY ) ) { cmd . noreply = true ; } Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; case FLUSH_ALL : if ( numParts >= 1 ) { if ( Arrays . equals ( parts . get ( numParts - 1 ) , NOREPLY ) ) { cmd . noreply = true ; if ( numParts == 3 ) cmd . time = BufferUtils . atoi ( ( parts . get ( 1 ) ) ) ; } else if ( numParts == 2 ) cmd . time = BufferUtils . atoi ( ( parts . get ( 1 ) ) ) ; } Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; case VERBOSITY : if ( numParts < 2 || numParts > 3 ) throw new MalformedCommandException ( "invalid verbosity command" ) ; cmd . time = BufferUtils . atoi ( ( parts . get ( 1 ) ) ) ; if ( numParts > 1 && Arrays . equals ( parts . get ( 2 ) , NOREPLY ) ) cmd . noreply = true ; Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; case APPEND : case PREPEND : case REPLACE : case ADD : case SET : case CAS : if ( numParts < 5 ) { throw new MalformedCommandException ( "invalid command length" ) ; } int size = BufferUtils . atoi ( parts . get ( 4 ) ) ; int expire = BufferUtils . atoi ( parts . get ( 3 ) ) ; int flags = BufferUtils . atoi ( parts . get ( 2 ) ) ; if ( expire == 0 ) { expire = Integer . MAX_VALUE ; } else if ( expire > SpaceCache . THIRTY_DAYS ) { expire = LocalCacheElement . Now ( ) - expire ; } cmd . element = new LocalCacheElement ( new Key ( parts . get ( 1 ) ) , flags , expire , 0L ) ; if ( numParts > 5 ) { int noreply = op == Op . CAS ? 6 : 5 ; if ( op == Op . CAS ) { cmd . cas_key = BufferUtils . atol ( parts . get ( 5 ) ) ; } if ( numParts == noreply + 1 && Arrays . equals ( parts . get ( noreply ) , NOREPLY ) ) cmd . noreply = true ; } status . needMore ( size , cmd ) ; break ; case GET : case GETS : case STATS : cmd . setKeys ( parts . subList ( 1 , numParts ) ) ; Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; case VERSION : case QUIT : if ( numParts > 1 ) { throw new MalformedCommandException ( "invalid command length" ) ; } Channels . fireMessageReceived ( channelHandlerContext , cmd , channel . getRemoteAddress ( ) ) ; break ; default : throw new UnknownCommandException ( "unknown command: " + op ) ; } }
process an individual complete protocol line and either passes the command for processing by the session handler , or ( in the case of set - type commands ) partially parses the command and sets the session into a state to wait for additional data .
