Example usage for java.io DataOutput writeBoolean

List of usage examples for java.io DataOutput writeBoolean

Introduction

In this page you can find the example usage for java.io DataOutput writeBoolean.

Prototype

void writeBoolean(boolean v) throws IOException;

Source Link

Document

Writes a boolean value to this output stream.

Usage

From source file:com.chinamobile.bcbsp.util.JobStatus.java

/** serialize
 * write this object to out./*from  ww  w .  j a  v a2s  .  c  o m*/
 *
 * @param out Writes to the output stream.
 */
@Override
public synchronized void write(DataOutput out) throws IOException {
    jobid.write(out);
    out.writeLong(setupProgress);
    out.writeLong(progress);
    out.writeLong(cleanupProgress);
    out.writeInt(runState);
    WritableUtils.writeEnum(out, this.state);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    Text.writeString(out, user);
    //    Text.writeString(out, schedulingInfo);
    out.writeLong(superstepCount);
    out.writeBoolean(recovery);
}

From source file:com.mapr.hbase.support.objects.MHRegionInfo.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeByte(getVersion());/*from  w w  w .jav  a 2  s . c  om*/
    Bytes.writeByteArray(out, endKey);
    out.writeBoolean(offLine);
    out.writeLong(regionId);
    Bytes.writeByteArray(out, regionName);
    out.writeBoolean(split);
    Bytes.writeByteArray(out, startKey);
    if (getVersion() == 0) {
        tableDesc.write(out);
    } else {
        Bytes.writeByteArray(out, tableName);
    }
    out.writeInt(hashCode);
}

From source file:eu.stratosphere.nephele.jobgraph.AbstractJobVertex.java

@Override
public void write(final DataOutput out) throws IOException {

    // Number of subtasks
    out.writeInt(this.numberOfSubtasks);

    // Number of execution retries
    out.writeInt(this.numberOfExecutionRetries);

    // Vertex to share instance with
    if (this.vertexToShareInstancesWith != null) {
        out.writeBoolean(true);
        this.vertexToShareInstancesWith.getID().write(out);
    } else {/*from w w w. j a  v  a  2  s. c  o m*/
        out.writeBoolean(false);
    }

    // Write the configuration
    this.configuration.write(out);

    // We ignore the backward edges and connect them when we reconstruct the graph on the remote side, only write
    // number of forward edges
    out.writeInt(this.forwardEdges.size());

    // Now output the IDs of the vertices this vertex is connected to
    for (int i = 0; i < this.forwardEdges.size(); i++) {
        final JobEdge edge = this.forwardEdges.get(i);
        if (edge == null) {
            out.writeBoolean(false);
        } else {
            out.writeBoolean(true);
            edge.getConnectedVertex().getID().write(out);
            EnumUtils.writeEnum(out, edge.getChannelType());
            EnumUtils.writeEnum(out, edge.getDistributionPattern());
            out.writeInt(edge.getIndexOfInputGate());
        }
    }

    // Write the invokable class
    if (this.invokableClass == null) {
        out.writeBoolean(false);
        return;
    }

    out.writeBoolean(true);

    // Write out the name of the class
    StringRecord.writeString(out, this.invokableClass.getName());
}

From source file:com.chinamobile.bcbsp.util.StaffStatus.java

/** serialize
 * write this object to out.//  w  w  w.  ja v a2s . c om
 *
 * @param out Writes to the output stream.
 */
@Override
public void write(DataOutput out) throws IOException {
    jobId.write(out);
    staffId.write(out);
    out.writeInt(progress);
    WritableUtils.writeEnum(out, runState);
    Text.writeString(out, stateString);
    WritableUtils.writeEnum(out, phase);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    out.writeLong(superstepCount);
    if (this.faultFlag == 0) {
        out.writeInt(this.faultFlag);
    } else {
        out.writeInt(this.faultFlag);
        this.fault.write(out);
    }
    out.writeBoolean(recovery);
    out.writeLong(this.currentSSTime);
    Text.writeString(out, workerManager);
}

From source file:com.fiorano.openesb.application.aps.OutPortInst.java

/**
 *  This method is called to write this object of <code>OutPortInst</code>
 *  to the specified output stream object.
 *
 * @param out DataOutput object//from  ww  w .j  av a  2s  . c  o  m
 * @param versionNo Description of the Parameter
 * @exception IOException if an error occurs while converting data and
 *      writing it to a binary stream.
 * @since Tifosi2.0
 */
