/** * Sets the the length of the content line to be decoded. * When set, it overrides the dynamic delimiter setting and content length * method will be used for decoding on the next decodeOnce call. * The default value is <tt>-1</tt>. * * @param contentLength the content length to match * @param resetMatchCount delimiter matching is reset if true */ public void setContentLength(int contentLength, boolean resetMatchCount) { if (contentLength <= 0) { throw new IllegalArgumentException("contentLength: " + contentLength); } ctx.setContentLength(contentLength); if (resetMatchCount) { ctx.setMatchCount(0); } }
int contentLength = ctx.getContentLength(); IoBuffer decodedBuffer = ctx.getDecodedBuffer(); int readBytes = in.remaining(); decodedBuffer.put(in); ctx.setDecodedBuffer(decodedBuffer); ctx.setContentLength(contentLength - readBytes); return null; decodedBuffer.flip(); in.limit(oldLimit); ctx.reset(); int matchCount = ctx.getMatchCount(); IoBuffer delimiter = ctx.getDelimiter(); ctx.reset(); ctx.setMatchCount(matchCount); ctx.setDecodedBuffer(decodedBuffer);
int contentLength = ctx.getContentLength(); IoBuffer decodedBuffer = ctx.getDecodedBuffer(); int readBytes = in.remaining(); decodedBuffer.put(in); ctx.setDecodedBuffer(decodedBuffer); ctx.setContentLength(contentLength - readBytes); return null; decodedBuffer.flip(); in.limit(oldLimit); ctx.reset(); int matchCount = ctx.getMatchCount(); IoBuffer delimiter = ctx.getDelimiter(); ctx.reset(); ctx.setMatchCount(matchCount); ctx.setDecodedBuffer(decodedBuffer);
int contentLength = ctx.getContentLength(); IoBuffer decodedBuffer = ctx.getDecodedBuffer(); int readBytes = in.remaining(); decodedBuffer.put(in); ctx.setDecodedBuffer(decodedBuffer); ctx.setContentLength(contentLength - readBytes); return null; decodedBuffer.flip(); in.limit(oldLimit); ctx.reset(); int matchCount = ctx.getMatchCount(); IoBuffer delimiter = ctx.getDelimiter(); ctx.reset(); ctx.setMatchCount(matchCount); ctx.setDecodedBuffer(decodedBuffer);
/** * Dynamically sets a new delimiter. Next time * {@link IoBufferDecoder#decodeOnce(IoSession, int) } will be called it will use the new * delimiter. Delimiter matching is reset only if <tt>resetMatchCount</tt> is true but * decoding will continue from current position. * * NB : Delimiter {@link LineDelimiter#AUTO} is not allowed. * * @param delim the new delimiter as a byte array * @param resetMatchCount delimiter matching is reset if true */ public void setDelimiter(byte[] delim, boolean resetMatchCount) { if (delim == null) { throw new NullPointerException("Null delimiter not allowed"); } // Convert delimiter to IoBuffer. IoBuffer delimiter = IoBuffer.allocate(delim.length); delimiter.put(delim); delimiter.flip(); ctx.setDelimiter(delimiter); ctx.setContentLength(-1); if (resetMatchCount) { ctx.setMatchCount(0); } }
/** * Dynamically sets a new delimiter. Next time * {@link #decodeFully(IoBuffer)} will be called it will use the new * delimiter. Delimiter matching is reset only if <tt>resetMatchCount</tt> is true but * decoding will continue from current position. * * NB : Delimiter {@link LineDelimiter#AUTO} is not allowed. * * @param delim the new delimiter as a byte array * @param resetMatchCount delimiter matching is reset if true */ public void setDelimiter(byte[] delim, boolean resetMatchCount) { if (delim == null) { throw new IllegalArgumentException("Null delimiter not allowed"); } // Convert delimiter to IoBuffer. IoBuffer delimiter = IoBuffer.allocate(delim.length); delimiter.put(delim); delimiter.flip(); ctx.setDelimiter(delimiter); ctx.setContentLength(-1); if (resetMatchCount) { ctx.setMatchCount(0); } }
/** * Dynamically sets a new delimiter. Next time * {@link #decodeFully(IoBuffer)} will be called it will use the new * delimiter. Delimiter matching is reset only if <tt>resetMatchCount</tt> is true but * decoding will continue from current position. * * NB : Delimiter {@link LineDelimiter#AUTO} is not allowed. * * @param delim the new delimiter as a byte array * @param resetMatchCount delimiter matching is reset if true */ public void setDelimiter(byte[] delim, boolean resetMatchCount) { if (delim == null) { throw new IllegalArgumentException("Null delimiter not allowed"); } // Convert delimiter to IoBuffer. IoBuffer delimiter = IoBuffer.allocate(delim.length); delimiter.put(delim); delimiter.flip(); ctx.setDelimiter(delimiter); ctx.setContentLength(-1); if (resetMatchCount) { ctx.setMatchCount(0); } }
/** * Sets the the length of the content line to be decoded. * When set, it overrides the dynamic delimiter setting and content length * method will be used for decoding on the next decodeOnce call. * The default value is <tt>-1</tt>. * * @param contentLength the content length to match * @param resetMatchCount delimiter matching is reset if true */ public void setContentLength(int contentLength, boolean resetMatchCount) { if (contentLength <= 0) { throw new IllegalArgumentException("contentLength: " + contentLength); } ctx.setContentLength(contentLength); if (resetMatchCount) { ctx.setMatchCount(0); } }
/** * Sets the the length of the content line to be decoded. * When set, it overrides the dynamic delimiter setting and content length * method will be used for decoding on the next decodeOnce call. * The default value is <tt>-1</tt>. * * @param contentLength the content length to match * @param resetMatchCount delimiter matching is reset if true */ public void setContentLength(int contentLength, boolean resetMatchCount) { if (contentLength <= 0) { throw new IllegalArgumentException("contentLength: " + contentLength); } ctx.setContentLength(contentLength); if (resetMatchCount) { ctx.setMatchCount(0); } }