java.io.ObjectInput#read ( )源码实例Demo

下面列出了java.io.ObjectInput#read ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: reladomo   文件: ReadableByteArrayInputStream.java
public void readFromStream(ObjectInput in, int size) throws IOException
{
    if (size > buf.length)
    {
        buf = new byte[size];
    }
    int read = 0;
    while (read < size)
    {
        int moreRead = in.read(buf, read, size - read);
        if (moreRead < 0) throw new IOException("Could not read "+size+" bytes from stream");
        read += moreRead;
    }
    this.count = size;
    this.pos = 0;
}
 
源代码2 项目: org.openntf.domino   文件: AbstractStruct.java
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
	int len = in.readInt();
	byte[] storage = new byte[len];
	in.read(storage);
	setByteBuffer(ByteBuffer.wrap(storage).order(ByteOrder.LITTLE_ENDIAN), 0);
}
 
源代码3 项目: ignite   文件: GridMarshallerAbstractTest.java
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    fully = in.readBoolean();

    arr = new byte[in.readInt()];

    if (fully)
        in.readFully(arr);
    else
        in.read(arr);
}
 
源代码4 项目: astor   文件: AbstractStepInterpolator.java
/** Read the base state of the instance.
 * This method does <strong>neither</strong> set the interpolated
 * time nor state. It is up to the derived class to reset it
 * properly calling the {@link #setInterpolatedTime} method later,
 * once all rest of the object state has been set up properly.
 * @param in stream where to read the state from
 * @return interpolated time to be set later by the caller
 * @exception IOException in case of read error
 * @exception ClassNotFoundException if an equation mapper class
 * cannot be found
 */
protected double readBaseExternal(final ObjectInput in)
  throws IOException, ClassNotFoundException {

  final int dimension = in.readInt();
  globalPreviousTime  = in.readDouble();
  globalCurrentTime   = in.readDouble();
  softPreviousTime    = in.readDouble();
  softCurrentTime     = in.readDouble();
  h                   = in.readDouble();
  forward             = in.readBoolean();
  primaryMapper       = (EquationsMapper) in.readObject();
  secondaryMappers    = new EquationsMapper[in.read()];
  for (int i = 0; i < secondaryMappers.length; ++i) {
      secondaryMappers[i] = (EquationsMapper) in.readObject();
  }
  dirtyState          = true;

  if (dimension < 0) {
      currentState = null;
  } else {
      currentState  = new double[dimension];
      for (int i = 0; i < currentState.length; ++i) {
          currentState[i] = in.readDouble();
      }
  }

  // we do NOT handle the interpolated time and state here
  interpolatedTime = Double.NaN;
  allocateInterpolatedArrays(dimension);

  finalized = true;

  return in.readDouble();

}
 
源代码5 项目: astor   文件: AbstractStepInterpolator.java
/** Read the base state of the instance.
 * This method does <strong>neither</strong> set the interpolated
 * time nor state. It is up to the derived class to reset it
 * properly calling the {@link #setInterpolatedTime} method later,
 * once all rest of the object state has been set up properly.
 * @param in stream where to read the state from
 * @return interpolated time to be set later by the caller
 * @exception IOException in case of read error
 * @exception ClassNotFoundException if an equation mapper class
 * cannot be found
 */
protected double readBaseExternal(final ObjectInput in)
  throws IOException, ClassNotFoundException {

  final int dimension = in.readInt();
  globalPreviousTime  = in.readDouble();
  globalCurrentTime   = in.readDouble();
  softPreviousTime    = in.readDouble();
  softCurrentTime     = in.readDouble();
  h                   = in.readDouble();
  forward             = in.readBoolean();
  primaryMapper       = (EquationsMapper) in.readObject();
  secondaryMappers    = new EquationsMapper[in.read()];
  for (int i = 0; i < secondaryMappers.length; ++i) {
      secondaryMappers[i] = (EquationsMapper) in.readObject();
  }
  dirtyState          = true;

  if (dimension < 0) {
      currentState = null;
  } else {
      currentState  = new double[dimension];
      for (int i = 0; i < currentState.length; ++i) {
          currentState[i] = in.readDouble();
      }
  }

  // we do NOT handle the interpolated time and state here
  interpolatedTime = Double.NaN;
  allocateInterpolatedArrays(dimension);

  finalized = true;

  return in.readDouble();

}
 
源代码6 项目: gemfirexd-oss   文件: StoredFieldHeader.java
/**
	read the field status

	@exception IOException Thrown by potential I/O errors while reading 
                              field header.
 */
public static final int readStatus(ObjectInput in) 
       throws IOException 
   {
	int status;

	if ((status = in.read()) >= 0)
           return status;
       else
		throw new EOFException();
}
 
源代码7 项目: astor   文件: AbstractStepInterpolator.java
/** Read the base state of the instance.
 * This method does <strong>neither</strong> set the interpolated
 * time nor state. It is up to the derived class to reset it
 * properly calling the {@link #setInterpolatedTime} method later,
 * once all rest of the object state has been set up properly.
 * @param in stream where to read the state from
 * @return interpolated time to be set later by the caller
 * @exception IOException in case of read error
 * @exception ClassNotFoundException if an equation mapper class
 * cannot be found
 */
