本文整理了Java中org.littleshoot.mina.common.ByteBuffer.getString()
方法的一些代码示例,展示了ByteBuffer.getString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.getString()
方法的具体详情如下:
包路径:org.littleshoot.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:getString
[英]Reads a NUL
-terminated string from this buffer using the specified decoder
and returns it.
[中]使用指定的decoder
从该缓冲区读取以NUL
结尾的字符串并返回该字符串。
代码示例来源:origin: org.littleshoot/mina-port
public String getString(int fieldSize, CharsetDecoder decoder)
throws CharacterCodingException {
return buf.getString(fieldSize, decoder);
}
代码示例来源:origin: org.littleshoot/mina-port
public String getString(CharsetDecoder decoder)
throws CharacterCodingException {
return buf.getString(decoder);
}
代码示例来源:origin: org.littleshoot/mina-util
/**
* 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;
}
}
代码示例来源:origin: org.littleshoot/sip-stack
@Override
protected DecodingState finishDecode(final ByteBuffer product,
final ProtocolDecoderOutput out) throws Exception
{
final String version = product.getString(m_asciiDecoder);
out.write(version);
return null;
}
};
代码示例来源:origin: org.littleshoot/sip-stack
@Override
protected DecodingState finishDecode(final ByteBuffer product,
final ProtocolDecoderOutput out) throws Exception
{
final String reasonPhrase = product.getString(m_asciiDecoder);
out.write(reasonPhrase);
return null;
}
}
代码示例来源:origin: org.littleshoot/sip-stack
@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);
}
代码示例来源:origin: org.littleshoot/sip-stack
@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();
}
代码示例来源:origin: org.littleshoot/sip-stack
@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();
}
};
代码示例来源:origin: org.littleshoot/sip-stack
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);
}
}
}
};
代码示例来源:origin: org.littleshoot/sip-stack
@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();
}
}
代码示例来源:origin: org.littleshoot/mina-util
/**
* 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);
}
}
代码示例来源:origin: org.littleshoot/mina-port
buf.limit(buf.limit() - matchCount);
try {
out.write(buf.getString(ctx.getDecoder()));
} finally {
buf.clear();
代码示例来源:origin: org.littleshoot/mina-port
buf.limit(buf.limit() - matchCount);
try {
out.write(buf.getString(ctx.getDecoder()));
} finally {
buf.clear();
代码示例来源:origin: org.littleshoot/sip-stack
buf.limit(buf.limit() - matchCount);
final String headers = buf.getString(decoder);
final Map<String, SipHeader> headersMap =
createHeadersMap(headers);
内容来源于网络,如有侵权,请联系作者删除!