int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); if (ctx.getOverflowPosition() == 0) { IoBuffer buf = ctx.getBuffer(); buf.flip(); buf.limit(buf.limit() - matchCount); byte[] data = new byte[buf.limit()]; buf.get(data); CharsetDecoder decoder = ctx.getDecoder(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
private void decodeAuto(Context ctx, IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws CharacterCodingException, ProtocolDecoderException { int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); 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(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException( "Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); if (ctx.getOverflowPosition() == 0) { IoBuffer buf = ctx.getBuffer(); buf.flip(); buf.limit(buf.limit() - matchCount); byte[] data = new byte[buf.limit()]; buf.get(data); CharsetDecoder decoder = ctx.getDecoder(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); if (ctx.getOverflowPosition() == 0) { IoBuffer buf = ctx.getBuffer(); buf.flip(); buf.limit(buf.limit() - matchCount); writeText(session, buf.getString(ctx.getDecoder()), out); } finally { buf.clear(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
private void decodeNormal(Context ctx, IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws CharacterCodingException, ProtocolDecoderException { int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); 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(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException( "Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
int matchCount = ctx.getMatchCount(); in.position(oldPos); ctx.append(in); if (ctx.getOverflowPosition() == 0) { IoBuffer buf = ctx.getBuffer(); buf.flip(); buf.limit(buf.limit() - matchCount); writeText(session, buf.getString(ctx.getDecoder()), out); } finally { buf.clear(); int overflowPosition = ctx.getOverflowPosition(); ctx.reset(); throw new RecoverableProtocolDecoderException("Line is too long: " + overflowPosition); ctx.append(in); ctx.setMatchCount(matchCount);
public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws Exception { Context ctx = getContext(session); if( LineDelimiter.AUTO.equals( delimiter ) ) { ctx.setMatchCount( decodeAuto( in, ctx.getBuffer(), ctx.getMatchCount(), ctx.getDecoder(), out ) ); } else { ctx.setMatchCount( decodeNormal( in, ctx.getBuffer(), ctx.getMatchCount(), ctx.getDecoder(), out ) ); } }
/** * @return the context for this session * * @param session The session for which we want the context */ private Context getContext(IoSession session) { Context ctx; ctx = (Context) session.getAttribute(CONTEXT); if (ctx == null) { ctx = new Context(bufferLength); session.setAttribute(CONTEXT, ctx); } return ctx; }
private Context getContext(IoSession session) { Context ctx; ctx = (Context) session.getAttribute(CONTEXT); if (ctx == null) { ctx = new Context(); session.setAttribute(CONTEXT, ctx); } return ctx; }
/** * @return the context for this session * * @param session The session for which we want the context */ private Context getContext(IoSession session) { Context ctx; ctx = (Context) session.getAttribute(CONTEXT); if (ctx == null) { ctx = new Context(bufferLength); session.setAttribute(CONTEXT, ctx); } return ctx; }
public void dispose( IoSession session ) throws Exception { Context ctx = ( Context ) session.getAttribute( CONTEXT ); if( ctx != null ) { ctx.getBuffer().release(); session.removeAttribute( CONTEXT ); } }
private Context getContext(IoSession session) { Context ctx; ctx = ( Context ) session.getAttribute( CONTEXT ); if( ctx == null ) { ctx = new Context(); session.setAttribute( CONTEXT, ctx ); } return ctx; }