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


Java IoBuffer.getEnumSetShort方法代碼示例

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


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

示例1: processHello

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

    final byte version = data.get ();
    if ( version != 0x01 )
    {
        throw new ProtocolCodecException ( String.format ( "Protocol version %s is unsupported", version ) );
    }

    final short nodeId = data.getShort ();
    final EnumSet<Hello.Features> features = data.getEnumSetShort ( Hello.Features.class );

    out.write ( new Hello ( nodeId, features ) );

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

示例2: decodeDataUpdateEntry

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private DataUpdate.Entry decodeDataUpdateEntry ( final IoBuffer data, final IoSession session ) throws ProtocolCodecException
{
    final int register = data.getUnsignedShort ();
    final byte missedUpdates = data.get ();
    final long timestamp = data.getLong ();
    final Set<DataUpdate.State> states = data.getEnumSetShort ( DataUpdate.State.class );

    final Variant value = decodeVariant ( session, data );

    return new DataUpdate.Entry ( register, value, timestamp, states, missedUpdates );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:12,代碼來源:ProtocolDecoderImpl.java

示例3: decodeEnumSet

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
@Override
public <E extends Enum<E>> Set<E> decodeEnumSet ( final IoBuffer buffer, final Class<E> enumClazz ) throws Exception
{
    final byte type = checkType ( buffer, TYPE_ENUM_SET, true );
    if ( type == TYPE_NULL )
    {
        return null;
    }

    return buffer.getEnumSetShort ( enumClazz );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:12,代碼來源:DefaultBinaryContext.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.getEnumSetShort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。