Example usage for java.io ObjectOutput writeInt

List of usage examples for java.io ObjectOutput writeInt

Introduction

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

Prototype

void writeInt(int v) throws IOException;

Source Link

Document

Writes an int value, which is comprised of four bytes, to the output stream.

Usage

From source file:xbird.xquery.expr.opt.ShippedVariable.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(_type);/*w  w w  .  ja v  a  2  s.  c  o m*/
    out.writeObject(_varName);
    out.writeInt(_identifier);
    final Sequence result = _result;
    if (result == null) {
        out.writeBoolean(false);
        final XQExpression value = _value;
        if (value == null) {
            throw new IllegalStateException();
        }
        out.writeObject(value);
    } else {
        out.writeBoolean(true);
        if (result instanceof RemoteSequence) {
            out.writeBoolean(true);
            RemoteSequence remote = (RemoteSequence) result;
            remote.writeExternal(out);
        } else {
            out.writeBoolean(false);
            final StopWatch sw = new StopWatch("Elapsed time for encoding `$" + getName() + '\'');
            final XQEventEncoder encoder = new XQEventEncoder(out);
            try {
                encoder.emit(result);
            } catch (XQueryException xqe) {
                throw new IllegalStateException("failed encoding `$" + getName() + '\'', xqe);
            } catch (Throwable e) {
                LOG.fatal(e);
                throw new IllegalStateException("failed encoding `$" + getName() + '\'', e);
            }
            if (LOG.isInfoEnabled()) {
                LOG.info(sw);
            }
        }
    }
}

From source file:org.apache.tapestry.engine.BaseEngine.java

/**
 *  Writes the engine's persistent state; this is simply the list of active page
 *  names.  For efficiency, this is written as a count followed by each name
 *  as a UTF String./*from  w  w  w .  j a va 2  s  .c  o m*/
 * 
 **/

public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    if (Tapestry.isEmpty(_activePageNames)) {
        out.writeInt(0);
        return;
    }

    int count = _activePageNames.size();

    out.writeInt(count);

    Iterator i = _activePageNames.iterator();

    while (i.hasNext()) {
        String name = (String) i.next();

        out.writeUTF(name);
    }
}

From source file:gridool.routing.strategy.ConsistentHash.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(hashFunction);/*from   www  .  j  ava 2s . c o  m*/
    out.writeInt(numberOfVirtualNodes);
    final GridNode[] nodes = getAll();
    out.writeInt(nodes.length);
    for (GridNode node : nodes) {
        out.writeObject(node);
    }
    int numRemoved = removedNodes.size();
    out.writeInt(numRemoved);
    for (GridNode node : removedNodes.values()) {
        out.writeObject(node);
    }
}

From source file:com.sentaroh.android.TextFileBrowser.ViewedFileListAdapter.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(file_path);//from  w  ww.  j a va2  s. c  o  m
    out.writeUTF(file_name);
    out.writeInt(listViewPos[0]);
    out.writeInt(listViewPos[1]);
    out.writeInt(copyFrom);
    out.writeInt(copyTo);
    out.writeInt(horizontalPos);
    out.writeInt(findResultPos);
    out.writeBoolean(findPosIsValid);
    out.writeBoolean(searchEnabled);
    out.writeUTF(searchString);
    out.writeBoolean(searchCaseSensitive);

    out.writeInt(lineBreak);
    out.writeInt(browseMode);
    out.writeBoolean(showLineNo);

    out.writeUTF(encodeName);
    out.writeBoolean(viewerParmsInitRequired);
    out.writeBoolean(viewerParmsRestoreRequired);
}

From source file:org.knime.al.util.noveltydetection.knfst.MultiClassKNFST.java

@Override
public void writeExternal(final ObjectOutput arg0) throws IOException {
    // call super method
    super.writeExternal(arg0);

    // write labels
    arg0.writeInt(m_labels.length);
    for (final String label : m_labels) {
        arg0.writeUTF(label);/*from  w w w.  j a  v a  2  s .  c o  m*/
    }

}

From source file:org.apache.ode.utils.NSContext.java

/**
 * @see Externalizable#writeExternal(java.io.ObjectOutput)
 *//*from  w  ww . ja v a 2 s  . c  o  m*/
public void writeExternal(ObjectOutput out) throws IOException {
    if (__log.isTraceEnabled()) {
        __log.trace("writeExternal: contents=" + _prefixToUriMap);
    }

    out.writeInt(_prefixToUriMap.size());

    for (Iterator i = _prefixToUriMap.entrySet().iterator(); i.hasNext();) {
        Map.Entry me = (Map.Entry) i.next();
        out.writeUTF((String) me.getKey());
        out.writeUTF((String) me.getValue());
    }
}

From source file:xbird.util.nio.RemoteMemoryMappedFile.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeBoolean(_bigEndian);/*from   w  w  w.  j av a2 s .  c o  m*/
    out.writeInt(_pageSize);
    IOUtils.writeString(_sockAddr.getHostName(), out);
    out.writeInt(_sockAddr.getPort());
    IOUtils.writeString(_filePath, out);
    close();
}

From source file:xbird.storage.io.RemoteVarSegments.java

public void writeExternal(ObjectOutput out) throws IOException {
    IOUtils.writeString(_sockAddr.getHostName(), out);
    out.writeInt(_sockAddr.getPort());
    IOUtils.writeString(_filePath, out);
    close();//from   ww  w. j  a  v  a  2s. c  om
}

From source file:org.nuxeo.ecm.platform.ui.web.component.list.StampState.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(rows.size());

    if (rows.isEmpty()) {
        return;/* w w  w .  ja  v a2 s. c o  m*/
    }

    Map<DualKey, Object> map = new HashMap<DualKey, Object>(rows.size());
    map.putAll(rows);

    if (log.isDebugEnabled()) {
        for (Map.Entry<DualKey, Object> entry : map.entrySet()) {
            log.debug("Saving " + entry.getKey() + ", " + entry.getValue());
        }
    }

    out.writeObject(map);
}

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);/*ww  w  .  j  a  va 2 s. c o m*/
    }
    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);
}