public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(1); // version if (first instanceof Serializable) out.writeObject(first); else out.writeObject(null); if (second instanceof Serializable) out.writeObject(second); else out.writeObject(null); }
private void writeTo(ObjectOutput o) throws IOException { o.writeInt(x); o.writeInt(y); o.writeInt(width); o.writeInt(height); o.writeInt(measuredWidth); o.writeInt(measuredHeight); o.writeInt(scrollX); o.writeInt(scrollY); o.writeInt(absoluteX); o.writeInt(absoluteY); o.writeFloat(cameraDistance); o.writeBoolean(visible); o.writeLong(drawingTime); o.writeBoolean(isShown); o.writeBoolean(hasFocus); o.writeBoolean(focusable); o.writeBoolean(hasOnClickListener); o.writeObject(viewType); o.writeObject(textContent); o.writeBoolean(isEditText); o.writeBoolean(isInputMethodTarget); o.writeBoolean(isContainer); o.writeInt(inputMethod); o.writeInt(id); if (children != null) { o.writeInt(children.size()); for (ViewComponentInfo child : children) { child.writeTo(o); } } else { o.writeInt(0); } }
/** * compare the byte-array representation of two TaskObjects. * * @param f TaskObject * @param s TaskObject * @return true if the two arguments have the same byte-array */ private boolean sameBytes(TaskObject f, TaskObject s) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); out.writeObject(f); byte[] fs = bos.toByteArray(); out.writeObject(s); byte[] ss = bos.toByteArray(); if (fs.length != ss.length) return false; for (int i = 0; i < fs.length; i++) { if (fs[i] != ss[i]) return false; } return true; } catch (IOException e) { e.printStackTrace(); return false; } finally { if (out != null) { try { out.close(); } catch (IOException e) { // ignore } try { bos.close(); } catch (IOException e) { // ignore } } } }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(firstName); out.writeUTF(lastName); out.writeInt(age); out.writeObject(mother); out.writeObject(father); out.writeObject(children); }
public void writeExternal(ObjectOutput out) throws IOException { // esto es solo para serializar tickets que no estan en la bolsa de tickets pendientes out.writeObject(m_sId); out.writeInt(tickettype); out.writeInt(m_iTicketId); out.writeInt(m_iTicketNCF); // NCF out.writeObject(m_Customer); out.writeObject(m_dDate); out.writeObject(attributes); out.writeObject(m_aLines); }
/** Serializes this <code>DataFlavor</code>. */ public synchronized void writeExternal(ObjectOutput os) throws IOException { if (mimeType != null) { mimeType.setParameter("humanPresentableName", humanPresentableName); os.writeObject(mimeType); mimeType.removeParameter("humanPresentableName"); } else { os.writeObject(null); } os.writeObject(representationClass); }
public void writeExternal(ObjectOutput out) { try { out.writeObject("LEVEL"); out.writeObject(new Integer(level)); out.writeObject("TIMESUSED"); out.writeObject(new Integer(timesUsed)); out.writeObject("SKILL END"); } catch (Exception e) { e.printStackTrace(); } }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(depEnabled); if (depEnabled) { U.writeByteArray(out, topicBytes); U.writeByteArray(out, predBytes); U.writeString(out, clsName); out.writeObject(depInfo); } else { out.writeObject(topic); out.writeObject(pred); } }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(size()); for (int i = 0; i < size(); i++) { out.writeObject(get(i)); } }
public static byte[] convertToBytes(Object object) throws IOException { try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos)) { out.writeObject(object); return bos.toByteArray(); } }
/** * Serialize an instance, restore it, and check for equality. In addition, test for a bug that was * reported where the listener list is 'null' after deserialization. */ public void testSerialization() { BarRenderer r1 = new BarRenderer(); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 4)); r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); r1.setBaseLegendShape(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); BarRenderer 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 = (BarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); try { r2.notifyListeners(new RendererChangeEvent(r2)); } catch (NullPointerException e) { assertTrue(false); // failed } }
// deprecated in ObjectOutputStream.PutField public void write(ObjectOutput out) throws IOException { /* * Applications should *not* use this method to write PutField * data, as it will lead to stream corruption if the PutField * object writes any primitive data (since block data mode is not * unset/set properly, as is done in OOS.writeFields()). This * broken implementation is being retained solely for behavioral * compatibility, in order to support applications which use * OOS.PutField.write() for writing only non-primitive data. * * Serialization of unshared objects is not implemented here since * it is not necessary for backwards compatibility; also, unshared * semantics may not be supported by the given ObjectOutput * instance. Applications which write unshared objects using the * PutField API must use OOS.writeFields(). */ if (InteropObjectOutputStream.this != out) { throw new IllegalArgumentException("wrong stream"); } out.write(primVals, 0, primVals.length); ObjectStreamField[] fields = desc.getFields(false); int numPrimFields = fields.length - objVals.length; // REMIND: warn if numPrimFields > 0? for (int i = 0; i < objVals.length; i++) { if (fields[numPrimFields + i].isUnshared()) { throw new IOException("cannot write unshared object"); } out.writeObject(objVals[i]); } }
/** * @param out Output stream. * @param err Error cause. */ private void sendErrorResponse(ObjectOutput out, Exception err) { try { out.writeObject(new IpcSharedMemoryInitResponse(err)); } catch (IOException e) { U.error(log, "Failed to send error response to client.", e); } }
// Implements Externalizable public void writeExternal(ObjectOutput out) throws IOException { // VERSION out.writeByte(0); // MAP out.writeObject(_map); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { boolean done; boolean cancelled; Object res; Throwable err; boolean syncNotify; boolean concurNotify; synchronized (mux) { done = this.done; cancelled = this.cancelled; res = this.res; err = this.err; syncNotify = this.syncNotify; concurNotify = this.concurNotify; } out.writeBoolean(done); out.writeBoolean(syncNotify); out.writeBoolean(concurNotify); // Don't write any further if not done, as deserialized future // will be invalid anyways. if (done) { out.writeBoolean(cancelled); out.writeObject(res); out.writeObject(err); } }
public byte[] getByteContent() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(baos); out.writeObject(content); out.close(); return baos.toByteArray(); }
// Implements Externalizable @Override public void writeExternal(ObjectOutput out) throws IOException { // VERSION out.writeByte(0); // SET out.writeObject(_set); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(id); boolean writable = innerSplit instanceof Writable; out.writeUTF(writable ? innerSplit.getClass().getName() : null); if (writable) ((Writable) innerSplit).write(out); else out.writeObject(innerSplit); }
// write data to server's database file private void updateFile(String file_name, Object data) { try { OutputStream file_data = new FileOutputStream(file_name); OutputStream buffer = new BufferedOutputStream(file_data); ObjectOutput data_out = new ObjectOutputStream(buffer); data_out.writeObject(data); data_out.close(); } catch (Exception e) { System.out.println("updateFile: Failed to update data to " + file_name); } }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeLong(topVer); out.writeBoolean(implicitTx); out.writeBoolean(implicitSingleTx); out.writeBoolean(syncCommit); out.writeBoolean(syncRollback); out.writeObject(filterBytes); U.writeArray(out, dhtVers); assert miniId != null; U.writeGridUuid(out, miniId); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); assert futId != null; assert miniId != null; assert ver != null; U.writeGridUuid(out, futId); U.writeGridUuid(out, miniId); U.writeCollection(out, entries); U.writeIntCollection(out, invalidParts); CU.writeVersion(out, ver); out.writeObject(err); }
static void writeSlotWithFields( ClassMetaDataSlot slot, ObjectOutput output, Object obj, ObjectSubstitutionInterface substitution) throws IOException { ClassMetadataField[] fields = slot.getFields(); for (int fieldNR = 0; fieldNR < fields.length; fieldNR++) { ClassMetadataField field = fields[fieldNR]; if (field.getField().getType().isPrimitive() && !field.getField().getType().isArray()) { writeOnPrimitive(output, obj, field); } else { Object value = null; value = FieldsManager.getFieldsManager().getObject(obj, field); output.writeObject(value); } } }
/** * @param out Object output. * @throws IOException If failed. */ @SuppressWarnings("TypeMayBeWeakened") private void writeFieldsCollection(ObjectOutput out) throws IOException { assert fields; out.writeInt(data != null ? data.size() : -1); if (data == null) return; for (Object o : data) { List<GridIndexingEntity<?>> list = (List<GridIndexingEntity<?>>) o; out.writeInt(list.size()); for (GridIndexingEntity<?> idxEnt : list) { try { out.writeObject(idxEnt.value()); } catch (GridSpiException e) { throw new IOException("Failed to write indexing entity: " + idxEnt, e); } } } }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(fieldName.toCharArray()); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(base); out.writeInt(minOccurs); out.writeInt(maxOccurs); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(ctx); out.writeUTF(name); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(base); out.writeInt(start); out.writeInt(end); }
protected void marshalCustomCallData(ObjectOutput out) throws IOException { // this custom data ensures that a custom server // ref has written the relevant information. System.err.println("marshalling call data..."); out.writeObject("hello there."); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(key); out.writeObject(val); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeObject(parts); }