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

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

源代码1 项目: astor   文件: OHLCItemTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0);
    OHLCItem item2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(item1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        item2 = (OHLCItem) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(item1, item2);
}
 
源代码2 项目: astor   文件: OHLCSeriesTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    OHLCSeries s1 = new OHLCSeries("s1");
    s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0);
    OHLCSeries s2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(s1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        s2 = (OHLCSeries) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(s1, s2);

}
 
源代码3 项目: astor   文件: XYCoordinateTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    XYCoordinate v1 = new XYCoordinate(1.0, 2.0);
    XYCoordinate v2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(v1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        v2 = (XYCoordinate) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(v1, v2);
}
 
源代码4 项目: spliceengine   文件: ScanOperation.java
@Override
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
    super.readExternal(in);
    oneRowScan=in.readBoolean();
    lockMode=in.readInt();
    isolationLevel=in.readInt();
    scanInformation=(ScanInformation<ExecRow>)in.readObject();
    tableVersion=in.readUTF();
    rowIdKey = in.readBoolean();
    pin = in.readBoolean();
    delimited = in.readBoolean()?in.readUTF():null;
    escaped = in.readBoolean()?in.readUTF():null;
    lines = in.readBoolean()?in.readUTF():null;
    storedAs = in.readBoolean()?in.readUTF():null;
    location = in.readBoolean()?in.readUTF():null;
    partitionRefItem = in.readInt();
    splits = in.readInt();
}
 
源代码5 项目: astor   文件: PieLabelRecordTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"),
            3.0, 4.0, 5.0);
    PieLabelRecord p2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(p1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        p2 = (PieLabelRecord) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    boolean b = p1.equals(p2);
    assertTrue(b);

}
 
源代码6 项目: astor   文件: EmptyBlockTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    EmptyBlock b1 = new EmptyBlock(1.0, 2.0);
    EmptyBlock b2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(b1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        b2 = (EmptyBlock) in.readObject();
        in.close();
    }
    catch (Exception e) {
        fail(e.toString());
    }
    assertEquals(b1, b2);
}
 
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
		super.readExternal(in);
		getProbeValsFuncName = SerializationUtils.readNullableString(in);
		sortRequired = in.readInt();
		inlistPosition = in.readInt();
		if (in.readBoolean()) {
			probeValues = new DataValueDescriptor[in.readInt()];
			for (int i = 0; i < probeValues.length; i++) {
				probeValues[i] = (DataValueDescriptor) in.readObject();
			}
		}
              probeValue = (DataValueDescriptor)in.readObject();
		inlistTypeArrayItem = in.readInt();

}
 
源代码8 项目: spliceengine   文件: IndexDescriptorImpl.java
/**
 * @see java.io.Externalizable#readExternal
 *
 * @exception IOException	Thrown on read error
 */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
       FormatableHashtable fh = (FormatableHashtable) in.readObject();
       isUnique = fh.getBoolean("isUnique");
       int bcpLength = fh.getInt("keyLength");
       baseColumnPositions = new int[bcpLength];
       isAscending = new boolean[bcpLength];
       for (int i = 0; i < bcpLength; i++) {
           baseColumnPositions[i] = fh.getInt("bcp" + i);
           isAscending[i] = fh.getBoolean("isAsc" + i);
       }
       numberOfOrderedColumns = fh.getInt("orderedColumns");
       indexType = (String) fh.get("indexType");
       //isUniqueWithDuplicateNulls attribute won't be present if the index
       //was created in older versions
       isUniqueWithDuplicateNulls = fh.containsKey("isUniqueWithDuplicateNulls") && fh.getBoolean("isUniqueWithDuplicateNulls");
	excludeNulls = fh.containsKey("excludeNulls") && fh.getBoolean("excludeNulls");
	excludeDefaults = fh.containsKey("excludeDefaults") && fh.getBoolean("excludeDefaults");
   }
 
源代码9 项目: kogito-runtimes   文件: ObjectFieldImpl.java
public void readExternal(ObjectInput in) throws IOException,
                                        ClassNotFoundException {
    isEnum = in.readBoolean();
    enumName = (String) in.readObject();
    fieldName = (String) in.readObject();
    if ( !isEnum || enumName == null || fieldName == null ) {
        value = (Serializable) in.readObject();
    } else {
        resolveEnumValue( (DroolsObjectInputStream) in );
    }
    setBooleans();
}
 
源代码10 项目: kogito-runtimes   文件: AsyncSendNode.java
public void readExternal(ObjectInput in) throws IOException,
                                        ClassNotFoundException {
    super.readExternal( in );
    dataProvider = (DataProvider) in.readObject();
    alphaConstraints = (AlphaNodeFieldConstraint[]) in.readObject();
    betaConstraints = (BetaConstraints) in.readObject();
    tupleMemoryEnabled = in.readBoolean();
    send = (AsyncSend) in.readObject();
}
 
源代码11 项目: openjdk-8-source   文件: BitArray.java
/**
 * Read the whole tree from a file (serialized)
 */
public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException {
    _bitSize = in.readInt();
    _intSize = (_bitSize >>> 5) + 1;
    _mask    = in.readInt();
    _bits    = (int[])in.readObject();
}
 
源代码12 项目: spliceengine   文件: GenericQualifier.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	columnId = in.readInt();
	storagePosition = in.readInt();
	operator = in.readInt();
	orderedNulls = in.readBoolean();
	unknownRV = in.readBoolean();
	negateCompareResult = in.readBoolean();
	variantType = in.readInt();
	orderableCache = (DataValueDescriptor) in.readObject();
}
 
源代码13 项目: gemfirexd-oss   文件: BasicProviderInfo.java
/**
 * Read this object from a stream of stored objects.
 *
 * @param in read this.
 *
 * @exception IOException					thrown on error
 * @exception ClassNotFoundException		thrown on error
 */
public void readExternal( ObjectInput in )
	 throws IOException, ClassNotFoundException
{

	FormatableHashtable fh = (FormatableHashtable)in.readObject();
	uuid = (UUID)fh.get("uuid");
	dFinder = (DependableFinder)fh.get("dFinder");
	providerName = (String) fh.get("providerName");
}
 
源代码14 项目: kogito-runtimes   文件: HashTableIterator.java
public void readExternal(ObjectInput in) throws IOException,
                                        ClassNotFoundException {
    hashTable = (AbstractHashTable) in.readObject();
    table = (Entry[]) in.readObject();
    row = in.readInt();
    length = in.readInt();
    entry = (Entry) in.readObject();
}
 
源代码15 项目: gemfirexd-oss   文件: PullPushAdapter.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    identifier=(Serializable)in.readObject();
}
 
源代码16 项目: ignite   文件: PlatformSqlQueryTask.java
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    arg = (String)in.readObject();
}
 
源代码17 项目: gemfirexd-oss   文件: SingleHopInformation.java
private void readRangeResolverData(ObjectInput in)
    throws ClassNotFoundException, IOException {
  this.rangeValuesHolderList = (ArrayList)in.readObject();
}
 
public void readExternal(ObjectInput in) throws IOException,
                                        ClassNotFoundException {
    super.readExternal( in );
    this.sinks = (LeftTupleSinkNodeList) in.readObject();
}
 
源代码19 项目: kogito-runtimes   文件: From.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    dataProvider    = ( DataProvider ) in.readObject();
    resultPattern   = ( Pattern ) in.readObject();
    resultClass     = ( Class<?> ) in.readObject();
}
 
源代码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) //
                    );

        }
                
    }