當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。