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

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

源代码1 项目: gemfirexd-oss   文件: ReplicationData.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int num;
    type=in.readInt();
    if((num=in.readInt()) > 0) {
        data=new byte[num];
        in.readFully(data, 0, num);
    }
    if(in.readBoolean()) {
        transaction=new Xid();
        transaction.readExternal(in);
    }
    use_locks=in.readBoolean();
    if(use_locks) {
        if((num=in.readInt()) > 0) {
            lock_info=new byte[num];
            in.readFully(lock_info, 0, num);
        }
        lock_acquisition_timeout=in.readLong();
        lock_lease_timeout=in.readLong();        
    }
}
 
源代码2 项目: gemfirexd-oss   文件: JGroupMember.java
/**
   * For Externalizable
   * 
   * @see java.io.Externalizable
   */
  public void readExternal(ObjectInput in) throws IOException,
          ClassNotFoundException {
//    ipAddr = new IpAddress();
//    ipAddr.readExternal(in);
    // do it the way we like
    int len = in.readInt(); // IPv6 compatible
    byte addr[] = new byte[len];
    in.readFully(addr);
    InetAddress ia = InetAddress.getByAddress(addr);
    int port = in.readInt();
    byte flags = in.readByte();
    ipAddr = new IpAddress(ia, port);
    ipAddr.setFlags(flags);
    ipAddr.readVersion(flags, in);
    len = in.readInt();
    if (len != 0) {
      byte bytes[] = new byte[len];
      in.readFully(bytes);
      GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
    }
  }
 
源代码3 项目: spliceengine   文件: ByteSlice.java
@Override
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
    offset = in.readInt();
    length = in.readInt();
    buffer = new byte[length];
    if(length > 0) {
        in.readFully(buffer);
    }
    hashSet = false;
    if (buffer.length > 0) {
        assertLengthCorrect(buffer, offset, length);
    } else {
        // If there's nothing in the buffer, reset offset and length
        // to prevent ArrayIndexOutOfBoundsException
        offset = length = 0;
    }
}
 
源代码4 项目: gemfirexd-oss   文件: ReplicationData.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int num;
    type=in.readInt();
    if((num=in.readInt()) > 0) {
        data=new byte[num];
        in.readFully(data, 0, num);
    }
    if(in.readBoolean()) {
        transaction=new Xid();
        transaction.readExternal(in);
    }
    use_locks=in.readBoolean();
    if(use_locks) {
        if((num=in.readInt()) > 0) {
            lock_info=new byte[num];
            in.readFully(lock_info, 0, num);
        }
        lock_acquisition_timeout=in.readLong();
        lock_lease_timeout=in.readLong();        
    }
}
 
源代码5 项目: gemfirexd-oss   文件: SQLBinary.java
/** 
 * delegated to bit 
 *
 * @exception IOException			io exception
 * @exception ClassNotFoundException	class not found
*/
public final void readExternal(ObjectInput in) throws IOException
{
	// need to clear stream first, in case this object is reused, and
	// stream is set by previous use.  Track 3794.
	//stream = null;
	//streamValueLength = -1;
       _blobValue = null;


	int len = SQLBinary.readBinaryLength(in);

	if (len != 0)
	{
		dataValue = new byte[len];
		in.readFully(dataValue);
	}
	else
	{
		readFromStream((InputStream) in);
	}
}
 
源代码6 项目: protect   文件: ForwardedMessage.java
@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;

	}
}
 
源代码7 项目: spliceengine   文件: DistributedCheckTableJob.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    txn = SIDriver.driver().getOperationFactory().readTxn(in);
    ah = (ActivationHolder) in.readObject();
    schemaName = in.readUTF();
    tableName = in.readUTF();
    int iSize = in.readInt();
    tentativeIndexList = new ArrayList<>(iSize);
    for (int i = 0; i< iSize; i++) {
        byte[] message = new byte[in.readInt()];
        in.readFully(message);
        tentativeIndexList.add(DDLMessage.TentativeIndex.parseFrom(message));
    }
    fix = in.readBoolean();
    jobGroup = in.readUTF();
}
 
源代码8 项目: gemfirexd-oss   文件: JGroupMember.java
/**
   * For Externalizable
   * 
   * @see java.io.Externalizable
   */
  public void readExternal(ObjectInput in) throws IOException,
          ClassNotFoundException {
//    ipAddr = new IpAddress();
//    ipAddr.readExternal(in);
    // do it the way we like
    int len = in.readInt(); // IPv6 compatible
    byte addr[] = new byte[len];
    in.readFully(addr);
    InetAddress ia = InetAddress.getByAddress(addr);
    int port = in.readInt();
    byte flags = in.readByte();
    ipAddr = new IpAddress(ia, port);
    ipAddr.setFlags(flags);
    ipAddr.readVersion(flags, in);
    len = in.readInt();
    if (len != 0) {
      byte bytes[] = new byte[len];
      in.readFully(bytes);
      GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
    }
  }
 
源代码9 项目: spliceengine   文件: SimpleTxnOperationFactory.java
@Override
public TxnView readTxn(ObjectInput oi) throws IOException{
    int size=oi.readInt();
    byte[] txnData=new byte[size];
    oi.readFully(txnData);

    return decode(txnData,0,txnData.length);
}
 
