Java Code Examples for java.io.ObjectInput#readObject()

The following examples show how to use java.io.ObjectInput#readObject() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * 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);
}
 
Example 2
/**
 * 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);

}
 
Example 3
/**
 * 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);
}
 
Example 4
@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();
}
 
Example 5
/**
 * 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);

}
 
Example 6
/**
 * 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);
}
 
Example 7
@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();

}
 
Example 8
/**
 * @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");
   }
 
Example 9
Source Project: kogito-runtimes   File: ObjectFieldImpl.java    License: Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 10
Source Project: kogito-runtimes   File: AsyncSendNode.java    License: Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 11
/**
 * 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();
}
 
Example 12
@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();
}
 
Example 13
Source Project: gemfirexd-oss   File: BasicProviderInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 14
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();
}
 
Example 15
Source Project: gemfirexd-oss   File: PullPushAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    identifier=(Serializable)in.readObject();
}
 
Example 16
Source Project: ignite   File: PlatformSqlQueryTask.java    License: Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    arg = (String)in.readObject();
}
 
Example 17
private void readRangeResolverData(ObjectInput in)
    throws ClassNotFoundException, IOException {
  this.rangeValuesHolderList = (ArrayList)in.readObject();
}
 
Example 18
public void readExternal(ObjectInput in) throws IOException,
                                        ClassNotFoundException {
    super.readExternal( in );
    this.sinks = (LeftTupleSinkNodeList) in.readObject();
}
 
Example 19
Source Project: kogito-runtimes   File: From.java    License: Apache License 2.0 4 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    dataProvider    = ( DataProvider ) in.readObject();
    resultPattern   = ( Pattern ) in.readObject();
    resultClass     = ( Class<?> ) in.readObject();
}
 
Example 20
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) //
                    );

        }
                
    }