Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.array()


    ChannelBuffer buffer = (ChannelBuffer) msg;
   
    // TODO return this instead of byte array. This maybe more useful protocol.
    //buffer.toByteBuffer();
    return buffer.array();
  }
}
View Full Code Here


       
            ChannelBuffer buf = (ChannelBuffer) e.getMessage();     
            byte[] line;
           
            if (buf.hasArray()) {
                line = buf.array();
            } else {
                // copy the ChannelBuffer to a byte array to process the LineHandler
                line = new byte[buf.capacity()];
                buf.getBytes(0, line);
            }
View Full Code Here

   */
  public static String base64(byte[] bytes) {
   
    ChannelBuffer buf = Base64.encode(ChannelBuffers.wrappedBuffer(bytes));
    try {
      return new String(buf.array(), "ASCII");
    } catch (UnsupportedEncodingException e) {
      log.error("Caught", e);
    }
    return null;
  }
View Full Code Here

  }
 
  public static String base64(byte[] bytes, Base64Dialect dialect) {
    ChannelBuffer buf = Base64.encode(ChannelBuffers.wrappedBuffer(bytes), dialect);
    try {
      return new String(buf.array(), "ASCII");
    } catch (UnsupportedEncodingException e) {
      log.error("Caught", e);
    }
    return null;
  }
View Full Code Here

        ChannelBuffer buf = (ChannelBuffer) msg;
        if (buf.hasArray()) {
            if(extensionRegistry == null) {
                return prototype.newBuilderForType().mergeFrom(
                        buf.array(),buf.arrayOffset(), buf.readableBytes()).build();
            } else {
                return prototype.newBuilderForType().mergeFrom(
                        buf.array(), buf.arrayOffset(), buf.readableBytes(), extensionRegistry).build();
            }
        } else {
View Full Code Here

            if(extensionRegistry == null) {
                return prototype.newBuilderForType().mergeFrom(
                        buf.array(),buf.arrayOffset(), buf.readableBytes()).build();
            } else {
                return prototype.newBuilderForType().mergeFrom(
                        buf.array(), buf.arrayOffset(), buf.readableBytes(), extensionRegistry).build();
            }
        } else {
            if (extensionRegistry == null) {
                return prototype.newBuilderForType().mergeFrom(
                        new ChannelBufferInputStream((ChannelBuffer) msg)).build();
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
      // Get handle from create response
      ChannelBuffer buf = (ChannelBuffer) e.getMessage();
      XDR rsp = new XDR(buf.array());
      if (rsp.getBytes().length == 0) {
        LOG.info("rsp length is zero, why?");
        return;
      }
      LOG.info("rsp length=" + rsp.getBytes().length);
View Full Code Here

        pieces.add(in.toString(USASCII));

        processLine(pieces, messageEvent.getChannel(), channelHandlerContext);
      } else if (status.state == SessionStatus.State.PROCESSING_MULTILINE) {
        ChannelBuffer slice = in.copy();
        byte[] payload = slice.array();
        in.skipBytes(in.readableBytes());
        continueSet(messageEvent.getChannel(), status, payload, channelHandlerContext);
      } else {
        throw new InvalidProtocolStateException("invalid protocol state");
      }
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
      // Get handle from create response
      ChannelBuffer buf = (ChannelBuffer) e.getMessage();
      XDR rsp = new XDR(buf.array());
      if (rsp.getBytes().length == 0) {
        LOG.info("rsp length is zero, why?");
        return;
      }
      LOG.info("rsp length=" + rsp.getBytes().length);
View Full Code Here

    writableRequest.readFields(inputStream);
    if (LOG.isDebugEnabled()) {
      LOG.debug("decode: Client " + writableRequest.getClientId() +
          ", requestId " + writableRequest.getRequestId() +
          ", " +  writableRequest.getType() + ", with size " +
          buffer.array().length + " took " +
          Times.getNanosSince(TIME, startDecodingNanoseconds) + " ns");
    }

    return writableRequest;
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.