List of usage examples for java.io ObjectOutput writeObject
public void writeObject(Object obj) throws IOException;
From source file:org.jfree.data.time.junit.TimePeriodValuesTest.java
/** * Serialize an instance, restore it, and check for equality. *///from w w w . j a va 2 s . c om public void testSerialization() { TimePeriodValues s1 = new TimePeriodValues("A test"); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); TimePeriodValues 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 = (TimePeriodValues) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); }
From source file:com.github.naoghuman.cm.model.subcategory.SubCategoryModel.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(this.getId()); out.writeLong(this.getMatrixId()); out.writeLong(this.getCategoryId()); out.writeLong(this.getGenerationTime()); out.writeObject(StringEscapeUtils.escapeHtml4(this.getTitle())); out.writeObject(StringEscapeUtils.escapeHtml4(this.getDescription())); }
From source file:org.jfree.data.time.junit.MonthTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w w w. java2 s . co m*/ public void testSerialization() { Month m1 = new Month(12, 1999); Month m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); m2 = (Month) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(m1, m2); }
From source file:xbird.xquery.expr.ext.BDQExpr.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(_endpoint); out.writeObject(_hostVar);/* w w w . j a v a2s. c o m*/ out.writeObject(_queryExpr); }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Serialize an instance, restore it, and check for equality. */// w w w .j a v a2s . c om public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); c2 = (XYSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); }
From source file:de.pro.dbw.file.dream.api.DreamModel.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(this.getId()); out.writeLong(this.getGenerationTime()); out.writeBoolean(this.isFavorite()); out.writeObject(this.getFavoriteReason()); out.writeObject(this.getDescription()); out.writeObject(this.getText()); out.writeObject(this.getTitle()); }
From source file:xbird.xquery.dm.value.sequence.MarshalledSequence.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(_type); final boolean reaccessable = _reaccessable; final boolean redirectable = _redirectable; out.writeBoolean(redirectable);/*from w w w .j a v a 2s .c om*/ if (redirectable) { out.writeObject(_entity); } else { if (_entity instanceof IncrDecodedSequnece) { out.writeBoolean(true); IncrDecodedSequnece incr = ((IncrDecodedSequnece) _entity); incr._reaccessable = reaccessable; incr.writeExternal(out); } else { out.writeBoolean(false); if (_piped) { out.writeBoolean(true); pipedOut(out, _entity, _remotePaging); } else { out.writeBoolean(false); bulkOut(out, _entity, _remotePaging); } } } if (!reaccessable) { this._entity = null; } }
From source file:org.apache.rahas.Token.java
/** * Implementing serialize logic according to our own protocol. We had to follow this, because * OMElement class is not serializable. Making OMElement serializable will have an huge impact * on other components. Therefore implementing serialization logic according to a manual * protocol.//ww w. j a v a 2 s.co m * @param out Stream which writes serialized bytes. * @throws IOException If unable to serialize particular member. */ public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(this.id); out.writeInt(this.state); String stringElement = convertOMElementToString(this.token); out.writeObject(stringElement); stringElement = convertOMElementToString(this.previousToken); out.writeObject(stringElement); stringElement = convertOMElementToString(this.attachedReference); out.writeObject(stringElement); stringElement = convertOMElementToString(this.unattachedReference); out.writeObject(stringElement); out.writeObject(this.properties); out.writeBoolean(this.changed); int secretLength = 0; if (null != this.secret) { secretLength = this.secret.length; } // First write the length of secret out.writeInt(secretLength); if (0 != secretLength) { out.write(this.secret); } out.writeObject(this.created); out.writeObject(this.expires); out.writeObject(this.issuerAddress); out.writeObject(this.encrKeySha1Value); }
From source file:org.opencms.util.CmsUUID.java
/** * //w w w. j a v a 2 s .c o m * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput) */ public void writeExternal(ObjectOutput out) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_WRITE_UUID_1, toString())); } out.writeObject(toString()); }
From source file:org.jfree.data.junit.DefaultKeyedValuesTests.java
/** * Serialize an instance, restore it, and check for equality. *//* w w w. j av a 2s .com*/ public void testSerialization() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("Key 1", new Double(23)); v1.addValue("Key 2", null); v1.addValue("Key 3", new Double(42)); DefaultKeyedValues 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 = (DefaultKeyedValues) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(v1, v2); }