public void toStream(DataOutput out, int versionNo) throws IOException {
    super.toStream(out, versionNo);

    writeUTF(out, m_strPortName);
    writeUTF(out, m_strDscription);
    writeUTF(out, m_strXSD);
    writeUTF(out, m_strContextXSL);
    writeUTF(out, m_strContextInfo);

    writeUTF(out, m_transformerType);
    writeUTF(out, m_strJavaClass);
    out.writeBoolean(m_bIsSyncRequestType);
    out.writeBoolean(m_bisDisabled);

    if (m_params != null && m_params.size() > 0) {
        int num = m_params.size();

        out.writeInt(num);
        for (int i = 0; i < num; ++i) {
            Param param = (Param) m_params.elementAt(i);

            param.toStream(out, versionNo);
        }
    } else {
        out.writeInt(0);
    }
}

From source file:dk.statsbiblioteket.util.LineReaderTest.java

public void writeSample(DataOutput out) throws Exception {
    out.writeInt(12345);/*from   w w  w  .  jav a 2 s  . co m*/
    out.writeInt(-87);
    out.writeLong(123456789L);
    out.write("Hello World!\n".getBytes("utf-8"));
    out.write("Another world\n".getBytes("utf-8"));
    out.writeFloat(0.5f);
    out.writeBoolean(true);
    out.writeBoolean(false);
    out.writeByte(12);
    out.writeByte(-12);
    out.write(129);
    out.writeShort(-4567);
    out.writeBytes("ASCII");
}

From source file:ml.shifu.shifu.core.dtrain.dataset.PersistBasicFloatNetwork.java

public void saveNetwork(DataOutput out, final BasicFloatNetwork network) throws IOException {
    final FlatNetwork flat = network.getStructure().getFlat();
    // write general properties
    Map<String, String> properties = network.getProperties();
    if (properties == null) {
        out.writeInt(0);/*  w w  w . j av  a2  s . com*/
    } else {
        out.writeInt(properties.size());
        for (Entry<String, String> entry : properties.entrySet()) {
            ml.shifu.shifu.core.dtrain.StringUtils.writeString(out, entry.getKey());
            ml.shifu.shifu.core.dtrain.StringUtils.writeString(out, entry.getValue());
        }
    }

    // write fields values in BasicFloatNetwork
    out.writeInt(flat.getBeginTraining());
    out.writeDouble(flat.getConnectionLimit());

    writeIntArray(out, flat.getContextTargetOffset());
    writeIntArray(out, flat.getContextTargetSize());

    out.writeInt(flat.getEndTraining());
    out.writeBoolean(flat.getHasContext());
    out.writeInt(flat.getInputCount());

    writeIntArray(out, flat.getLayerCounts());
    writeIntArray(out, flat.getLayerFeedCounts());
    writeIntArray(out, flat.getLayerContextCount());
    writeIntArray(out, flat.getLayerIndex());
    writeDoubleArray(out, flat.getLayerOutput());
    out.writeInt(flat.getOutputCount());
    writeIntArray(out, flat.getWeightIndex());
    writeDoubleArray(out, flat.getWeights());
    writeDoubleArray(out, flat.getBiasActivation());

    // write activation list
    out.writeInt(flat.getActivationFunctions().length);
    for (final ActivationFunction af : flat.getActivationFunctions()) {
        ml.shifu.shifu.core.dtrain.StringUtils.writeString(out, af.getClass().getSimpleName());
        writeDoubleArray(out, af.getParams());
    }
    // write sub sets
    Set<Integer> featureList = network.getFeatureSet();
    if (featureList == null || featureList.size() == 0) {
        out.writeInt(0);
    } else {
        out.writeInt(featureList.size());
        for (Integer integer : featureList) {
            out.writeInt(integer);
        }
    }
}

From source file:com.fiorano.openesb.application.aps.ApplicationHeader.java

/**
 *  This method writes this <code>ApplicationHeader</code> object to the
 *  specified output stream object.//from ww w.j  a  va  2s.  c  om
 *
 * @param out DataOutput object
 * @param versionNo
 * @exception IOException if an error occurs while converting data and
 * writing it to a binary stream.
 * @see #fromStream(DataInput, int)
 * @since Tifosi2.0
 */
