Codota Logo
ByteArrayDataInputStream
Code IndexAdd Codota to your IDE (free)

How to use
ByteArrayDataInputStream
in
org.jgroups.util

Best Java code snippets using org.jgroups.util.ByteArrayDataInputStream (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: wildfly/wildfly

public static <T extends Streamable> T streamableFromByteBuffer(Class<? extends Streamable> cl,byte[] buffer,int offset,int length) throws Exception {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  T retval=(T)cl.newInstance();
  retval.readFrom(in);
  return retval;
}
origin: wildfly/wildfly

public ByteArrayDataInputStream position(int pos) {
  this.pos=checkBounds(pos); return this;
}
origin: wildfly/wildfly

public int available() throws IOException {
  return input.limit() - input.position();
}
origin: wildfly/wildfly

protected static Message readMessage(byte[] buf, int offset, int length) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  short ver=in.readShort();
  byte flags=in.readByte();
  // final boolean multicast=(flags & (byte)2) == (byte)2;
  Message msg=new Message(false); // don't create headers, readFrom() will do this
  msg.readFrom(in);
  return msg;
}
origin: wildfly/wildfly

public String readUTF() throws IOException {
  int utflen=readUnsignedShort();
  byte[] bytearr=new byte[utflen];
  char[] chararr=new char[utflen];
  int chararr_count=0;
  readFully(bytearr,0,utflen);
origin: wildfly/wildfly

/** Reads the message's contents from an input stream, but skips the buffer and instead returns the
 * position (offset) at which the buffer starts */
public int readFromSkipPayload(ByteArrayDataInputStream in) throws Exception {
  // 1. read the leading byte first
  byte leading=in.readByte();
  // 2. the flags
  flags=in.readShort();
  // 3. dest_addr
  if(Util.isFlagSet(leading, DEST_SET))
    dest_addr=Util.readAddress(in);
  // 4. src_addr
  if(Util.isFlagSet(leading, SRC_SET))
    src_addr=Util.readAddress(in);
  // 5. headers
  int len=in.readShort();
  headers=createHeaders(len);
  for(int i=0; i < len; i++) {
    short id=in.readShort();
    Header hdr=readHeader(in).setProtId(id);
    this.headers[i]=hdr;
  }
  // 6. buf
  if(!Util.isFlagSet(leading, BUF_SET))
    return -1;
  length=in.readInt();
  return in.position();
}
origin: wildfly/wildfly

@Override public void receive(Address sender, byte[] buf, int offset, int length) {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  GossipType type;
  try {
    type=GossipType.values()[in.readByte()];
    in.position(Global.BYTE_SIZE);
          ByteArrayDataInputStream input=new ByteArrayDataInputStream(buf, offset, length);
          GossipData data=new GossipData();
          data.readFrom(input);
origin: wildfly/wildfly

public long readLong() throws IOException {
  return (((long)read() << 56) +
   ((long)(read() & 0xff) << 48) +
   ((long)(read() & 0xff) << 40) +
   ((long)(read() & 0xff) << 32) +
   ((long)(read() & 0xff) << 24) +
   ((read() & 0xff) << 16) +
   ((read() & 0xff) <<  8) +
   ((read() & 0xff) <<  0));
}
origin: wildfly/wildfly

public double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}
origin: wildfly/wildfly

public float readFloat() throws IOException {
  return Float.intBitsToFloat(readInt());
}
origin: wildfly/wildfly

public void readFully(byte[] b) throws IOException {
  readFully(b, 0, b.length);
}
origin: org.jboss.eap/wildfly-client-all

/** Reads the message's contents from an input stream, but skips the buffer and instead returns the
 * position (offset) at which the buffer starts */
public int readFromSkipPayload(ByteArrayDataInputStream in) throws Exception {
  // 1. read the leading byte first
  byte leading=in.readByte();
  // 2. the flags
  flags=in.readShort();
  // 3. dest_addr
  if(Util.isFlagSet(leading, DEST_SET))
    dest_addr=Util.readAddress(in);
  // 4. src_addr
  if(Util.isFlagSet(leading, SRC_SET))
    src_addr=Util.readAddress(in);
  // 5. headers
  int len=in.readShort();
  headers=createHeaders(len);
  for(int i=0; i < len; i++) {
    short id=in.readShort();
    Header hdr=readHeader(in).setProtId(id);
    this.headers[i]=hdr;
  }
  // 6. buf
  if(!Util.isFlagSet(leading, BUF_SET))
    return -1;
  length=in.readInt();
  return in.position();
}
origin: org.jboss.eap/wildfly-client-all

protected static Message readMessage(byte[] buf, int offset, int length) throws Exception {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  short ver=in.readShort();
  byte flags=in.readByte();
  // final boolean multicast=(flags & (byte)2) == (byte)2;
  Message msg=new Message(false); // don't create headers, readFrom() will do this
  msg.readFrom(in);
  return msg;
}
origin: org.jboss.eap/wildfly-client-all

@Override public void receive(Address sender, byte[] buf, int offset, int length) {
  ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, offset, length);
  GossipType type;
  try {
    type=GossipType.values()[in.readByte()];
    in.position(Global.BYTE_SIZE);
          ByteArrayDataInputStream input=new ByteArrayDataInputStream(buf, offset, length);
          GossipData data=new GossipData();
          data.readFrom(input);
origin: wildfly/wildfly

public int read() throws IOException {
  return input.read();
}
origin: org.jboss.eap/wildfly-client-all

public String readUTF() throws IOException {
  int utflen=readUnsignedShort();
  byte[] bytearr=new byte[utflen];
  char[] chararr=new char[utflen];
  int chararr_count=0;
  readFully(bytearr,0,utflen);
origin: org.jboss.eap/wildfly-client-all

public double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}
origin: org.jboss.eap/wildfly-client-all

public float readFloat() throws IOException {
  return Float.intBitsToFloat(readInt());
}
origin: org.jboss.eap/wildfly-client-all

public void readFully(byte[] b) throws IOException {
  readFully(b, 0, b.length);
}
origin: wildfly/wildfly

public static <T extends Streamable> T streamableFromByteBuffer(Supplier<T> factory, byte[] buffer, int offset, int length) throws Exception {
  if(buffer == null) return null;
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  T retval=factory.get();
  retval.readFrom(in);
  return retval;
}
org.jgroups.utilByteArrayDataInputStream

Javadoc

Implements java.io.DataInput over a byte[] buffer. This class is not thread safe.

Most used methods

  • <init>
  • checkBounds
  • limit
  • position
  • read
  • readByte
  • readFully
  • readInt
  • readLong
  • readShort
  • readUnsignedShort
  • skipBytes
  • readUnsignedShort,
  • skipBytes

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • ImageIO (javax.imageio)
  • JButton (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now