當前位置: 首頁>>代碼示例>>Java>>正文


Java IoBuffer.putString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:25,代碼來源:MessageChannelCodecFilter.java

示例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);
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:TextLineEncoder.java

示例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 );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:18,代碼來源:FixedLengthStringAccessor.java

示例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 );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:13,代碼來源:MessageChannelCodecFilter.java

示例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;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:31,代碼來源:TextLineDecoder.java


注:本文中的org.apache.mina.core.buffer.IoBuffer.putString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。