/** * {@inheritDoc} */ @Override public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { Context ctx = getContext(session); if (LineDelimiter.AUTO.equals(delimiter)) { decodeAuto(ctx, session, in, out); } else { decodeNormal(ctx, session, in, out); } }
/** * @return the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#getMaxLineLength()}. */ public int getDecoderMaxLineLength() { return decoder.getMaxLineLength(); }
/** * Sets the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#setMaxLineLength(int)}. */ public void setDecoderMaxLineLength(int maxLineLength) { decoder.setMaxLineLength(maxLineLength); } }
/** * Creates a new instance of TextLineCodecFactory. This constructor * provides more flexibility for the developer. * * @param charset * The charset to use in the encoding and decoding * @param encodingDelimiter * The line delimeter for the encoder * @param decodingDelimiter * The line delimeter for the decoder */ public TextLineCodecFactory(Charset charset, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter) { encoder = new TextLineEncoder(charset, encodingDelimiter); decoder = new TextLineDecoder(charset, decodingDelimiter); }
writeText(session, str, out); } finally { buf.clear();
/** * Creates a new instance with the specified {@link Charset}. The * encoder uses a UNIX {@link LineDelimiter} and the decoder uses * the AUTO {@link LineDelimiter}. * * @param charset The charset to use in the encoding and decoding */ public TextLineCodecFactory(Charset charset) { encoder = new TextLineEncoder(charset, LineDelimiter.UNIX); decoder = new TextLineDecoder(charset, LineDelimiter.AUTO); }
writeText(session, str, out); } finally { buf.clear();
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { Context ctx = getContext(session); if (LineDelimiter.AUTO.equals(delimiter)) { decodeAuto(ctx, session, in, out); } else { decodeNormal(ctx, session, in, out); } }
/** * Creates a new instance with the specified {@link Charset}. The * encoder uses a UNIX {@link LineDelimiter} and the decoder uses * the AUTO {@link LineDelimiter}. * * @param charset The charset to use in the encoding and decoding */ public TextLineCodecFactory(Charset charset) { encoder = new TextLineEncoder(charset, LineDelimiter.UNIX); decoder = new TextLineDecoder(charset, LineDelimiter.AUTO); }
/** * Returns the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#getMaxLineLength()}. */ public int getDecoderMaxLineLength() { return decoder.getMaxLineLength(); }
/** * Sets the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#setMaxLineLength(int)}. * * @param maxLineLength the maximum decoded line length */ public void setDecoderMaxLineLength(int maxLineLength) { decoder.setMaxLineLength(maxLineLength); } }
buf.limit(buf.limit() - matchCount); try { writeText(session, buf.getString(ctx.getDecoder()), out); } finally { buf.clear();
/** * {@inheritDoc} */ @Override public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { Context ctx = getContext(session); if (LineDelimiter.AUTO.equals(delimiter)) { decodeAuto(ctx, session, in, out); } else { decodeNormal(ctx, session, in, out); } }
/** * Creates a new instance with the specified {@link Charset}. */ public TextLineCodecFactory( Charset charset ) { encoder = new TextLineEncoder( charset, LineDelimiter.UNIX ); decoder = new TextLineDecoder( charset, LineDelimiter.AUTO ); }
/** * @return the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#getMaxLineLength()}. */ public int getDecoderMaxLineLength() { return decoder.getMaxLineLength(); }
/** * Sets the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#setMaxLineLength(int)}. */ public void setDecoderMaxLineLength( int maxLineLength ) { decoder.setMaxLineLength( maxLineLength ); } }
writeText(session, buf.getString(ctx.getDecoder()), out); } finally { buf.clear();
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 ) ); } }
/** * Creates a new instance with the specified {@link Charset}. The * encoder uses a UNIX {@link LineDelimiter} and the decoder uses * the AUTO {@link LineDelimiter}. * * @param charset * The charset to use in the encoding and decoding */ public TextLineCodecFactory(Charset charset) { encoder = new TextLineEncoder(charset, LineDelimiter.UNIX); decoder = new TextLineDecoder(charset, LineDelimiter.AUTO); }
/** * Returns the allowed maximum size of the line to be decoded. * If the size of the line to be decoded exceeds this value, the * decoder will throw a {@link BufferDataException}. The default * value is <tt>1024</tt> (1KB). * <p> * This method does the same job with {@link TextLineDecoder#getMaxLineLength()}. */ public int getDecoderMaxLineLength() { return decoder.getMaxLineLength(); }