本文整理匯總了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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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 );
}
}
示例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 ) );
}
示例7: get
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
@Override
public Short get ( final IoBuffer data, final int index )
{
return data.getUnsigned ( index );
}