源代码10 项目: tomcatsrc   文件: ByteMessage.java
/**
 * @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);
}
 
源代码11 项目: spliceengine   文件: SpliceSequence.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
    super.readExternal(in);
    int size=in.readInt();
    sysColumnsRow=new byte[size];
    in.readFully(sysColumnsRow);
}
 
源代码12 项目: jdk1.8-source-analysis   文件: MimeType.java
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
源代码13 项目: gemfirexd-oss   文件: ByteArray.java
/**
 * Read this object from a stream of stored objects.
 *
 * @param in read this.
 *
 * @exception IOException					thrown on error
 */
public void readExternal( ObjectInput in ) throws IOException
{
	int len = length = in.readInt();
	offset = 0; 
	array = new byte[len];

	in.readFully(array, 0, len);
}
 
源代码14 项目: reladomo   文件: LocalTx.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    int len = in.readByte();
    this.globalId = new byte[len];
    in.readFully(this.globalId);
    len = in.readByte();
    this.branchId = new byte[len];
    in.readFully(this.branchId);
}
 
源代码15 项目: openjdk-jdk8u   文件: MimeType.java
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
源代码16 项目: hottub   文件: MimeType.java
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
源代码17 项目: indexr   文件: UnsafeRow.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.baseOffset = Platform.BYTE_ARRAY_OFFSET;
    this.sizeInBytes = in.readInt();
    this.numFields = in.readInt();
    this.baseObject = new byte[sizeInBytes];
    in.readFully((byte[]) baseObject);
}
 
源代码18 项目: database   文件: AtomicBlockAppendProc.java
@Override
public void readExternal(final ObjectInput in) throws IOException,
        ClassNotFoundException {

    id = in.readUTF();

    version = in.readInt();

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

    len = in.readInt();

    b = new byte[len];

    in.readFully(b);

}
 
源代码19 项目: gemfirexd-oss   文件: InternalDistributedMember.java
/**
 * For Externalizable
 *
 * @see Externalizable
 */
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
  // do it the way we like
  int len = in.readInt(); // IPv6 compatible
  byte addr[] = new byte[len];
  in.readFully(addr);
  InetAddress inetAddr = InetAddress.getByAddress(addr);
  int port = in.readInt();
  
  this.hostName = DataSerializer.readString(in);

  int flags = in.readUnsignedByte();
  boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
  boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
  this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
  
  this.dcPort = in.readInt();
  this.vmPid = in.readInt();
  this.vmKind = in.readInt();
  this.vmViewId = in.readInt();
  this.groups = DataSerializer.readStringArray(in);

  this.name = DataSerializer.readString(in);
  this.uniqueTag = DataSerializer.readString(in);
  String durableId = DataSerializer.readString(in);
  int durableTimeout = DataSerializer.readInteger(in).intValue();
  this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);

  readVersion(flags, in);

  ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
      new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
  ((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);

  Assert.assertTrue(this.vmKind > 0);
  // [sumedh] loner VMs will have port as zero if no GFE client is connected
  // e.g. with GFXD clients
  Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
      || getPort() > 0);
}
 
源代码20 项目: database   文件: LocalPartitionMetadata.java
public void readExternal(final ObjectInput in) throws IOException,
            ClassNotFoundException {

        final short version = ShortPacker.unpackShort(in);

        switch (version) {
        case VERSION0:
        case VERSION1:
        case VERSION2:
            break;
        default:
            throw new IOException("Unknown version: " + version);
        }

        if (version < VERSION2) {
            partitionId = (int) LongPacker.unpackLong(in);
        } else {
            partitionId = in.readInt();
        }

        sourcePartitionId = in.readInt(); // MAY be -1.
        
        final int nresources = ShortPacker.unpackShort(in);
        
        final int leftLen = (int) LongPacker.unpackLong(in);

        final int rightLen = (int) LongPacker.unpackLong(in);

        leftSeparatorKey = new byte[leftLen];

        in.readFully(leftSeparatorKey);

        if (rightLen != 0) {

            rightSeparatorKey = new byte[rightLen];

            in.readFully(rightSeparatorKey);

        } else {

            rightSeparatorKey = null;

        }

        cause = (IndexPartitionCause)in.readObject();
        
        if (version < VERSION2) {
            /* history = */in.readUTF();
        }
        
        resources = nresources>0 ? new IResourceMetadata[nresources] : null;

        for (int j = 0; j < nresources; j++) {

            final boolean isIndexSegment = in.readBoolean();
            
            final String filename = in.readUTF();

//            long nbytes = LongPacker.unpackLong(in);

            final UUID uuid = new UUID(in.readLong()/*MSB*/,in.readLong()/*LSB*/);

            final long createTime = in.readLong();
            
            long commitTime = 0L;
            if (version >= VERSION1 && !isIndexSegment) {

                commitTime = in.readLong();
                
            }
            
            resources[j] = (isIndexSegment //
                    ? new SegmentMetadata(filename, /*nbytes,*/ uuid, createTime) //
                    : new JournalMetadata(filename, /*nbytes,*/ uuid, createTime, commitTime) //
                    );

        }
                
    }