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


Java ByteBuf.getUnsignedByte方法代碼示例

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


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

示例1: getUnadjustedFrameLength

import io.netty.buffer.ByteBuf; //導入方法依賴的package包/類
/**
 * Decodes the specified region of the buffer into an unadjusted frame length.  The default implementation is
 * capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer.  Override this method to
 * decode the length field encoded differently.  Note that this method must not modify the state of the specified
 * buffer (e.g. {@code readerIndex}, {@code writerIndex}, and the content of the buffer.)
 *
 * @throws DecoderException
 *         if failed to decode the specified region
 */
protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
    buf = buf.order(order);
    long frameLength;
    switch (length) {
        case 1:
            frameLength = buf.getUnsignedByte(offset);
            break;
        case 2:
            frameLength = buf.getUnsignedShort(offset);
            break;
        case 3:
            frameLength = buf.getUnsignedMedium(offset);
            break;
        case 4:
            frameLength = buf.getUnsignedInt(offset);
            break;
        case 8:
            frameLength = buf.getLong(offset);
            break;
        default:
            throw new DecoderException(
                    "unsupported lengthFieldLength: " + lengthFieldLength + " (expected: 1, 2, 3, 4, or 8)");
    }
    return frameLength;
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:35,代碼來源:LengthFieldBasedFrameDecoder.java

示例2: decode

import io.netty.buffer.ByteBuf; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {

    // 프로토콜 확인을 위해서 5byte를 확인한다.
    if (in.readableBytes() < 5) {
        // 다음 inbound 시 버퍼에 이전에 전송된 내용이 쌓이므로 버퍼를 비운다.
        in.clear();
        return;
    }

    if (isSsl(in)) {
        enableSsl(ctx);
    } else {

        if (!isUnificationMode) {
            switchToBinary(ctx);
            return;
        }

        final int magicPacket1 = in.getUnsignedByte(in.readerIndex());
        final int magicPacket2 = in.getUnsignedByte(in.readerIndex() + 1);

        if (isHttp(magicPacket1, magicPacket2)) {
            switchToHttp(ctx);
        } else {
            switchToBinary(ctx);
        }
    }
}
 
開發者ID:veritasware,項目名稱:neto,代碼行數:30,代碼來源:ProtocolUnificationHandler.java

示例3: decode

import io.netty.buffer.ByteBuf; //導入方法依賴的package包/類
@Override
protected void decode ( final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out ) throws Exception
{
    if ( logger.isTraceEnabled () )
    {
        logger.trace ( "decode - bytes: {}", ByteBufUtil.hexDump ( in ) );
    }

    if ( in.readableBytes () < Constants.APCI_MIN_LENGTH )
    {
        return;
    }

    final byte start = in.getByte ( in.readerIndex () + 0 );
    if ( start != Constants.START_BYTE )
    {
        throw new DecoderException ( String.format ( "ACPI must start with 0x%02x but did with 0x%02x", Constants.START_BYTE, start ) );
    }

    final short len = in.getUnsignedByte ( in.readerIndex () + 1 );

    if ( len > Constants.APCI_MAX_DATA_LENGTH )
    {
        throw new DecoderException ( String.format ( "APCI has a maximum length of %s bytes, but we received %s", Constants.APCI_MAX_DATA_LENGTH, len ) );
    }

    if ( in.readableBytes () < len + 2 )
    {
        return;
    }

    // we have the full InformationTransfer

    // skip start & len
    in.skipBytes ( 2 );

    // read control fields
    final ByteBuf controlFields = in.readSlice ( 4 );

    final ByteBuf data;
    if ( len > 4 )
    {
        data = Unpooled.copiedBuffer ( in.readSlice ( len - 4 ) ).order ( ByteOrder.LITTLE_ENDIAN );
    }
    else
    {
        data = null;
    }

    // now add the PDU

    out.add ( decode ( controlFields, data ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:54,代碼來源:APDUDecoder.java

示例4: toArray

import io.netty.buffer.ByteBuf; //導入方法依賴的package包/類
public int[] toArray ()
{
    final ByteBuf buf = Unpooled.buffer ( 4 );
    buf.writeMedium ( this.address );
    return new int[] { buf.getUnsignedByte ( 0 ), buf.getUnsignedByte ( 1 ), buf.getUnsignedByte ( 2 ) };
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:7,代碼來源:InformationObjectAddress.java

示例5: toArray

import io.netty.buffer.ByteBuf; //導入方法依賴的package包/類
public int[] toArray ()
{
    final ByteBuf buf = Unpooled.buffer ( 2 );
    buf.writeShort ( this.address );
    return new int[] { buf.getUnsignedByte ( 0 ), buf.getUnsignedByte ( 1 ) };
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:7,代碼來源:ASDUAddress.java


注:本文中的io.netty.buffer.ByteBuf.getUnsignedByte方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。