当前位置: 首页>>代码示例>>Java>>正文


Java IoBuffer.getUnsigned方法代码示例

本文整理汇总了Java中org.apache.mina.core.buffer.IoBuffer.getUnsigned方法的典型用法代码示例。如果您正苦于以下问题:Java IoBuffer.getUnsigned方法的具体用法?Java IoBuffer.getUnsigned怎么用?Java IoBuffer.getUnsigned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.core.buffer.IoBuffer的用法示例。


在下文中一共展示了IoBuffer.getUnsigned方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out) throws Exception {
    while (in.hasRemaining()) {
        switch (counter) {
        case 0:
            firstByte = in.getUnsigned();
            break;
        case 1:
            secondByte = in.getUnsigned();
            break;
        case 2:
            thirdByte = in.getUnsigned();
            break;
        case 3:
            counter = 0;
            return finishDecode((firstByte << 24) | (secondByte << 16) | (thirdByte << 8) | in.getUnsigned(), out);
        default:
            throw new InternalError();
        }
        counter++;
    }

    return this;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:IntegerDecodingState.java

示例2: decode

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out) throws Exception {

    while (in.hasRemaining()) {
        switch (counter) {
        case 0:
            highByte = in.getUnsigned();
            break;
        case 1:
            counter = 0;
            return finishDecode((short) ((highByte << 8) | in.getUnsigned()), out);
        default:
            throw new InternalError();
        }

        counter++;
    }
    return this;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:ShortIntegerDecodingState.java

示例3: decodeDataReadReply

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private DaveMessage decodeDataReadReply ( final IoBuffer parameters, final IoBuffer data )
{
    parameters.get (); // command code

    final short count = parameters.getUnsigned ();

    final Collection<Result> result = new LinkedList<Result> ();

    for ( int i = 0; i < count; i++ )
    {
        final short q = data.getUnsigned ();
        if ( q == 0xFF && data.remaining () > 4 )
        {
            final byte type = data.get ();
            int len = data.getUnsignedShort ();
            if ( type == 4 )
            {
                len >>= 3;
            }

            final IoBuffer valueData = IoBuffer.allocate ( len );
            data.get ( valueData.array () );
            result.add ( new Result ( valueData ) );

            if ( len % 2 != 0 && data.remaining () > 0 )
            {
                data.get ();
            }
        }
        else if ( q != 0xFF )
        {
            result.add ( new Result ( q ) );
        }
    }

    return new DaveReadResult ( result );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:38,代码来源:DaveFilter.java

示例4: readBytesArrayWithPrefix

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
 * Read a set of bytes with the first byte being the number of bytes to read
 *
 * @param buffer
 *            the buffer to read from
 * @return the result read
 */
private static byte[] readBytesArrayWithPrefix ( final IoBuffer buffer )
{
    final short numOfBytes = buffer.getUnsigned ();

    logger.trace ( "Prepare to read {} bytes", numOfBytes );

    final byte[] result = new byte[numOfBytes];
    buffer.get ( result, 0, numOfBytes );
    return result;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:ModbusProtocol.java

示例5: messageReceived

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void messageReceived ( final NextFilter nextFilter, final IoSession session, final Object message ) throws Exception
{
    logger.debug ( "Message received: {} - {}", new Object[] { session, message } );
    if ( ! ( message instanceof IoBuffer ) )
    {
        return;
    }
    final IoBuffer buffer = (IoBuffer)message;

    final short command = (short) ( buffer.getUnsigned ( 1 ) >> 4 );

    logger.debug ( "Command: {}", command );

    if ( command == COMMAND_CONNECT_CONFIRM )
    {
        handleConnectConfirm ( nextFilter, session, buffer );
    }
    else if ( command == COMMAND_DATA )
    {
        handleData ( nextFilter, session, buffer );
    }
    else
    {
        logger.warn ( "Unknown command: {}", command );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:28,代码来源:COTPFilter.java

示例6: handleData

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void handleData ( final NextFilter nextFilter, final IoSession session, final IoBuffer buffer )
{
    final short len = buffer.getUnsigned ();
    final short command = buffer.getUnsigned ();
    final short nr = buffer.getUnsigned ();

    // FIXME: append data TPDUs if there is more than one 

    nextFilter.messageReceived ( session, new DataTPDU ( buffer ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:COTPFilter.java

示例7: get

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public Short get ( final IoBuffer data, final int index )
{
    return data.getUnsigned ( index );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:6,代码来源:UInt8Accessor.java


注:本文中的org.apache.mina.core.buffer.IoBuffer.getUnsigned方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。