private void decodeNormal(Context ctx,IoSession session,IoBuffer in,ProtocolDecoderOutput out) throws CharacterCodingException, ProtocolDecoderException {
  int matchCount=ctx.getMatchCount();
  int oldPos=in.position();
  int oldLimit=in.limit();
  while (in.hasRemaining()) {
    byte b=in.get();
    if (delimBuf.get(matchCount) == b) {
      matchCount++;
      if (matchCount == delimBuf.limit()) {
        int pos=in.position();
        in.limit(pos);
        in.position(oldPos);
        ctx.append(in);
        in.limit(oldLimit);
        in.position(pos);
        if (ctx.getOverflowPosition() == 0) {
          IoBuffer buf=ctx.getBuffer();
          buf.flip();
          buf.limit(buf.limit() - matchCount);
          try {
            writeText(session,buf.getString(ctx.getDecoder()),out);
          }
  finally {
            buf.clear();
          }
        }
 else {
          int overflowPosition=ctx.getOverflowPosition();
          ctx.reset();
          throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition);
        }
        oldPos=pos;
        matchCount=0;
      }
    }
 else {
      in.position(Math.max(0,in.position() - matchCount));
      matchCount=0;
    }
  }
  in.position(oldPos);
  ctx.append(in);
  ctx.setMatchCount(matchCount);
}

private void decodeNormal ( Context ctx , IoSession session , IoBuffer in , ProtocolDecoderOutput out ) throws CharacterCodingException , ProtocolDecoderException { int matchCount = ctx . getMatchCount ( ) ; int oldPos = in . position ( ) ; int oldLimit = in . limit ( ) ; while ( in . hasRemaining ( ) ) { byte b = in . get ( ) ; if ( delimBuf . get ( matchCount ) == b ) { matchCount ++ ; if ( matchCount == delimBuf . limit ( ) ) { int pos = in . position ( ) ; in . limit ( pos ) ; in . position ( oldPos ) ; ctx . append ( in ) ; in . limit ( oldLimit ) ; in . position ( pos ) ; if ( ctx . getOverflowPosition ( ) == 0 ) { IoBuffer buf = ctx . getBuffer ( ) ; buf . flip ( ) ; buf . limit ( buf . limit ( ) - matchCount ) ; try { writeText ( session , buf . getString ( ctx . getDecoder ( ) ) , out ) ; } finally { buf . clear ( ) ; } } else { int overflowPosition = ctx . getOverflowPosition ( ) ; ctx . reset ( ) ; throw new RecoverableProtocolDecoderException ( "Line is too long: " + overflowPosition ) ; } oldPos = pos ; matchCount = 0 ; } } else { in . position ( Math . max ( 0 , in . position ( ) - matchCount ) ) ; matchCount = 0 ; } } in . position ( oldPos ) ; ctx . append ( in ) ; ctx . setMatchCount ( matchCount ) ; }
decode a line using the delimiter defined by the caller
