Example usage for java.io ObjectInput readUTF

List of usage examples for java.io ObjectInput readUTF

Introduction

In this page you can find the example usage for java.io ObjectInput readUTF.

Prototype

String readUTF() throws IOException;

Source Link

Document

Reads in a string that has been encoded using a modified UTF-8 format.

Usage

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

/**
 * Read the Message// w  w w .  j ava  2  s .  co  m
 * @param in
 * @param mc
 * @param correlationIDString
 * @return
 * @throws IOException
 */
public static SOAPEnvelope readExternal(ObjectInput in, MessageContext mc, String correlationIDString)
        throws IOException, ClassNotFoundException {
    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":readExternal(): start");
    }
    SOAPEnvelope envelope = null;

    // Read Prolog
    // Read the class name and object state
    String name = in.readUTF();
    int revision = in.readInt();

    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":readExternal(): name= " + name + " revision= " + revision);
    }
    // make sure the object data is in a revision level we can handle
    if (revision != REVISION_2) {
        throw new ClassNotFoundException(ExternalizeConstants.UNSUPPORTED_REVID);
    }

    boolean gotMsg = in.readBoolean();
    if (gotMsg != ACTIVE_OBJECT) {
        if (log.isDebugEnabled()) {
            log.debug(correlationIDString + ":readExternal(): end:" + "no message present");
        }
        in.readInt(); // Read end of data blocks
        return envelope;
    }

    // Read optimized, optimized content-type, charset encoding and namespace uri
    boolean optimized = in.readBoolean();
    String optimizedContentType = null;
    if (optimized) {
        optimizedContentType = in.readUTF();
    }
    String charSetEnc = in.readUTF();
    String namespaceURI = in.readUTF();
    if (log.isDebugEnabled()) {
        log.debug(correlationIDString + ":readExternal(): " + "optimized=[" + optimized + "]  "
                + "optimizedContentType=[" + optimizedContentType + "]  " + "charSetEnc=[" + charSetEnc + "]  "
                + "namespaceURI=[" + namespaceURI + "]");
    }

    MessageInputStream mis = new MessageInputStream(in);
    StAXBuilder builder = null;
    try {
        if (optimized) {
            boolean isSOAP = true;
            builder = BuilderUtil.getAttachmentsBuilder(mc, mis, optimizedContentType, isSOAP);
            envelope = (SOAPEnvelope) builder.getDocumentElement();
            envelope.buildWithAttachments();
        } else {
            XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(mis, charSetEnc);
            builder = new StAXSOAPModelBuilder(xmlreader, namespaceURI);
            envelope = (SOAPEnvelope) builder.getDocumentElement();
            envelope.build();
        }
    } catch (Exception ex) {
        // TODO: what to do if can't get the XML stream reader
        // For now, log the event
        log.error(correlationIDString + ":readExternal(): Error when deserializing persisted envelope: ["
                + ex.getClass().getName() + " : " + ex.getLocalizedMessage() + "]", ex);
        envelope = null;
    } finally {
        if (builder != null) {
            builder.close();
        }
        // Close the message input stream.  This will ensure that the
        // underlying stream is advanced past the message.
        mis.close();
        if (log.isDebugEnabled()) {
            log.debug(correlationIDString + ":readExternal(): end");
        }
    }
    return envelope;
}

From source file:PersonExt.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.name = in.readUTF();
    this.gender = in.readUTF();
}

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

protected String readString(ObjectInput in) throws IOException {
    return in.readUTF();
}

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

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    this.setKey(in.readUTF());
    this.setBucketName(in.readUTF());
    this.setAcl((AccessControlList) in.readObject());
    this.setMetadataComplete(in.readBoolean());
    this.addAllMetadata((Map) in.readObject());
    int length = in.readInt();
    byte[] entity = new byte[length];
    in.readFully(entity);//from   w w w . j ava 2s. c om
    this.setDataInputStream(new ByteArrayInputStream(entity));
}

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

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    name = in.readUTF();
    ephemeral = in.readBoolean();//from w  ww .  j a  v a 2 s .  c  o m
}

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

@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    directory = in.readUTF();
    exportFunction = (SpliceFunction2) in.readObject();
    rdd = (JavaRDD) in.readObject();/*from w  ww . j  a  va2 s.  com*/
}

From source file:org.spearce.jgit.transport.RemoteConfig.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    name = in.readUTF();
    final int items = in.readInt();
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    for (int i = 0; i < items; i++) {
        String key = in.readUTF();
        String value = in.readUTF();
        List<String> values = map.get(key);
        if (null == values) {
            values = new ArrayList<String>();
            map.put(key, values);/*  w ww  .ja v  a 2  s . c o m*/
        }
        values.add(value);
    }
    fromMap(map);
}

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

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);
    this.tableName = in.readUTF();
    this.dsp = (SparkDataSetProcessor) in.readObject();
}

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

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    uuid = UUID.fromString(in.readUTF());

    if (in.readBoolean()) {
        alias = in.readUTF();/*from   w w w  .jav a 2 s  .c  o m*/
    }

    ephemeral = in.readBoolean();
}

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

protected String[] readStringArray(ObjectInput in) throws IOException {
    String[] array = new String[in.readInt()];

    for (int i = 0; i < array.length; i++) {
        array[i] = in.readUTF();
    }/*from  w ww .j  av  a  2  s. c  om*/

    return array;
}