本文整理匯總了Java中org.apache.mina.core.buffer.IoBuffer.putString方法的典型用法代碼示例。如果您正苦於以下問題:Java IoBuffer.putString方法的具體用法?Java IoBuffer.putString怎麽用?Java IoBuffer.putString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.core.buffer.IoBuffer
的用法示例。
在下文中一共展示了IoBuffer.putString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeProperties
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private IoBuffer encodeProperties ( final IoSession session, final Map<String, String> properties ) throws CharacterCodingException
{
final IoBuffer data = IoBuffer.allocate ( 0 );
data.setAutoExpand ( true );
data.putInt ( properties.size () );
final CharsetEncoder encoder = getCharsetEncoder ( session );
for ( final Map.Entry<String, String> entry : properties.entrySet () )
{
final String key = entry.getKey ();
final String value = entry.getValue ();
data.putString ( key, encoder );
data.put ( (byte)0x00 );
data.putString ( value, encoder );
data.put ( (byte)0x00 );
}
data.flip ();
return data;
}
示例2: encode
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER);
if (encoder == null) {
encoder = charset.newEncoder();
session.setAttribute(ENCODER, encoder);
}
String value = (message == null ? "" : message.toString());
IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
buf.putString(value, encoder);
if (buf.position() > maxLineLength) {
throw new IllegalArgumentException("Line length: " + buf.position());
}
buf.putString(delimiter.getValue(), encoder);
buf.flip();
out.write(buf);
}
示例3: put
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
@Override
public void put ( final IoBuffer data, final String value )
{
if ( value == null )
{
data.put ( (byte)0x00 );
}
try
{
data.putString ( value, this.length, this.charset.newEncoder () );
}
catch ( final CharacterCodingException e )
{
throw new RuntimeException ( e );
}
}
示例4: encodeCloseMessage
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private Frame encodeCloseMessage ( final IoSession session, final CloseMessage message ) throws CharacterCodingException
{
final IoBuffer data = IoBuffer.allocate ( 0 );
data.setAutoExpand ( true );
data.putString ( message.getMessage (), getCharsetEncoder ( session ) );
data.put ( (byte)0x00 );
data.putInt ( message.getCode () );
data.flip ();
return new Frame ( FrameType.CLOSE, data );
}
示例5: TextLineDecoder
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
/**
* Creates a new instance with the specified <tt>charset</tt>
* and the specified <tt>delimiter</tt>.
*/
public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
if (charset == null) {
throw new IllegalArgumentException("charset parameter shuld not be null");
}
if (delimiter == null) {
throw new IllegalArgumentException("delimiter parameter should not be null");
}
this.charset = charset;
this.delimiter = delimiter;
// Convert delimiter to ByteBuffer if not done yet.
if (delimBuf == null) {
IoBuffer tmp = IoBuffer.allocate(2).setAutoExpand(true);
try {
tmp.putString(delimiter.getValue(), charset.newEncoder());
} catch (CharacterCodingException cce) {
}
tmp.flip();
delimBuf = tmp;
}
}