java.io.ObjectOutput Java Examples
The following examples show how to use
java.io.ObjectOutput.
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: 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 #2
Source File: ExtendedCategoryAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); a1.setSubLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); ExtendedCategoryAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (ExtendedCategoryAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); }
Example #3
Source File: DormandPrince853StepInterpolator.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void writeExternal(final ObjectOutput out) throws IOException { try { // save the local attributes finalizeStep(); } catch (DerivativeException e) { throw MathRuntimeException.createIOException(e); } final int dimension = (currentState == null) ? -1 : currentState.length; out.writeInt(dimension); for (int i = 0; i < dimension; ++i) { out.writeDouble(yDotKLast[0][i]); out.writeDouble(yDotKLast[1][i]); out.writeDouble(yDotKLast[2][i]); } // save the state of the base class super.writeExternal(out); }
Example #4
Source File: AbstractFileFunction.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeBoolean(characterDelimiter!=null); if (characterDelimiter!=null) out.writeUTF(characterDelimiter); out.writeBoolean(columnDelimiter!=null); if (columnDelimiter!=null) out.writeUTF(columnDelimiter); writeNullableUTF(out, timeFormat); writeNullableUTF(out, dateFormat); writeNullableUTF(out,timestampFormat); try { ArrayUtil.writeIntArray(out, WriteReadUtils.getExecRowTypeFormatIds(execRow)); } catch (StandardException se) { throw new IOException(se); } out.writeBoolean(columnIndex!=null); if (columnIndex!=null) ArrayUtil.writeIntArray(out,columnIndex); }
Example #5
Source File: DateTickTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0); DateTick t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (DateTick) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); }
Example #6
Source File: CategoryPointerAnnotationTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (CategoryPointerAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); }
Example #7
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 #8
Source File: ColumnInfo.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Write this object to a stream of stored objects. * * @param out write bytes here. * * @exception IOException thrown on error */ public void writeExternal( ObjectOutput out ) throws IOException { FormatableHashtable fh = new FormatableHashtable(); fh.put("name", name); fh.put("dataType", dataType); fh.put("defaultValue", defaultValue); fh.put("defaultInfo", defaultInfo); fh.put("newDefaultUUID", newDefaultUUID); fh.put("oldDefaultUUID", oldDefaultUUID ); fh.putInt("action", action); if (autoincInc != 0) { // only write out autoinc values if its an autoinc column. fh.putLong("autoincStart", autoincStart); fh.putLong("autoincInc", autoincInc); } out.writeObject(fh); }
Example #9
Source File: PieLabelRecordTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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 #10
Source File: StackedXYAreaRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); r1.setShapePaint(Color.red); r1.setShapeStroke(new BasicStroke(1.23f)); StackedXYAreaRenderer 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 = (StackedXYAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); }
Example #11
Source File: RungeKuttaStepInterpolator.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void writeExternal(final ObjectOutput out) throws IOException { // save the state of the base class writeBaseExternal(out); // save the local attributes final int n = (currentState == null) ? -1 : currentState.length; final int kMax = (yDotK == null) ? -1 : yDotK.length; out.writeInt(kMax); for (int k = 0; k < kMax; ++k) { for (int i = 0; i < n; ++i) { out.writeDouble(yDotK[k][i]); } } // we do not save any reference to the equations }
Example #12
Source File: LdifControl.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void writeExternal( ObjectOutput out ) throws IOException { out.writeUTF( oid ); out.writeBoolean( criticality ); if ( hasValue() ) { out.writeBoolean( true ); out.writeInt( value.length ); if ( value.length > 0 ) { out.write( value ); } } else { out.writeBoolean( false ); } out.flush(); }
Example #13
Source File: DormandPrince853StepInterpolator.java From astor with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void writeExternal(final ObjectOutput out) throws IOException { try { // save the local attributes finalizeStep(); } catch (DerivativeException e) { throw MathRuntimeException.createIOException(e); } final int dimension = (currentState == null) ? -1 : currentState.length; out.writeInt(dimension); for (int i = 0; i < dimension; ++i) { out.writeDouble(yDotKLast[0][i]); out.writeDouble(yDotKLast[1][i]); out.writeDouble(yDotKLast[2][i]); } // save the state of the base class super.writeExternal(out); }
Example #14
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 #15
Source File: StreamRemoteCall.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns an output stream (may put out header information * relating to the success of the call). * @param success If true, indicates normal return, else indicates * exceptional return. * @exception StreamCorruptedException If result stream previously * acquired * @exception IOException For any other problem with I/O. */ public ObjectOutput getResultStream(boolean success) throws IOException { /* make sure result code only marshaled once. */ if (resultStarted) throw new StreamCorruptedException("result already in progress"); else resultStarted = true; // write out return header // return header, part 1 (read by Transport) DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); wr.writeByte(TransportConstants.Return);// transport op getOutputStream(true); // creates a MarshalOutputStream // return header, part 2 (read by client-side RemoteCall) if (success) // out.writeByte(TransportConstants.NormalReturn); else out.writeByte(TransportConstants.ExceptionalReturn); out.writeID(); // write id for gcAck return out; }
Example #16
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 #17
Source File: XYPolygonAnnotationTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); XYPolygonAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (XYPolygonAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); }
Example #18
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 #19
Source File: BubbleXYItemLabelGeneratorTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); BubbleXYItemLabelGenerator 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 = (BubbleXYItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(g1, g2); }
Example #20
Source File: MMapGOV4Function.java From mph-table with Apache License 2.0 | 6 votes |
public static <T> void writeTo(final GOV4Function<T> gov4Function, final String path) throws NoSuchFieldException, IllegalAccessException, IOException { final Field dataField = gov4Function.getClass().getDeclaredField("data"); dataField.setAccessible(true); final AbstractBitVector.LongBigListView signaturesData = (AbstractBitVector.LongBigListView) dataField.get(gov4Function); final Field bitVectorField = signaturesData.getClass().getDeclaredField("bitVector"); bitVectorField.setAccessible(true); final BitVector bitVector = (BitVector)bitVectorField.get(signaturesData); try (final LittleEndianDataOutputStream outputStream = new LittleEndianDataOutputStream( new BufferedOutputStream(new FileOutputStream(Files.buildPath(path, "signatures.bin"))))) { for (final long value : bitVector.bits()) { outputStream.writeLong(value); } } dataField.set(gov4Function, null); try (final OutputStream outputStream = new FileOutputStream(Files.buildPath(path, "GOV4Function.bin")); final ObjectOutput objectOutput = new ObjectOutputStream(outputStream)) { objectOutput.writeObject(gov4Function); } }
Example #21
Source File: DeveloperHtmlBrowserComponent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void writeExternal (ObjectOutput out) throws IOException { out.writeBoolean (bComp.isStatusLineVisible ()); out.writeBoolean (bComp.isToolbarVisible ()); out.writeObject (bComp.getDocumentURL ()); }
Example #22
Source File: VisorCacheAggregatedMetrics.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeString(out, name); U.writeEnum(out, mode); out.writeBoolean(sys); U.writeMap(out, metrics); out.writeObject(minHeapSize); out.writeObject(avgHeapSize); out.writeObject(maxHeapSize); out.writeObject(minOffHeapSize); out.writeObject(avgOffHeapSize); out.writeObject(maxOffHeapSize); out.writeObject(minHits); out.writeObject(avgHits); out.writeObject(maxHits); out.writeObject(minMisses); out.writeObject(avgMisses); out.writeObject(maxMisses); out.writeObject(minReads); out.writeObject(avgReads); out.writeObject(maxReads); out.writeObject(minWrites); out.writeObject(avgWrites); out.writeObject(maxWrites); out.writeObject(minQryTime); out.writeObject(avgQryTime); out.writeObject(maxQryTime); out.writeObject(totalQryTime); out.writeObject(execsQry); out.writeObject(failsQry); }
Example #23
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 #24
Source File: RoleRemovedEvent.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void writeObject(ObjectOutput output, RoleRemovedEvent obj) throws IOException { output.writeByte(VERSION_1); MarshallUtil.marshallString(obj.roleId, output); MarshallUtil.marshallString(obj.roleName, output); MarshallUtil.marshallString(obj.containerId, output); }
Example #25
Source File: PlatformFullJob.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { if (job == null) { assert ptr != 0; try { if (task != null) { if (task.onJobLock()) { try { serialize(); } finally { task.onJobUnlock(); } } else throw new IgniteCheckedException("Task already completed: " + task); } else serialize(); } catch (IgniteCheckedException e) { throw new IOException("Failed to serialize interop job.", e); } } assert job != null; out.writeObject(job); }
Example #26
Source File: PersianCalendar.java From Time4A with Apache License 2.0 | 5 votes |
private void writePersian(ObjectOutput out) throws IOException { PersianCalendar persian = (PersianCalendar) this.obj; out.writeInt(persian.getYear()); out.writeByte(persian.getMonth().getValue()); out.writeByte(persian.getDayOfMonth()); }
Example #27
Source File: BasicUUID.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** Write this out. @exception IOException error writing to log stream */ public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(majorId); out.writeLong(timemillis); out.writeInt(sequence); }
Example #28
Source File: CacheContinuousQueryHandlerV2.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); boolean b = rmtFilterFactoryDep != null; out.writeBoolean(b); if (b) out.writeObject(rmtFilterFactoryDep); else out.writeObject(rmtFilterFactory); out.writeByte(types); }
Example #29
Source File: DocumentDefinition.java From org.openntf.domino with Apache License 2.0 | 5 votes |
@Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeUTF(name_); out.writeBoolean(defaultSummary_); out.writeInt(itemDefinitionKeys_.size()); for (String key : itemDefinitionKeys_) { out.writeUTF(key); } out.writeInt(overrideLabels_.size()); for (Map.Entry<String, String> entry : overrideLabels_.entrySet()) { out.writeUTF(entry.getKey()); out.writeUTF(entry.getValue()); } }
Example #30
Source File: AppUser.java From simple-spring-memcached with MIT License | 5 votes |
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(CLASS_VERSION); out.writeInt(userId); out.writeInt(applicationId); out.writeBoolean(enabled); out.writeInt(version); }