public void toStream(DataOutput out, int versionNo) throws IOException {
    super.toStream(out, versionNo);

    out.writeBoolean(m_canBeSubGraphed);

    if (m_scope != null)
        UTFReaderWriter.writeUTF(out, m_scope);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_appName != null)
        UTFReaderWriter.writeUTF(out, m_appName);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_appGUID != null)
        UTFReaderWriter.writeUTF(out, m_appGUID);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_creationDate != null)
        UTFReaderWriter.writeUTF(out, m_creationDate);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_category != null)
        UTFReaderWriter.writeUTF(out, m_category);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_authorNames != null) {
        int length = m_authorNames.size();

        out.writeInt(length);

        Enumeration names = m_authorNames.elements();

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();

            UTFReaderWriter.writeUTF(out, name);
        }
    } else
        out.writeInt(0);

    if (m_iconName != null)
        UTFReaderWriter.writeUTF(out, m_iconName);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_shortDescription != null)
        UTFReaderWriter.writeUTF(out, m_shortDescription);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_longDescription != null)
        UTFReaderWriter.writeUTF(out, m_longDescription);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_compatibleWith != null) {
        int length = m_compatibleWith.size();

        out.writeInt(length);

        Enumeration names = m_compatibleWith.elements();

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();

            UTFReaderWriter.writeUTF(out, name);
        }
    } else
        out.writeInt(0);

    out.writeInt(m_maxInstLimit);

    if (m_params != null) {
        int length = m_params.size();

        out.writeInt(length);

        Enumeration params = m_params.elements();

        while (params.hasMoreElements()) {
            Param param = (Param) params.nextElement();

            param.toStream(out, versionNo);
        }
    } else
        out.writeInt(0);

    if (m_version != null)
        UTFReaderWriter.writeUTF(out, m_version);
    else
        UTFReaderWriter.writeUTF(out, "");

    out.writeBoolean(m_isVersionLocked);

    UTFReaderWriter.writeUTF(out, m_strProfile);

    if (m_appContext != null) {
        out.writeInt(1);
        m_appContext.toStream(out, versionNo);
    } else {
        out.writeInt(0);
    }
}

From source file:com.fiorano.openesb.application.aps.Route.java

/**
 *  This method is called to write this object of <code>Route</code> to the
 *  specified output stream object.//from ww w .  j  a v  a 2s  .  c  o m
 *
 * @param out DataOutput object
 * @param versionNo
 * @exception IOException if an error occurs while converting data and
 *      writing it to a binary stream.
 * @see #fromStream(DataInput, int)
 * @since Tifosi2.0
 */
