java.io.ObjectInput Java Examples
The following examples show how to use
java.io.ObjectInput.
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
Source File: THash.java From blip with GNU Lesser General Public License v3.0 | 6 votes |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // LOAD FACTOR float old_factor = _loadFactor; _loadFactor = Math.abs(in.readFloat()); // AUTO COMPACTION LOAD FACTOR _autoCompactionFactor = in.readFloat(); // If we change the laod factor from the default, re-setup if (old_factor != _loadFactor) { setUp( saturatedCast( (long) Math.ceil( DEFAULT_CAPACITY / (double) _loadFactor))); } }
Example #2
Source File: FirstOrderIntegratorWithJacobians.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { interpolator = (StepInterpolator) in.readObject(); final int n = in.readInt(); final int k = in.readInt(); y = new double[n]; dydy0 = new double[n][n]; dydp = new double[n][k]; yDot = new double[n]; dydy0Dot = new double[n][n]; dydpDot = new double[n][k]; readArray(in, y); readArray(in, dydy0); readArray(in, dydp); readArray(in, yDot); readArray(in, dydy0Dot); readArray(in, dydpDot); }
Example #3
Source File: ExternObjTrees.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { z = in.readBoolean(); b = in.readByte(); c = in.readChar(); s = in.readShort(); i = in.readInt(); f = in.readFloat(); j = in.readLong(); d = in.readDouble(); str = (String) in.readObject(); parent = in.readObject(); left = in.readObject(); right = in.readObject(); }
Example #4
Source File: UnicastServerRef.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Sets a filter for invocation arguments, if a filter has been set. * Called by dispatch before the arguments are read. */ protected void unmarshalCustomCallData(ObjectInput in) throws IOException, ClassNotFoundException { if (filter != null && in instanceof ObjectInputStream) { // Set the filter on the stream ObjectInputStream ois = (ObjectInputStream) in; AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { ObjectInputFilter.Config.setObjectInputFilter(ois, filter); return null; } }); } }
Example #5
Source File: SimpleHistogramBinTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0, false, true); b1.setItemCount(123); SimpleHistogramBin 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 = (SimpleHistogramBin) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(b1, b2); }
Example #6
Source File: TCustomHashMap.java From blip with GNU Lesser General Public License v3.0 | 6 votes |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION byte version = in.readByte(); // NOTE: super was not written in version 0 if (version != 0) { super.readExternal(in); } // NUMBER OF ENTRIES int size = in.readInt(); setUp(size); // ENTRIES while (size-- > 0) { // noinspection unchecked K key = (K) in.readObject(); // noinspection unchecked V val = (V) in.readObject(); put(key, val); } }
Example #7
Source File: OHLCItemTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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 #8
Source File: NIPv2.java From yangtools with Eclipse Public License 1.0 | 6 votes |
@Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { final QName qname = QName.readFrom(in); final int size = in.readInt(); switch (size) { case 0: nip = NodeIdentifierWithPredicates.of(qname); break; case 1: nip = NodeIdentifierWithPredicates.of(qname, QName.readFrom(in), in.readObject()); break; default: final Builder<QName, Object> keys = ImmutableMap.builderWithExpectedSize(size); for (int i = 0; i < size; ++i) { keys.put(QName.readFrom(in), in.readObject()); } nip = NodeIdentifierWithPredicates.of(qname, keys.build()); } }
Example #9
Source File: OHLCTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); OHLC i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (OHLC) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); }
Example #10
Source File: OHLCItemTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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 #11
Source File: ModuleData.java From netbeans with Apache License 2.0 | 6 votes |
ModuleData(ObjectInput dis) throws IOException { try { this.codeName = dis.readUTF(); this.codeNameBase = dis.readUTF(); this.codeNameRelease = dis.readInt(); this.coveredPackages = readStrings(dis, new HashSet<String>(), true); this.dependencies = (Dependency[]) dis.readObject(); this.implVersion = dis.readUTF(); this.buildVersion = dis.readUTF(); this.provides = readStrings(dis); this.friendNames = readStrings(dis, new HashSet<String>(), false); this.specVers = new SpecificationVersion(dis.readUTF()); this.publicPackages = Module.PackageExport.read(dis); this.agentClass = dis.readUTF(); String s = dis.readUTF(); if (s != null) { s = s.trim(); } this.fragmentHostCodeName = s == null || s.isEmpty() ? null : s; } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } }
Example #12
Source File: YIntervalRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (YIntervalRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); }
Example #13
Source File: RectangleAnchorTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Serialize an instance, restore it, and check for identity. */ public void testSerialization() { final RectangleAnchor a1 = RectangleAnchor.RIGHT; RectangleAnchor a2 = null; try { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); a2 = (RectangleAnchor) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(a1 == a2); }
Example #14
Source File: SymbolicXYItemLabelGeneratorTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); SymbolicXYItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); g2 = (SymbolicXYItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(g1, g2); }
Example #15
Source File: DelimitedParser.java From mrgeo with Apache License 2.0 | 6 votes |
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { boolean hasAttributes = in.readBoolean(); if (hasAttributes) { attributeNames = new ArrayList<>(); int count = in.readInt(); for (int i = 0; i < count; i++) { attributeNames.add(in.readUTF()); } } xCol = in.readInt(); yCol = in.readInt(); geometryCol = in.readInt(); delimiter = in.readChar(); encapsulator = in.readChar(); skipFirstLine = in.readBoolean(); }
Example #16
Source File: right_IrmiPRODelegate_1.3.java From gumtree-spoon-ast-diff with Apache License 2.0 | 6 votes |
public void receive(byte code, ObjectInput in) throws IOException, ClassNotFoundException { JClientRequestInfo info = new JRMPClientRequestInfoImpl(); int len = in.readShort(); for (int i = 0; i < len; i++) { info.add_request_service_context((JServiceContext) in.readObject()); } for (int i = 0; i < cis.length; i++) { switch (code) { case METHOD_RESULT: cis[i].receive_reply(info); break; case METHOD_ERROR: case SYSTEM_ERROR: cis[i].receive_exception(info); break; } } }
Example #17
Source File: EmptyBlockTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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 #18
Source File: XYCoordinateTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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 #19
Source File: HijrahDate.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static HijrahDate readExternal(ObjectInput in) throws IOException, ClassNotFoundException { HijrahChronology chrono = (HijrahChronology) in.readObject(); int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); return chrono.date(year, month, dayOfMonth); }
Example #20
Source File: FirstOrderIntegratorWithJacobians.java From astor with GNU General Public License v2.0 | 5 votes |
/** Read an array. * @param in input stream * @param array array to read * @exception IOException if array cannot be read */ private static void readArray(final ObjectInput in, final double[][] array) throws IOException { for (int i = 0; i < array.length; ++i) { readArray(in, array[i]); } }
Example #21
Source File: CompassPlotTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CompassPlot p1 = new CompassPlot(null); p1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setRoseCenterPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.green)); p1.setRoseHighlightPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.green)); CompassPlot 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 = (CompassPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); }
Example #22
Source File: RoleUpdatedEvent.java From keycloak with Apache License 2.0 | 5 votes |
@Override public RoleUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException { switch (input.readByte()) { case VERSION_1: return readObjectVersion1(input); default: throw new IOException("Unknown version"); } }
Example #23
Source File: MimeType.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example #24
Source File: AvgAggregator.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * @see java.io.Externalizable#readExternal * * @exception IOException on error */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { aggregator = (SumAggregator)in.readObject(); //TODO -sf- is this the most efficient? perhaps better to get the sum direct eliminatedNulls = in.readBoolean(); count = in.readLong(); scale = in.readInt(); }
Example #25
Source File: JointModel.java From spf with GNU General Public License v2.0 | 5 votes |
/** * Read {@link JointModel} object from a file. */ public static <DI extends ISituatedDataItem<?, ?>, MR, ESTEP> JointModel<DI, MR, ESTEP> readJointModel( File file) throws ClassNotFoundException, IOException { LOG.info("Reading joint model from file..."); final long start = System.currentTimeMillis(); try (final ObjectInput input = new ObjectInputStream( new BufferedInputStream(new FileInputStream(file)))) { @SuppressWarnings("unchecked") final JointModel<DI, MR, ESTEP> model = (JointModel<DI, MR, ESTEP>) input .readObject(); LOG.info("Model loaded. Reading time: %.4f", (System.currentTimeMillis() - start) / 1000.0); return model; } }
Example #26
Source File: PolicyUpdatedEvent.java From keycloak with Apache License 2.0 | 5 votes |
public PolicyUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException { PolicyUpdatedEvent res = new PolicyUpdatedEvent(); res.id = MarshallUtil.unmarshallString(input); res.name = MarshallUtil.unmarshallString(input); res.resources = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new); res.resourceTypes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new); res.scopes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new); res.serverId = MarshallUtil.unmarshallString(input); return res; }
Example #27
Source File: LiveRef.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static LiveRef read(ObjectInput in, boolean useNewFormat) throws IOException, ClassNotFoundException { Endpoint ep; ObjID id; // Now read in the endpoint, id, and result flag // (need to choose whether or not to read old JDK1.1 endpoint format) if (useNewFormat) { ep = TCPEndpoint.read(in); } else { ep = TCPEndpoint.readHostPortFormat(in); } id = ObjID.read(in); boolean isResultStream = in.readBoolean(); LiveRef ref = new LiveRef(id, ep, false); if (in instanceof ConnectionInputStream) { ConnectionInputStream stream = (ConnectionInputStream)in; // save ref to send "dirty" call after all args/returns // have been unmarshaled. stream.saveRef(ref); if (isResultStream) { // set flag in stream indicating that remote objects were // unmarshaled. A DGC ack should be sent by the transport. stream.setAckNeeded(); } } else { DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref })); } return ref; }
Example #28
Source File: MithraNotificationEvent.java From reladomo with Apache License 2.0 | 5 votes |
public void readObject(ObjectInput in) throws IOException, ClassNotFoundException { readHeader(in); this.operationForMassDelete = (Operation) in.readObject(); int updatedAttributesSize = in.readInt(); if(updatedAttributesSize > 0) { this.updatedAttributes = new Attribute[updatedAttributesSize]; for(int i = 0; i < updatedAttributesSize; i++) { this.updatedAttributes[i] = (Attribute)in.readObject(); } } int dataObjectsSize = in.readInt(); if(dataObjectsSize > 0) { this.dataObjects = new MithraDataObject[dataObjectsSize]; MithraDataObject dataObject; Class dataClass = MithraSerialUtil.getDataClassForFinder(classname); for(int i = 0; i < dataObjectsSize; i++) { dataObject = MithraSerialUtil.instantiateData(dataClass); dataObject.zDeserializePrimaryKey(in); this.dataObjects[i] = dataObject; } } }
Example #29
Source File: InitPageOperation.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Read this in @exception IOException error reading from log stream @exception ClassNotFoundException log stream corrupted */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); nextRecordId = CompressedNumber.readInt(in); initFlag = CompressedNumber.readInt(in); pageOffset = CompressedNumber.readLong(in); pageFormatId = in.readInt(); }
Example #30
Source File: DefaultKeyedValuesDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); KeyedValuesDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (KeyedValuesDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); }