Example usage for java.io ObjectOutput writeUTF

List of usage examples for java.io ObjectOutput writeUTF

Introduction

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

Prototype

void writeUTF(String s) throws IOException;

Source Link

Document

Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in the string s.

Usage

From source file:org.apache.axis2.context.externalize.MessageExternalizeUtils.java

/**
 * Write out the Message//from   w  w  w .  j a  v  a 2  s .c  o  m
 * @param out
 * @param mc
 * @param correlationIDString
 * @param outputFormat
 * @throws IOException
 */
public static void writeExternal(ObjectOutput out, MessageContext mc, String correlationIDString,
        OMOutputFormat outputFormat) throws IOException {
    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":writeExternal(): start");
    }
    SOAPEnvelope envelope = mc.getEnvelope();
    if (envelope == null) {
        // Case: No envelope
        out.writeUTF("NULL_ENVELOPE");
        out.writeInt(revisionID);
        out.writeBoolean(EMPTY_OBJECT); // Not Active
        out.writeInt(0); // EndBlocks
        if (log.isDebugEnabled()) {
            log.debug(correlationIDString + ":writeExternal(): end: msg is Empty");
        }
        return;
    }

    // Write Prolog
    String msgClass = envelope.getClass().getName();
    out.writeUTF(msgClass);
    out.writeInt(revisionID);
    out.writeBoolean(ACTIVE_OBJECT);
    if (outputFormat.isOptimized()) {
        out.writeBoolean(true);
        // Write out the contentType.
        out.writeUTF(outputFormat.getContentType());
    } else {
        out.writeBoolean(false);
    }
    out.writeUTF(outputFormat.getCharSetEncoding());
    out.writeUTF(envelope.getNamespace().getNamespaceURI());
    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":writeExternal(): " + "optimized=[" + outputFormat.isOptimized()
                + "]  " + "optimizedContentType " + outputFormat.getContentType() + "]  " + "charSetEnc=["
                + outputFormat.getCharSetEncoding() + "]  " + "namespaceURI=["
                + envelope.getNamespace().getNamespaceURI() + "]");
    }

    // Write DataBlocks
    // MessageOutputStream writes out the DataBlocks in chunks
    // BufferedOutputStream buffers the data to prevent numerous, small blocks
    MessageOutputStream mos = new MessageOutputStream(out);
    BufferedOutputStream bos = new BufferedOutputStream(mos);
    boolean errorOccurred = false;
    try {
        // Write out the message using the same logic as the 
        // transport layer.
        MessageFormatter msgFormatter = MessageProcessorSelector.getMessageFormatter(mc);
        msgFormatter.writeTo(mc, outputFormat, bos, true); // Preserve the original message

    } catch (IOException e) {
        throw e;
    } catch (Throwable t) {
        throw AxisFault.makeFault(t);
    } finally {
        bos.flush();
        bos.close();
    }

    // Write End of Data Blocks
    if (errorOccurred) {
        out.writeInt(-1);
    } else {
        out.writeInt(0);
    }
    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":writeExternal(): end");
    }
}

From source file:PersonExt.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.name);
    out.writeUTF(this.gender);
}

From source file:com.talis.storage.s3.ExternalizableS3Object.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(getKey());
    out.writeUTF(getBucketName());/*w  ww . j a  v  a 2s  . c  om*/
    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:com.enonic.cms.core.portal.instruction.PostProcessInstruction.java

protected void writeString(ObjectOutput out, String value) throws IOException {
    out.writeUTF(value);
}

From source file:com.delphix.session.service.ServiceName.java

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

    out.writeUTF(name);
    out.writeBoolean(ephemeral);/*from w  w  w .  j  a va  2 s .co m*/
}

From source file:com.splicemachine.derby.stream.spark.SparkExportDataSetWriter.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(directory);
    out.writeObject(exportFunction);//from  ww w . j ava2 s  . com
    out.writeObject(rdd);
}

From source file:com.splicemachine.derby.stream.spark.SparkScanSetBuilder.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    out.writeUTF(tableName);
    out.writeObject(dsp);/*from   www.j a  va  2s.co m*/
}

From source file:com.delphix.session.service.ServiceUUID.java

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

    out.writeUTF(uuid.toString());

    if (alias != null) {
        out.writeBoolean(true);//w  w  w . j a  v  a2s . co m
        out.writeUTF(alias);
    } else {
        out.writeBoolean(false);
    }

    out.writeBoolean(ephemeral);
}

From source file:com.enonic.cms.core.portal.instruction.PostProcessInstruction.java

protected void writeStringArray(ObjectOutput out, String[] array) throws IOException {
    out.writeInt(array.length);/*w ww.  jav  a  2  s. c  o  m*/

    for (String element : array) {
        out.writeUTF(element);
    }
}

From source file:edu.wustl.cab2b.admin.flex.DAGNode.java

/**
 * It serializes DAGNode for communication with flex client
 * /*w  ww  .j a v  a  2s. c  om*/
 * @param out
 * @throws IOException
 */

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(nodeName);
    out.writeUTF(toolTip);
    out.writeInt((int) nodeId);
    out.writeUTF(operatorBetweenAttrAndAssociation);
    out.writeUTF(nodeType);
    out.writeObject(associationList);
    out.writeObject(operatorList);
    out.writeObject(dagpathList);
    out.writeUTF(errorMsg);
    out.writeInt(xCordinate);
    out.writeInt(yCordinate);
    out.writeInt((int) entityId);
    out.writeObject(attributesList);
}