public void toStream(DataOutput out, int versionNo) throws IOException {
    super.toStream(out, versionNo);

    out.writeBoolean(m_isP2PRoute);

    out.writeBoolean(m_isPersitant);

    out.writeBoolean(m_isDurable);

    out.writeBoolean(m_applyTransformationAtSrc);

    if (m_routeName != null) {
        UTFReaderWriter.writeUTF(out, m_routeName);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_routeGUID != null) {
        UTFReaderWriter.writeUTF(out, m_routeGUID);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    out.writeLong(m_iTimeToLive);

    if (m_srcServInst != null) {
        UTFReaderWriter.writeUTF(out, m_srcServInst);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_trgtServInst != null) {
        UTFReaderWriter.writeUTF(out, m_trgtServInst);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_srcPortName != null) {
        UTFReaderWriter.writeUTF(out, m_srcPortName);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_trgtPortName != null) {
        UTFReaderWriter.writeUTF(out, m_trgtPortName);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_transformationXSL != null) {
        UTFReaderWriter.writeUTF(out, m_transformationXSL);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_selectors != null) {
        int size = m_selectors.size();

        // For newer versions i am writing -1.
        out.writeInt(-1);
        out.writeInt(size);

        Set keys = m_selectors.keySet();
        Iterator itr = keys.iterator();

        while (itr.hasNext()) {
            String type = (String) itr.next();
            Object obj = m_selectors.get(type);

            if (type == null)
                type = "";

            // Write the type.
            UTFReaderWriter.writeUTF(out, type);

            if (type.equalsIgnoreCase(MESSAGE_BODY_XPATH) || type.equalsIgnoreCase(APP_CONTEXT_XPATH)) {
                // Then ask the dmi to streamify.
                ((XPathDmi) obj).toStream(out, versionNo);
            } else {
                String value = (String) obj;

                if (value == null)
                    value = "";

                UTFReaderWriter.writeUTF(out, value);
            }
        }
    } else {
        out.writeInt(0);
    }

    if (m_params != null) {
        int length = m_params.size();

        out.writeInt(length);

        Enumeration params = m_params.elements();

        while (params.hasMoreElements()) {
            Param param = (Param) params.nextElement();

            param.toStream(out, versionNo);
        }
    } else {
        out.writeInt(0);
    }

    if (m_shortDescription != null) {
        UTFReaderWriter.writeUTF(out, m_shortDescription);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_longDescription != null) {
        UTFReaderWriter.writeUTF(out, m_longDescription);
    } else {
        UTFReaderWriter.writeUTF(out, "");
    }

    if (m_altDestination != null) {
        out.writeInt(1);
        m_altDestination.toStream(out, versionNo);
    } else {
        out.writeInt(0);
    }

}

From source file:com.fiorano.openesb.application.aps.ServiceInstance.java

/**
 *  This method tests whether this object of <code>ServiceInstance</code>
 *  has the required(mandatory) fields set, before inserting values in to
 *  the database.//www.j a v a2 s  .  c  om
 *
 * @param out DataOutput object
 * @param versionNo
 * @exception IOException if the object is not valid
 * @since Tifosi2.0
 */
public void toStream(DataOutput out, int versionNo) throws IOException {
    super.toStream(out, versionNo);

    out.writeBoolean(m_isManualLaunch);

    out.writeBoolean(m_isStateful);

    out.writeBoolean(m_isDelayedLaunch);

    UTFReaderWriter.writeUTF(out, m_delayedPortName);

    out.writeBoolean(m_isTransacted);

    out.writeBoolean(m_isErrorHandlingEnabled);

    out.writeBoolean(m_isVersionLocked);

    out.writeBoolean(m_isEndOfWorkflow);

    out.writeBoolean(m_isInMemoryLaunch);

    out.writeBoolean(m_isTransportLPC);

    out.writeBoolean(m_bPreferLaunchOnHigherLevelNode);

    out.writeBoolean(m_bIsDurableSubscription);

    out.writeBoolean(m_bIsDurableConnection);

    out.writeBoolean(m_bKillPrimaryOnSecondaryLaunch);

    out.writeBoolean(m_bIsDebugMode);

    out.writeInt(m_iDebugPort);

    out.writeInt(m_maxRetries);

    if (m_version != null)
        UTFReaderWriter.writeUTF(out, m_version);
    else
        UTFReaderWriter.writeUTF(out, "");

    out.writeLong(m_dBufferSizePerPort);

    if (m_servInstName != null)
        UTFReaderWriter.writeUTF(out, m_servInstName);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_servGUID != null)
        UTFReaderWriter.writeUTF(out, m_servGUID);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_longDescription != null)
        UTFReaderWriter.writeUTF(out, m_longDescription);
    else
        UTFReaderWriter.writeUTF(out, "");

    if (m_shortDescription != null)
        UTFReaderWriter.writeUTF(out, m_shortDescription);
    else
        UTFReaderWriter.writeUTF(out, "");

    // Service Dependency
    if (m_runtimeDependencies != null && m_runtimeDependencies.size() > 0) {
        int num = m_runtimeDependencies.size();

        out.writeInt(num);
        for (int i = 0; i < num; ++i) {
            RuntimeDependency serv = (RuntimeDependency) m_runtimeDependencies.elementAt(i);

            serv.toStream(out, versionNo);
        }
    } else {
        out.writeInt(0);
    }

    if (m_runtimeArgs != null) {
        out.writeInt(1);
        m_runtimeArgs.toStream(out, versionNo);
    } else
        out.writeInt(0);

    if (m_portInstDescriptor != null) {
        out.writeInt(1);
        m_portInstDescriptor.toStream(out, versionNo);
    } else
        out.writeInt(0);

    if (m_params != null) {
        int length = m_params.size();

        out.writeInt(length);

        Enumeration params = m_params.elements();

        while (params.hasMoreElements()) {
            Param param = (Param) params.nextElement();

            param.toStream(out, versionNo);
        }
    } else
        out.writeInt(0);

    if (m_statusTracking != null) {
        out.writeInt(1);
        m_statusTracking.toStream(out, versionNo);
    } else
        out.writeInt(0);

    if (m_vecEndStates != null) {
        int size = m_vecEndStates.size();

        out.writeInt(size);
        for (int i = 0; i < size; i++) {
            ((EndState) m_vecEndStates.get(i)).toStream(out, versionNo);
        }
    } else
        out.writeInt(0);

    if (m_nodes != null) {
        int size = m_nodes.size();

        out.writeInt(size);

        Enumeration keys = m_nodes.keys();
        Enumeration values = m_nodes.elements();

        while (keys.hasMoreElements()) {
            UTFReaderWriter.writeUTF(out, (String) keys.nextElement());
            UTFReaderWriter.writeUTF(out, (String) values.nextElement());
        }
    } else
        out.writeInt(0);

    if (m_monitor != null) {
        out.writeInt(1);
        m_monitor.toStream(out, versionNo);
    } else
        out.writeInt(0);

    if (m_logModules != null) {
        out.writeInt(1);
        m_logModules.toStream(out, versionNo);
    } else
        out.writeInt(0);

    // Log Manager and log params
    writeUTF(out, m_logManager);
    writeUTF(out, m_profile);
    if (m_logParams != null) {
        int length = m_logParams.size();

        out.writeInt(length);

        Enumeration logParams = m_logParams.elements();

        while (logParams.hasMoreElements()) {
            Param logParam = (Param) logParams.nextElement();

            logParam.toStream(out, versionNo);
        }
    } else
        out.writeInt(0);

    //  Event Parameters.
    writeUTF(out, m_eventDeliveryMode);
    out.writeLong(m_eventExpiryTime);
    out.writeInt(m_eventHandler);

}