Example usage for java.io ObjectOutput write

List of usage examples for java.io ObjectOutput write

Introduction

In this page you can find the example usage for java.io ObjectOutput write.

Prototype

public void write(byte b[]) throws IOException;

Source Link

Document

Writes an array of bytes.

Usage

From source file:org.opencms.db.CmsPublishList.java

/**
 * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
 */// ww w.jav a2  s . c  om
public void writeExternal(ObjectOutput out) throws IOException {

    // write the history id
    out.write(m_publishHistoryId.toByteArray());
    // write the project id
    out.write((m_projectId != null) ? m_projectId.toByteArray() : CmsUUID.getNullUUID().toByteArray());
    // write the flags
    out.writeInt((m_publishSiblings) ? 1 : 0);
    out.writeInt((m_publishSubResources) ? 1 : 0);
    // write the list of direct publish resources by writing the uuid of each resource
    if (m_directPublishResources != null) {
        out.writeInt(m_directPublishResources.size());
        for (Iterator<CmsResource> i = m_directPublishResources.iterator(); i.hasNext();) {
            out.write((i.next()).getStructureId().toByteArray());
        }
    } else {
        out.writeInt(NIL);
    }
    // write the list of published files by writing the uuid of each resource
    if (m_fileList != null) {
        out.writeInt(m_fileList.size());
        for (Iterator<CmsResource> i = m_fileList.iterator(); i.hasNext();) {
            out.write((i.next()).getStructureId().toByteArray());
        }
    } else {
        out.writeInt(NIL);
    }
    // write the list of published folders by writing the uuid of each resource
    if (m_folderList != null) {
        out.writeInt(m_folderList.size());
        for (Iterator<CmsResource> i = m_folderList.iterator(); i.hasNext();) {
            out.write((i.next()).getStructureId().toByteArray());
        }
    } else {
        out.writeInt(NIL);
    }
    // write the list of deleted folders by writing the uuid of each resource
    if (m_deletedFolderList != null) {
        out.writeInt(m_deletedFolderList.size());
        for (Iterator<CmsResource> i = m_deletedFolderList.iterator(); i.hasNext();) {
            out.write((i.next()).getStructureId().toByteArray());
        }
    } else {
        out.writeInt(NIL);
    }
}

From source file:org.openspaces.persistency.cassandra.meta.ColumnFamilyMetadata.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.write(SERIAL_VER);
    IOUtils.writeObject(out, typeDescriptorData);
    IOUtils.writeObject(out, topLevelTypeNode);
    IOUtils.writeString(out, columnFamilyName);
}

From source file:org.taverna.server.master.common.Workflow.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    try {/*from   w w  w  . j a v  a  2 s  . c  o m*/
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamWriter w = new OutputStreamWriter(new DeflaterOutputStream(baos), ENCODING);
        marshaller.marshal(this, w);
        w.close();
        byte[] bytes = baos.toByteArray();
        out.writeInt(bytes.length);
        out.write(bytes);
    } catch (JAXBException e) {
        throw new IOException("failed to marshal", e);
    }
}

From source file:xbird.xquery.dm.value.sequence.MarshalledSequence.java

private static void bulkOut(ObjectOutput out, Sequence<Item> entity, boolean remotePaing) throws IOException {
    final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
    final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
    final XQEventEncoder encoder = new XQEventEncoder(objOut);
    if (remotePaing) {
        encoder.setRemotePaging(true);//from w w w . java  2 s . c om
    }
    try {
        encoder.emit(entity);
        objOut.flush();
    } catch (XQueryException xqe) {
        throw new IllegalStateException("failed encoding", xqe);
    } catch (Throwable e) {
        LOG.fatal(e);
        throw new IllegalStateException("failed encoding", e);
    }
    final byte[] buf = bufOut.toByteArray();
    bufOut.clear();
    final int buflen = buf.length;
    if (LOG.isDebugEnabled()) {
        LOG.debug("encoded sequence size: " + buflen);
    }
    out.writeInt(buflen);
    out.write(buf);
}