Tabnine Logo
ByteArrayDataInputStream
Code IndexAdd Tabnine 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)

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

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • startActivity (Activity)
  • getContentResolver (Context)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Socket (java.net)
    Provides a client-side TCP socket.
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JLabel (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now