コード例 #1
0
ファイル: QueryRequest.java プロジェクト: dCache/xrootd4j
  public QueryRequest(ByteBuf buffer) {
    super(buffer, kXR_query);
    reqcode = buffer.getUnsignedShort(4);
    fhandle = buffer.getInt(8);
    int alen = buffer.getInt(20);

    /* The protocol spec doesn't state anything about trailing zeros in args,
     * however the xrdfs client sends zero terminated paths.
     */
    args = NULL_CHARACTER.trimTrailingFrom(buffer.toString(24, alen, US_ASCII));
  }
コード例 #2
0
ファイル: TestEndian.java プロジェクト: mengtest/ttpod-rpc
  @Test(timeout = 1000)
  public void a() {
    ByteBuf buf = Unpooled.buffer(4);
    buf.setInt(0, 1);
    System.out.format("%08x%n", buf.getInt(0));
    ByteBuf leBuf = buf.order(ByteOrder.LITTLE_ENDIAN);
    // 打印出 '01000000'
    System.out.format("%08x%n", leBuf.getInt(0));

    assert buf != leBuf;
    assert buf == buf.order(ByteOrder.BIG_ENDIAN);
  }
コード例 #3
0
 @Override
 protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
   if (in.readableBytes() < 4 * Integer.SIZE / Byte.SIZE) {
     return;
   }
   int numPayloads = in.getInt(in.readerIndex() + 3 * Integer.SIZE / Byte.SIZE);
   int index = 4 * Integer.SIZE / Byte.SIZE;
   for (int i = 0; i < numPayloads; i++) {
     if (in.readableBytes() < index + Integer.SIZE / Byte.SIZE) {
       return;
     }
     int size = in.getInt(in.readerIndex() + index);
     index += Integer.SIZE / Byte.SIZE + size;
     if (in.readableBytes() < index) {
       return;
     }
   }
   int sender = in.readInt();
   int dest = in.readInt();
   int msgType = in.readInt();
   numPayloads = in.readInt();
   Msg msg = new Msg(msgType);
   msg.setSender(sender);
   msg.setDest(dest);
   for (int i = 0; i < numPayloads; i++) {
     int size = in.readInt();
     if (size > 0) {
       ByteBuffer buffer = ByteBuffer.allocate(size);
       in.readBytes(buffer);
       buffer.rewind();
       msg.addPayload(buffer);
     } else {
       msg.addPayload(null);
     }
   }
   out.add(msg);
 }
コード例 #4
0
 @Override
 public int getInt(int index) {
   return buf.getInt(index);
 }
コード例 #5
0
ファイル: Buffer.java プロジェクト: hgschmie/vert.x
 /**
  * Returns the {@code int} at position {@code pos} in the Buffer.
  *
  * @throws IndexOutOfBoundsException if the specified {@code pos} is less than {@code 0} or {@code
  *     pos + 4} is greater than the length of the Buffer.
  */
 public int getInt(int pos) {
   return buffer.getInt(pos);
 }
コード例 #6
0
 @Override
 public int getInt(int var1) {
   return a.getInt(var1);
 }