protected double readBaseExternal(final ObjectInput in)
  throws IOException, ClassNotFoundException {

  final int dimension = in.readInt();
  globalPreviousTime  = in.readDouble();
  globalCurrentTime   = in.readDouble();
  softPreviousTime    = in.readDouble();
  softCurrentTime     = in.readDouble();
  h                   = in.readDouble();
  forward             = in.readBoolean();
  primaryMapper       = (EquationsMapper) in.readObject();
  secondaryMappers    = new EquationsMapper[in.read()];
  for (int i = 0; i < secondaryMappers.length; ++i) {
      secondaryMappers[i] = (EquationsMapper) in.readObject();
  }
  dirtyState          = true;

  if (dimension < 0) {
      currentState = null;
  } else {
      currentState  = new double[dimension];
      for (int i = 0; i < currentState.length; ++i) {
          currentState[i] = in.readDouble();
      }
  }

  // we do NOT handle the interpolated time and state here
  interpolatedTime = Double.NaN;
  allocateInterpolatedArrays(dimension);

  finalized = true;

  return in.readDouble();

}
 
源代码8 项目: astor   文件: AbstractStepInterpolator.java
/** Read the base state of the instance.
 * This method does <strong>neither</strong> set the interpolated
 * time nor state. It is up to the derived class to reset it
 * properly calling the {@link #setInterpolatedTime} method later,
 * once all rest of the object state has been set up properly.
 * @param in stream where to read the state from
 * @return interpolated time to be set later by the caller
 * @exception IOException in case of read error
 * @exception ClassNotFoundException if an equation mapper class
 * cannot be found
 */
protected double readBaseExternal(final ObjectInput in)
  throws IOException, ClassNotFoundException {

  final int dimension = in.readInt();
  globalPreviousTime  = in.readDouble();
  globalCurrentTime   = in.readDouble();
  softPreviousTime    = in.readDouble();
  softCurrentTime     = in.readDouble();
  h                   = in.readDouble();
  forward             = in.readBoolean();
  primaryMapper       = (EquationsMapper) in.readObject();
  secondaryMappers    = new EquationsMapper[in.read()];
  for (int i = 0; i < secondaryMappers.length; ++i) {
      secondaryMappers[i] = (EquationsMapper) in.readObject();
  }
  dirtyState          = true;

  if (dimension < 0) {
      currentState = null;
  } else {
      currentState  = new double[dimension];
      for (int i = 0; i < currentState.length; ++i) {
          currentState[i] = in.readDouble();
      }
  }

  // we do NOT handle the interpolated time and state here
  interpolatedTime = Double.NaN;
  allocateInterpolatedArrays(dimension);

  finalized = true;

  return in.readDouble();

}
 
源代码9 项目: org.openntf.domino   文件: NoteSet.java
@Override
public void readExternal(final ObjectInput arg0) throws IOException, ClassNotFoundException {
	int size = arg0.readInt();
	byte[] buffer = new byte[24];
	for (int i = 0; i < size; i++) {
		arg0.read(buffer);
		add(new NoteCoordinate(buffer));
	}
}
 
源代码10 项目: reladomo   文件: BigDecimalAttribute.java
public BigDecimal readFromStream(ObjectInput in) throws IOException
{
    int length = in.readInt();
    byte[] buf = new byte[length];
    int read = in.read(buf);
    while(read < length)
    {
        read += in.read(buf, read, length - read);
    }
    BigInteger unscaledValue = new BigInteger(buf);
    return  new BigDecimal(unscaledValue, in.readInt());
}
 
源代码11 项目: j2objc   文件: MeasureUnit.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    /* byte version = */ in.readByte(); // version
    type = in.readUTF();
    subType = in.readUTF();
    // allow for more data from future version
    int extra = in.readShort();
    if (extra > 0) {
        byte[] extraBytes = new byte[extra];
        in.read(extraBytes, 0, extra);
    }
}
 
源代码12 项目: triplea   文件: RemoteMethodCallResults.java
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
  final boolean hasReturnValue = in.read() == 1;
  if (hasReturnValue) {
    returnValue = in.readObject();
  } else {
    exception = (Throwable) in.readObject();
  }
}
 
