public String getString(int fieldSize, CharsetDecoder decoder) throws CharacterCodingException { return buf.getString(fieldSize, decoder); }
public String getString(CharsetDecoder decoder) throws CharacterCodingException { return buf.getString(decoder); }
/** * Reads an ASCII string from the buffer. Reads from the buffer's current * position to its limit. * * @param buf The buffer to read from. * @return The bytes converted to an ASCII string. */ public static String getString(final ByteBuffer buf) { DECODER.reset(); try { return buf.getString(DECODER); } catch (final CharacterCodingException e) { LOG.error("Could not decode: "+buf, e); return StringUtils.EMPTY; } }
@Override protected DecodingState finishDecode(final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String version = product.getString(m_asciiDecoder); out.write(version); return null; } };
@Override protected DecodingState finishDecode(final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String reasonPhrase = product.getString(m_asciiDecoder); out.write(reasonPhrase); return null; } }
@Override protected DecodingState finishDecode(final byte foundTerminator, final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String headerName = product.getString(m_asciiDecoder); return new AfterHeaderColonState(headerName); }
@Override protected DecodingState finishDecode(final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String headerValue = product.getString(m_asciiDecoder); LOG.debug("Read header value: {}", headerValue); final SipHeader header = m_headerFactory.createHeader(this.m_headerName, headerValue); m_headers.put(this.m_headerName, header); return new FindEmptyLine(); }
@Override protected DecodingState finishDecode(final byte foundTerminator, final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String uri = product.getString(m_utf8Decoder); out.write(new URI(uri)); return new ReadSipVersionState(); } };
private SipMessageType determineMessageType(final byte terminator, final ByteBuffer product) throws CharacterCodingException { if (terminator == MinaCodecUtils.CR) { LOG.debug("Returning double CRLF"); return SipMessageType.DOUBLE_CRLF; } else { final String firstWord = product.getString(m_asciiDecoder); if (!SipMessageType.contains(firstWord)) { LOG.warn("Unknown message type: '{}'", firstWord); return SipMessageType.UNKNOWN; } else { LOG.debug("Matching message type for: {}", firstWord); return SipMessageType.convert(firstWord); } } } };
@Override protected DecodingState finishDecode(final byte foundTerminator, final ByteBuffer product, final ProtocolDecoderOutput out) throws Exception { final String statusCodeString = product.getString(m_asciiDecoder); if (!NumberUtils.isNumber(statusCodeString)) { LOG.warn("Bad status code: "+statusCodeString); throw new IllegalArgumentException( "Bad status code: "+statusCodeString); } final Integer statusCode = Integer.decode(statusCodeString); out.write(statusCode); return new ReadResponseReasonPhraseState(); } }
/** * Useful for debugging. Turns the given buffer into an ASCII string. * This does not affect the position or the limit of the buffer (it resets * them to their original values when done). * * @param buf The buffer to convert to a string. * @return The string. */ public static String toAsciiString(final ByteBuffer buf) { DECODER.reset(); final int position = buf.position(); final int limit = buf.limit(); try { return buf.getString(DECODER); } catch (final CharacterCodingException e) { LOG.error("Could not decode: "+buf, e); return StringUtils.EMPTY; } finally { buf.position(position); buf.limit(limit); } }
buf.limit(buf.limit() - matchCount); try { out.write(buf.getString(ctx.getDecoder())); } finally { buf.clear();
buf.limit(buf.limit() - matchCount); try { out.write(buf.getString(ctx.getDecoder())); } finally { buf.clear();
buf.limit(buf.limit() - matchCount); final String headers = buf.getString(decoder); final Map<String, SipHeader> headersMap = createHeadersMap(headers);