private void decodeAuto(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();
    boolean matched=false;
switch (b) {
case '\r':
      matchCount++;
    break;
case '\n':
  matchCount++;
matched=true;
break;
default :
matchCount=0;
}
if (matched) {
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 {
byte[] data=new byte[buf.limit()];
buf.get(data);
CharsetDecoder decoder=ctx.getDecoder();
CharBuffer buffer=decoder.decode(ByteBuffer.wrap(data));
String str=buffer.toString();
writeText(session,str,out);
}
  finally {
buf.clear();
}
}
 else {
int overflowPosition=ctx.getOverflowPosition();
ctx.reset();
throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition);
}
oldPos=pos;
matchCount=0;
}
}
in.position(oldPos);
ctx.append(in);
ctx.setMatchCount(matchCount);
}

private void decodeAuto ( 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 ( ) ; boolean matched = false ; switch ( b ) { case '\r' : matchCount ++ ; break ; case '\n' : matchCount ++ ; matched = true ; break ; default : matchCount = 0 ; } if ( matched ) { 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 { byte [ ] data = new byte [ buf . limit ( ) ] ; buf . get ( data ) ; CharsetDecoder decoder = ctx . getDecoder ( ) ; CharBuffer buffer = decoder . decode ( ByteBuffer . wrap ( data ) ) ; String str = buffer . toString ( ) ; writeText ( session , str , out ) ; } finally { buf . clear ( ) ; } } else { int overflowPosition = ctx . getOverflowPosition ( ) ; ctx . reset ( ) ; throw new RecoverableProtocolDecoderException ( "Line is too long: " + overflowPosition ) ; } oldPos = pos ; matchCount = 0 ; } } in . position ( oldPos ) ; ctx . append ( in ) ; ctx . setMatchCount ( matchCount ) ; }
decode a line using the default delimiter on the current system
