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


Java IoBuffer.getPrefixedString方法代碼示例

本文整理匯總了Java中org.apache.mina.core.buffer.IoBuffer.getPrefixedString方法的典型用法代碼示例。如果您正苦於以下問題:Java IoBuffer.getPrefixedString方法的具體用法?Java IoBuffer.getPrefixedString怎麽用?Java IoBuffer.getPrefixedString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.mina.core.buffer.IoBuffer的用法示例。


在下文中一共展示了IoBuffer.getPrefixedString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doDecode

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
    if (in.prefixedDataAvailable(prefixLength, maxDataLength)) {
        String msg = in.getPrefixedString(prefixLength, charset.newDecoder());
        out.write(msg);
        return true;
    }

    return false;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:10,代碼來源:PrefixedStringDecoder.java

示例2: decodeString

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private String decodeString ( final IoSession session, final IoBuffer data ) throws CharacterCodingException
{
    final String result = data.getPrefixedString ( Sessions.getCharsetDecoder ( session ) );
    if ( result.isEmpty () )
    {
        return null;
    }
    else
    {
        return result;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:13,代碼來源:ProtocolDecoderImpl.java

示例3: decodeBrowserAddEntry

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private BrowseAdded.Entry decodeBrowserAddEntry ( final IoBuffer data, final IoSession session ) throws ProtocolCodecException
{
    final short register = (short)data.getUnsignedShort ();
    // FIXME: validate if short works

    final byte b = data.get ();
    final DataType dataType = DataType.fromByte ( b );

    if ( dataType == null )
    {
        throw new ProtocolCodecException ( String.format ( "Data type %s is unkown", b ) );
    }

    final Set<BrowseAdded.Entry.Flags> flags = data.getEnumSet ( BrowseAdded.Entry.Flags.class );

    final CharsetDecoder decoder = Sessions.getCharsetDecoder ( session );

    try
    {
        final String name = data.getPrefixedString ( decoder );
        final String description = data.getPrefixedString ( decoder );
        final String unit = data.getPrefixedString ( decoder );
        return new BrowseAdded.Entry ( register, name, description, unit, dataType, flags );
    }
    catch ( final CharacterCodingException e )
    {
        throw new ProtocolCodecException ( e );
    }

}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:31,代碼來源:ProtocolDecoderImpl.java

示例4: processWelcome

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private boolean processWelcome ( final IoSession session, final IoBuffer data, final ProtocolDecoderOutput out ) throws ProtocolCodecException
{
    final int len = messageLength ( data );
    if ( len < 0 )
    {
        return false;
    }

    final EnumSet<Welcome.Features> features = data.getEnumSetShort ( Welcome.Features.class );

    logger.debug ( "Features: {}", features );

    final CharsetDecoder decoder = this.defaultCharset.newDecoder ();

    final int count = data.getUnsignedShort ();
    final Map<String, String> properties = new HashMap<String, String> ( count );

    for ( int i = 0; i < count; i++ )
    {
        try
        {
            final String key = data.getPrefixedString ( decoder );
            final String value = data.getPrefixedString ( decoder );

            properties.put ( key, value );
        }
        catch ( final CharacterCodingException e )
        {
            throw new ProtocolCodecException ( e );
        }
    }

    if ( features.contains ( Welcome.Features.LITTLE_ENDIAN ) )
    {
        logger.info ( "Setting little endian" );
        Sessions.setLittleEndian ( session );
    }

    out.write ( new Welcome ( features, properties ) );

    return true;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:43,代碼來源:ProtocolDecoderImpl.java


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