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.axis2.context.externalize.MessageExternalizeUtils.java

/**
 * Write out the Message/*  w ww . jav  a 2s  .  co  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:com.delphix.session.impl.frame.SessionHandle.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(handle.length);
    out.write(handle);/*from  w  ww . j a v a  2  s. c  o m*/
}

From source file:MainClass.java

public void writeExternal(ObjectOutput out) throws IOException {
    System.out.println("MyBean.writeExternal");
    out.writeObject(s);//from  www. java  2 s . co  m
    out.writeInt(i);
}

From source file:com.delphix.session.impl.frame.ExchangeID.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(xid);
}

From source file:gridool.dht.ops.AddGridNodeOperation.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(keys.length);
    for (byte[] k : keys) {
        IOUtils.writeBytes(k, out);//from  ww  w. j a v a 2s.c o m
    }
    node.writeExternal(out);
}

From source file:org.codehaus.wadi.core.session.LazyAttributes.java

public synchronized void writeExternal(ObjectOutput oo) throws IOException {
    bytes = serialise();/*w ww . j  a v a 2s  . com*/
    oo.writeInt(bytes.length);
    oo.write(bytes);
}

From source file:Blip3.java

public void writeExternal(ObjectOutput out) throws IOException {
    System.out.println("Blip3.writeExternal");
    // You must do this:
    out.writeObject(s);/* ww w.  j  a  v a 2  s  .c o m*/
    out.writeInt(i);
}

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

protected void writeStringArray(ObjectOutput out, String[] array) throws IOException {
    out.writeInt(array.length);

    for (String element : array) {
        out.writeUTF(element);//from  w  ww. j  av  a2s . c o m
    }
}

From source file:org.drools.CheeseEqual.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(type);
    out.writeInt(price);
}

From source file:bftsmart.consensus.TimestampValuePair.java

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

    out.writeInt(timestamp);
    out.writeObject(value);//from   w  w  w  . j a  v  a2  s  . c o  m
}