Пример #1
0
 public String readString() throws IOException {
   final ObjectInput in = this.in;
   final int cn = in.readInt();
   if (cn >= 0) {
     if (cn == 0) {
       return "";
     } else if (cn <= 64) {
       for (int ci = 0; ci < cn; ci++) {
         this.ca[ci] = in.readChar();
       }
       return new String(this.ca, 0, cn);
     } else if (cn <= CB_LENGTH) {
       final int bn = cn << 1;
       in.readFully(this.ba, 0, bn);
       if (!this.bb.hasArray()) {
         this.bb.clear();
         this.bb.put(this.ba, 0, bn);
       }
       this.cb.clear();
       this.cb.get(this.ca, 0, cn);
       return new String(this.ca, 0, cn);
     } else if (cn <= CA_LENGTH) {
       return readString(cn, this.ca, in);
     } else {
       return readString(cn, new char[cn], in);
     }
   } else if (cn != Integer.MIN_VALUE) {
     in.readFully(this.ba, 0, -cn);
     return new String(this.ba, 0, 0, -cn);
   } else {
     return null;
   }
 }
 @Override
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   int v1 = in.readInt();
   int v2 = in.readInt();
   int v3 = in.readInt();
   bytes1 = new byte[v2];
   in.readFully(bytes1);
   bytes2 = new byte[v3];
   in.readFully(bytes2);
   int v4 = 0;
 }
 @Override
 protected Object readObject(ObjectInput in) throws IOException {
   int length = in.readInt();
   byte[] bytes = new byte[length];
   in.readFully(bytes);
   return new BigInteger(bytes);
 }
 @Override
 protected Object readObject(ObjectInput in) throws IOException, ClassNotFoundException {
   int length = in.readInt();
   byte[] bytes = new byte[length];
   in.readFully(bytes);
   return new BinaryType(bytes);
 }
Пример #5
0
  /** {@inheritDoc} */
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    byte[] data = new byte[in.readInt()];
    in.readFully(data);
    path = new String(data, Constants.DEFAULT_ENCODING);
  }
Пример #6
0
 @Override
 public ByteBufferImpl readObject(ObjectInput input) throws IOException, ClassNotFoundException {
   int length = UnsignedNumeric.readUnsignedInt(input);
   byte[] data = new byte[length];
   input.readFully(data, 0, length);
   return new ByteBufferImpl(data, 0, length);
 }
Пример #7
0
 @Override
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   this.baseOffset = BYTE_ARRAY_OFFSET;
   this.sizeInBytes = in.readInt();
   this.numFields = in.readInt();
   this.bitSetWidthInBytes = calculateBitSetWidthInBytes(numFields);
   this.baseObject = new byte[sizeInBytes];
   in.readFully((byte[]) baseObject);
 }
Пример #8
0
  @Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    byte[] serReq = new byte[in.readInt()];
    in.readFully(serReq);

    request = TOMMessage.bytesToMessage(serReq);
    request.serializedMessage = serReq;

    boolean signed = in.readBoolean();

    if (signed) {

      byte[] serReqSign = new byte[in.readInt()];
      in.readFully(serReqSign);
      request.serializedMessageSignature = serReqSign;
    }
  }
Пример #9
0
 protected void readPackager(ObjectInput in) throws IOException, ClassNotFoundException {
   byte[] b = new byte[in.readShort()];
   in.readFully(b);
   try {
     Class mypClass = Class.forName(new String(b));
     ISOPackager myp = (ISOPackager) mypClass.newInstance();
     setPackager(myp);
   } catch (Exception e) {
     setPackager(null);
   }
 }
Пример #10
0
  @Override
  public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {

    id = in.readUTF();

    version = in.readInt();

    block = in.readLong();

    off = 0; // Note: offset always zero when de-serialized.

    len = in.readInt();

    b = new byte[len];

    in.readFully(b);
  }
Пример #11
0
  /**
   * Reads an object from the given object input. The object had to be saved by the {@link
   * NbObjectOutputStream#writeSafely} method.
   *
   * @param oi object input
   * @return the read object
   * @exception IOException if IO error occured
   * @exception SafeException if the operation failed but the stream is ok for further reading
   */
  public static Object readSafely(ObjectInput oi) throws IOException {
    int size = oi.readInt();
    byte[] byteArray = new byte[size];
    oi.readFully(byteArray, 0, size);

    try {
      ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
      NbObjectInputStream ois = new NbObjectInputStream(bis);
      Object obj = ois.readObject();
      bis.close();
      return obj;
    } catch (Exception exc) {
      // encapsulate all exceptions into safe exception
      throw new SafeException(exc);
    } catch (LinkageError le) {
      throw new SafeException(new InvocationTargetException(le));
    }
  }
