List of usage examples for java.io ObjectOutput writeInt
void writeInt(int v) throws IOException;
int
value, which is comprised of four bytes, to the output stream. From source file:LinkedList.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(firstNode);//from w w w .java 2 s. com out.writeObject(lastNode); out.writeInt(size); out.writeObject(iterator); }
From source file:com.ning.metrics.serialization.event.SmileEnvelopeEvent.java
/** * The object implements the writeExternal method to save its contents * by calling the methods of DataOutput for its primitive values or * calling the writeObject method of ObjectOutput for objects, strings, * and arrays.//from w w w. j av a 2 s .c om * * @param out the stream to write the object to * @throws java.io.IOException Includes any I/O exceptions that may occur * @serialData Overriding methods should use this tag to describe * the data layout of this Externalizable object. * List the sequence of element types and, if possible, * relate the element to a public/protected field and/or * method of this Externalizable class. */ @Override public void writeExternal(final ObjectOutput out) throws IOException { // Name of the event final byte[] eventNameBytes = eventName.getBytes(NAME_CHARSET); out.writeInt(eventNameBytes.length); out.write(eventNameBytes); final byte[] payloadBytes = getSerializedEvent(); // Size of Smile payload. Needed for deserialization, see below out.writeInt(payloadBytes.length); out.write(payloadBytes); }
From source file:com.delphix.session.impl.frame.SerialNumber.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeByte(serialBits);/* w w w. j ava2 s . c o m*/ if (serialBits < Byte.SIZE) { out.writeByte((int) serialNumber); } else if (serialBits < Short.SIZE) { out.writeShort((int) serialNumber); } else if (serialBits < Integer.SIZE) { out.writeInt((int) serialNumber); } else { out.writeLong(serialNumber); } }
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./*from w ww. j a va 2 s . c o 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.knime.al.util.noveltydetection.knfst.KNFST.java
@Override public void writeExternal(final ObjectOutput arg0) throws IOException { // write kernel arg0.writeUTF(m_kernel.getClass().getName()); m_kernel.writeExternal(arg0);// w w w.j a v a 2 s .co m // write projection // rows arg0.writeInt(m_projection.getRowDimension()); // columns arg0.writeInt(m_projection.getColumnDimension()); // data final double[][] projData = m_projection.getData(); for (final double[] row : projData) { for (final double cell : row) { arg0.writeDouble(cell); } } // write targetPoints // rows arg0.writeInt(m_targetPoints.getRowDimension()); // columns arg0.writeInt(m_targetPoints.getColumnDimension()); // data final double[][] tarData = m_targetPoints.getData(); for (final double[] row : tarData) { for (final double cell : row) { arg0.writeDouble(cell); } } // write betweenClassDistances // length arg0.writeInt(m_betweenClassDistances.length); // data for (final double dist : m_betweenClassDistances) { arg0.writeDouble(dist); } }
From source file:com.talis.storage.s3.ExternalizableS3Object.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(getKey());/* ww w. j ava 2 s. c o m*/ out.writeUTF(getBucketName()); out.writeObject(getAcl()); out.writeBoolean(isMetadataComplete()); out.writeObject(getMetadataMap()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { IOUtils.copy(this.getDataInputStream(), buffer); } catch (S3ServiceException e) { LOG.error("Error copying entity stream", e); throw new IOException("Error serializing object", e); } out.writeInt(buffer.toByteArray().length); out.write(buffer.toByteArray()); }
From source file:org.t2framework.commons.util.ArrayMap.java
public final void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(listTable.length); out.writeInt(size);/*from w ww . j av a 2 s . c o m*/ for (int i = 0; i < size; i++) { out.writeObject(listTable[i].key_); out.writeObject(listTable[i].value_); } }
From source file:org.apache.lens.server.session.HiveSessionService.java
@Override public void writeExternal(ObjectOutput out) throws IOException { // Write out all the sessions out.writeInt(SESSION_MAP.size()); for (LensSessionHandle sessionHandle : SESSION_MAP.values()) { LensSessionImpl session = getSession(sessionHandle); session.getLensSessionPersistInfo().writeExternal(out); }/*from ww w. j a v a 2 s. c om*/ log.info("Session service pesristed " + SESSION_MAP.size() + " sessions"); }
From source file:xbird.xquery.expr.path.PathExpr.java
public void writeExternal(ObjectOutput out) throws IOException { final List<XQExpression> steps = _steps; final int numSteps = steps.size(); out.writeInt(numSteps); for (int i = 0; i < numSteps; i++) { XQExpression step = steps.get(i); out.writeObject(step);/* ww w . j ava 2s. c o m*/ } final XQExpression analyzed = _analyzedExpr; if (analyzed == null) { out.writeBoolean(false); } else { out.writeBoolean(true); out.writeObject(analyzed); } }
From source file:org.perf.log.logger.PerfLogData.java
private void writeStr(String outStr, ObjectOutput out) { try {/*from w ww . java 2 s . c om*/ if (outStr != null) { out.writeInt(outStr.length()); out.writeObject(outStr); } else { out.writeInt(0); } } catch (IOException e) { e.printStackTrace(); } }