当前位置: 首页>>代码示例>>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;未经允许,请勿转载。