Пример #12
0
  /**
   * Note the use of rawData: we reuse the array if the incoming array is the same length or smaller
   * than the array length.
   *
   * @see java.io.Externalizable#readExternal
   */
  public void readExternal(ObjectInput in) throws IOException {
    // clear the previous value to ensure that the
    // rawData value will be used
    value = null;

    rawScale = in.readUnsignedByte();
    int size = in.readUnsignedByte();

    /*
    ** Allocate a new array if the data to read
    ** is larger than the existing array, or if
    ** we don't have an array yet.

          Need to use readFully below and NOT just read because read does not
          guarantee getting size bytes back, whereas readFully does (unless EOF).
          */
    if ((rawData == null) || size != rawData.length) {
      rawData = new byte[size];
    }
    in.readFully(rawData);
  }
Пример #13
0
  @Override
  public Document readObject(ObjectInput input) throws IOException {
    if (input.available() < 5) {
      // There's not enough data in the input, so return null
      return null;
    }
    // Read the type byte ...
    int type = input.readByte();
    assert type == 1;
    // Read the number of bytes ...
    int length = input.readInt();
    if (length == 0) {
      return new BasicDocument();
    }

    // Otherwise there's data ...
    byte[] bytes = new byte[length];
    // Read the BSON bytes...
    input.readFully(bytes);
    // Convert to a document ...
    return Bson.read(new ByteArrayInputStream(bytes));
  }
Пример #14
0
  @Override
  public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
    if (oi.readByte() != serialVersion) throw new IOException("Serial version mismatch");

    int nameLength =
        (short) oi.readByte() & 0xFF; // Remove possible negative sign extension from the cast
    byte[] name = new byte[nameLength];

    oi.readFully(name, 0, nameLength);

    if (nameLength == 1 && name[0] == 0) this.name = null;
    else this.name = new String(name);

    size = oi.readLong();

    int childCount = (short) oi.readByte() & 0xFF;
    for (int i = 0; i < childCount; i++) {
      FSTree child = new FSTree(null, 0L, this);
      child.readExternal(oi);
      children.put(child.getName(), child);
    }
  }
Пример #15
0
 private String readString(final int cn, final char[] ca, final ObjectInput in)
     throws IOException {
   int cr = 0;
   int position = 0;
   final int bToComplete;
   while (true) {
     position += in.read(this.ba, position, BA_LENGTH - position);
     if (position >= BB_PART) {
       final int icount = (position >> 1);
       final int bcount = (icount << 1);
       if (!this.bb.hasArray()) {
         this.bb.clear();
         this.bb.put(this.ba, 0, bcount);
       }
       this.cb.clear();
       this.cb.get(ca, cr, icount);
       cr += icount;
       if (position - bcount != 0) {
         this.ca[cr++] = (char) (((this.ba[bcount] & 0xff) << 8) | ((in.read() & 0xff)));
       }
       position = 0;
       if (cn - cr <= CB_LENGTH) {
         bToComplete = (cn - cr) << 1;
         break;
       }
     }
   }
   if (bToComplete > 0) {
     in.readFully(this.ba, position, bToComplete - position);
     if (!this.bb.hasArray()) {
       this.bb.clear();
       this.bb.put(this.ba, 0, bToComplete);
     }
     this.cb.clear();
     this.cb.get(ca, cr, bToComplete >> 1);
   }
   return new String(ca, 0, cn);
 }
Пример #16
0
 @Override
 public SessionID readObject(ObjectInput input) throws IOException {
   byte[] encoded = new byte[input.readInt()];
   input.readFully(encoded);
   return SessionID.createSessionID(encoded);
 }
Пример #17
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   id = in.readLong();
   content = new byte[in.readInt()];
   in.readFully(content);
 }
Пример #18
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   offset = BYTE_ARRAY_OFFSET;
   numBytes = in.readInt();
   base = new byte[numBytes];
   in.readFully((byte[]) base);
 }
Пример #19
0
 /**
  * @see java.io.Externalizable#readExternal
  * @param in ObjectInput
  * @throws IOException
  */
 @Override
 public void readExternal(ObjectInput in) throws IOException {
   int length = in.readInt();
   message = new byte[length];
   in.readFully(message);
 }
Пример #20
0
 protected void readHeader(ObjectInput in) throws IOException, ClassNotFoundException {
   byte[] b = new byte[in.readShort()];
   in.readFully(b);
   setHeader(b);
 }