本文整理汇总了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 );
}