源代码13 项目: org.openntf.domino   文件: NoteCoordinate.java
@Override
public void readExternal(final ObjectInput arg0) throws IOException, ClassNotFoundException {
	byte[] bytes = extreadbuffer_.get();
	arg0.read(bytes);
	this.db = Longs.fromBytes(bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
	this.x = Longs.fromBytes(bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);
	this.y = Longs.fromBytes(bytes[16], bytes[17], bytes[18], bytes[19], bytes[20], bytes[21], bytes[22], bytes[23]);
}
 
源代码14 项目: tomee   文件: EJBMetaDataImpl.java
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final byte version = in.readByte(); // future use

    homeClass = (Class) in.readObject();
    remoteClass = (Class) in.readObject();
    keyClass = (Class) in.readObject();
    ejbHomeProxy = (EJBHome) in.readObject();
    type = in.readByte();
    deploymentID = in.readUTF();
    deploymentCode = in.readShort();

    for (int i = in.readShort(); i > 0; i--) {
        businessClasses.add((Class) in.readObject());
    }
    if (businessClasses.size() > 0) {
        primaryKey = in.readObject();
    }
    if (version > 2) {
        mainInterface = (Class) in.readObject();
    }
    if (version > 1) {
        final byte typeIndex = in.readByte();
        interfaceType = InterfaceType.values()[typeIndex];
    }
    for (int i = in.readInt(); i > 0; i--) {
        asynchronousMethods.add((String) in.readObject());
    }

    final boolean hasProperties = in.readBoolean();
    if (hasProperties) {
        final int bufferLength = in.readInt();
        final byte[] buffer = new byte[bufferLength];
        in.read(buffer);
        final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
        properties.load(bais);
    }
}
 
源代码15 项目: riotapi   文件: BroadcastNotification.java
public void readExternal(ObjectInput in) throws IOException {
    byte[] buffer = new byte[in.readInt()];
    int i = 0;
    while (i < buffer.length - 1) {
        i += in.read(buffer, i, buffer.length - i);
    }
    String json = new String(buffer, "UTF-8");
    JsonElement elem = new JsonParser().parse(json);
    this.json = elem == null || elem.isJsonNull() ? null : elem.getAsJsonObject();
}
 
源代码16 项目: spliceengine   文件: SQLBinary.java
/**
 * Read the encoded length of the value from the on-disk format.
 * 
 * @see SQLBinary
*/
private static int readBinaryLength(ObjectInput in) throws IOException {

    int bl = in.read();
    if (bl == -1)
        throw new java.io.EOFException();
    
    byte li = (byte) bl;

    int len;
    if ((li & ((byte) 0x80)) != 0)
    {
        if (li == ((byte) 0xC0))
        {
            len = in.readInt();
         }
        else if (li == ((byte) 0xA0))
        {
            len = in.readUnsignedShort();
        }
        else
        {
            len = li & 0x1F;
        }
    }
    else
    {
        
        // old length in bits
        int v2 = in.read();
        int v3 = in.read();
        int v4 = in.read();
        if (v2 == -1 || v3 == -1 || v4 == -1)
            throw new java.io.EOFException();
        int lenInBits = (((bl & 0xff) << 24) | ((v2 & 0xff) << 16) | ((v3 & 0xff) << 8) | (v4 & 0xff));

        len = lenInBits / 8;
        if ((lenInBits % 8) != 0)
            len++;
     }
    return len;
}
 
源代码17 项目: gemfirexd-oss   文件: FakeByteArray.java
public void readExternal( ObjectInput in ) throws IOException
{
    _length = in.readInt();

    for ( int i = 0; i < _length; i++ ) { _fill = (byte) in.read(); }
}
 
源代码18 项目: gemfirexd-oss   文件: StoredFieldHeader.java
/**
	read the field data length

	@exception IOException Thrown by potential I/O errors while reading 
                              field header.
 */
public static final int readFieldDataLength(
   ObjectInput in, 
   int status, 
   int fieldDataSize)
		throws IOException 
   {
	
       if ((status & (FIELD_NULL | FIELD_FIXED)) == 0)
       {
           // usual case-not null, not fixed.  Length stored as compressed int.
           return(CompressedNumber.readInt(in));
       }
       else if ((status & FIELD_NULL) != 0)
       {
           // field is null or non-existent.
           return(0);
       }
       else
       {
           int fieldDataLength;

           // field data length is in a fixed size field, not compressed.

           if (fieldDataSize <= 2)
           {
               // read it in as short, because it was written out as short
               int ch1 = in.read();
               int ch2 = in.read();
               if ((ch1 | ch2) < 0)
                    throw new EOFException();

               fieldDataLength = ((ch1 << 8) + (ch2 << 0));
           }
           else
           {
               fieldDataLength = 
                   CompressedNumber.readInt(in);

               int diffLen = 
                   fieldDataSize - 
                   CompressedNumber.sizeInt(fieldDataLength);

               if (diffLen != 0)
                   in.skipBytes(diffLen);
           } 

           return(fieldDataLength);
       }
}
 
源代码19 项目: org.openntf.domino   文件: CDPATTERNTABLE.java
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
	int length = in.readInt();
	data_ = new byte[length];
	in.read(data_);
}
 
源代码20 项目: protect   文件: ConsensusMessage.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

	super.readExternal(in);

	number = in.readInt();
	epoch = in.readInt();
	paxosType = PaxosMessageType.getPaxosMessageByValue(in.readInt());

	int toRead = in.readInt();

	if (toRead != -1) {

		value = new byte[toRead];

		do {

			toRead -= in.read(value, value.length - toRead, toRead);

		} while (toRead > 0);

	}

	boolean asProof = in.readBoolean();
	if (asProof) {

		proof = in.readObject();
	}

}