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:org.apache.lens.server.query.QueryExecutionServiceImpl.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    // persist all drivers
    synchronized (drivers) {
        out.writeInt(drivers.size());
        LensDriver driver = null;//from  w w w  .  ja  va 2  s  . co  m
        for (Map.Entry<String, LensDriver> driverEntry : drivers.entrySet()) {
            driver = driverEntry.getValue();
            synchronized (driver) {
                out.writeUTF(driverEntry.getKey());
                out.writeUTF(driver.getClass().getName());
                driver.writeExternal(out);
            }
        }
    }
    // persist allQueries
    synchronized (allQueries) {
        out.writeInt(allQueries.size());
        for (QueryContext ctx : allQueries.values()) {
            synchronized (ctx) {
                out.writeObject(ctx);
                boolean isDriverAvailable = (ctx.getSelectedDriver() != null);
                out.writeBoolean(isDriverAvailable);
                if (isDriverAvailable) {
                    out.writeUTF(ctx.getSelectedDriver().getFullyQualifiedName());
                }
            }
        }
        log.info("Persisted {} queries", allQueries.size());
    }
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

@Override
public void writeExternal(ObjectOutput output) throws IOException {
    output.writeLong(serialVersionUID);//from  w  ww.j  av  a  2s  .co  m
    output.writeInt(progressVisible);
    output.writeUTF(progressCancelBtnText);
    output.writeUTF(progressMsgText);
    output.writeInt(lclPos);
    output.writeInt(lclPosTop);
    output.writeInt(profPos);
    output.writeInt(profPosTop);
    output.writeInt(remPos);
    output.writeInt(remPosTop);
    output.writeInt(dialogVisible);
    output.writeUTF(dialogMsgText);

}

From source file:org.apache.axis2.context.MessageContext.java

/**
 * Calls the serializeSelfManagedData() method of each handler that
 * implements the <bold>SelfManagedDataManager</bold> interface.
 * Handlers for this message context are identified via the
 * executionChain list.//  ww w.  j  a v  a2s .  co  m
 *
 * @param out The output stream
 */
private void serializeSelfManagedData(ObjectOutput out) {
    selfManagedDataHandlerCount = 0;

    try {
        if ((selfManagedDataMap == null) || (executionChain == null) || (selfManagedDataMap.size() == 0)
                || (executionChain.size() == 0)) {
            out.writeBoolean(ExternalizeConstants.EMPTY_OBJECT);

            if (DEBUG_ENABLED && log.isTraceEnabled()) {
                log.trace(getLogIDString() + ":serializeSelfManagedData(): No data : END");
            }

            return;
        }

        // let's create a temporary list with the handlers
        ArrayList<Handler> flatExecChain = flattenPhaseListToHandlers(executionChain, null);

        //ArrayList selfManagedDataHolderList = serializeSelfManagedDataHelper(flatExecChain.iterator(), new ArrayList());
        ArrayList<SelfManagedDataHolder> selfManagedDataHolderList = serializeSelfManagedDataHelper(
                flatExecChain);

        if (selfManagedDataHolderList.size() == 0) {
            out.writeBoolean(ExternalizeConstants.EMPTY_OBJECT);

            if (DEBUG_ENABLED && log.isTraceEnabled()) {
                log.trace(getLogIDString() + ":serializeSelfManagedData(): No data : END");
            }

            return;
        }

        out.writeBoolean(ExternalizeConstants.ACTIVE_OBJECT);

        // SelfManagedData can be binary so won't be able to treat it as a
        // string - need to treat it as a byte []

        // how many handlers actually
        // returned serialized SelfManagedData
        out.writeInt(selfManagedDataHolderList.size());

        for (int i = 0; i < selfManagedDataHolderList.size(); i++) {
            out.writeObject(selfManagedDataHolderList.get(i));
        }

    } catch (IOException e) {
        if (DEBUG_ENABLED && log.isTraceEnabled()) {
            log.trace("MessageContext:serializeSelfManagedData(): Exception [" + e.getClass().getName()
                    + "]  description [" + e.getMessage() + "]", e);
        }
    }

}