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:com.openlapi.AddressInfo.java

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int attributeCount = in.read();

    if (attributeCount > 0) {

        String[] attributes = StringUtils.split(in.readUTF(), ",");

        for (int i = 0; i < attributeCount; i++) {
            int attribute = Integer.valueOf(attributes[i]);
            setField(attribute + 1, in.readUTF());
        }/*from   w ww . j a  va 2  s  .  co  m*/
    }
}

From source file:org.knime.al.util.noveltydetection.knfst.KNFST.java

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

    try {/*  w  ww. j ava2  s.  c  o  m*/
        // read kernel
        m_kernel = (KernelCalculator) Class.forName(arg0.readUTF()).newInstance();
        m_kernel.readExternal(arg0);

        // read projection
        // rows
        final int rowsProj = arg0.readInt();
        // columns
        final int colsProj = arg0.readInt();
        // data
        final double[][] projData = new double[rowsProj][colsProj];
        for (int r = 0; r < rowsProj; r++) {
            for (int c = 0; c < colsProj; c++) {
                projData[r][c] = arg0.readDouble();
            }
        }
        // Matrix construction
        m_projection = MatrixUtils.createRealMatrix(projData);

        // read targetPoints
        // rows
        final int rowsTar = arg0.readInt();
        // columns
        final int colsTar = arg0.readInt();
        // data
        final double[][] tarData = new double[rowsTar][colsTar];
        for (int r = 0; r < rowsTar; r++) {
            for (int c = 0; c < colsTar; c++) {
                tarData[r][c] = arg0.readDouble();
            }
        }
        // Matrix construction
        m_targetPoints = MatrixUtils.createRealMatrix(tarData);

        // read betweenClassDistances
        final double[] betweenClassDistances = new double[arg0.readInt()];
        for (int i = 0; i < betweenClassDistances.length; i++) {
            betweenClassDistances[i] = arg0.readDouble();
        }
        m_betweenClassDistances = betweenClassDistances;

    } catch (InstantiationException | IllegalAccessException e) {
        throw new IOException(e);
    }
}

From source file:com.splicemachine.derby.stream.function.RowAndIndexGenerator.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    heapConglom = in.readLong();/*from  w ww. j  a v a 2s. com*/
    if (in.readBoolean())
        operationContext = (OperationContext) in.readObject();
    txn = SIDriver.driver().getOperationFactory().readTxn(in);
    pkCols = ArrayUtil.readIntArray(in);
    tableVersion = in.readUTF();
    execRowDefinition = (ExecRow) in.readObject();
    autoIncrementRowLocationArray = new RowLocation[in.readInt()];
    for (int i = 0; i < autoIncrementRowLocationArray.length; i++)
        autoIncrementRowLocationArray[i] = (RowLocation) in.readObject();
    spliceSequences = new SpliceSequence[in.readInt()];
    for (int i = 0; i < spliceSequences.length; i++)
        spliceSequences[i] = (SpliceSequence) in.readObject();
    heapConglom = in.readLong();
    int iSize = in.readInt();
    tentativeIndices = new ArrayList<>(iSize);
    for (int i = 0; i < iSize; i++) {
        byte[] message = new byte[in.readInt()];
        in.readFully(message);
        tentativeIndices.add(DDLMessage.TentativeIndex.parseFrom(message));
    }
}

From source file:org.knime.al.util.noveltydetection.kernel.KernelCalculator.java

/************ Externalizable methods *****************/
@Override/*from  w w w . j av a2  s . c o  m*/
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    try {
        // read kernelFunction
        m_kernelFunction = (KernelFunction) Class.forName(in.readUTF()).newInstance();
        m_kernelFunction.readExternal(in);

        // read trainingData
        // rows
        m_rowCount = in.readInt();
        // columns
        m_colCount = in.readInt();
        // data
        m_trainingData = new double[m_rowCount][m_colCount];
        for (int r = 0; r < m_rowCount; r++) {
            for (int c = 0; c < m_colCount; c++) {
                m_trainingData[r][c] = in.readDouble();
            }
        }

    } catch (InstantiationException | IllegalAccessException e) {
        throw new IOException(e);
    }

}

From source file:com.akop.bach.util.SerializableCookie.java

public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    nullMask = in.readInt();/*  w  ww.  ja  v a  2 s .c  om*/

    String name = null;
    String value = null;
    String comment = null;
    //String commentURL = null;
    Date expiryDate = null;
    //boolean isPersistent = false;
    String domain = null;
    String path = null;
    int[] ports = null;
    boolean isSecure = false;
    int version = 0;

    if ((nullMask & NAME) == 0)
        name = in.readUTF();

    if ((nullMask & VALUE) == 0)
        value = in.readUTF();

    if ((nullMask & COMMENT) == 0)
        comment = in.readUTF();

    if ((nullMask & COMMENT_URL) == 0)
        //commentURL =
        in.readUTF();

    if ((nullMask & EXPIRY_DATE) == 0)
        expiryDate = new Date(in.readLong());

    //isPersistent = 
    in.readBoolean();

    if ((nullMask & DOMAIN) == 0)
        domain = in.readUTF();

    if ((nullMask & PATH) == 0)
        path = in.readUTF();

    if ((nullMask & PORTS) == 0) {
        final int len = in.readInt();
        if (len < 10) {
            ports = new int[len];
            for (int i = 0; i < len; i++)
                ports[i] = in.readInt();
        }
    }

    isSecure = in.readBoolean();
    version = in.readInt();

    final BasicClientCookie bc = new BasicClientCookie(name, value);
    bc.setComment(comment);
    bc.setDomain(domain);
    bc.setExpiryDate(expiryDate);
    bc.setPath(path);
    bc.setSecure(isSecure);
    bc.setVersion(version);

    this.cookie = bc;
}

From source file:com.splicemachine.derby.stream.output.update.UpdateTableWriterBuilder.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    if (in.readBoolean())
        operationContext = (OperationContext) in.readObject();
    heapConglom = in.readLong();//w  w  w.j  a  va  2  s. co m
    formatIds = ArrayUtil.readIntArray(in);
    columnOrdering = ArrayUtil.readIntArray(in);
    if (columnOrdering == null)
        columnOrdering = new int[] {};
    pkCols = ArrayUtil.readIntArray(in);
    if (pkCols == null)
        pkCols = new int[0];

    pkColumns = (FormatableBitSet) in.readObject();
    heapList = (FormatableBitSet) in.readObject();
    tableVersion = in.readUTF();
    txn = SIDriver.driver().getOperationFactory().readTxn(in);
    execRowTypeFormatIds = ArrayUtil.readIntArray(in);
    execRowDefinition = WriteReadUtils.getExecRowFromTypeFormatIds(execRowTypeFormatIds);
}

From source file:org.chiba.xml.xforms.ChibaBean.java

/**
 * reads serialized host document from ObjectInputStream and parses the resulting String
 * to a DOM Document. After that the host document is passed to the processor. init() is NOT yet
 * called on the processor to allow an using application to do its own configuration work (like
 * setting of baseURI and passing of context params).
 *
 * todo: rethink the question of the baseURI - is this still necessary when deaserializing? Presumably yes to further allow dynamic resolution.
 * @param objectInput//from   ww w. ja  va 2 s  . c  o  m
 * @throws IOException
 * @throws ClassNotFoundException
 */
public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("deserializing XForms host document");
    }
    String read = objectInput.readUTF();
    Document host = null;
    try {
        host = DOMUtil.parseString(read, true, false);
        setXMLContainer(host.getDocumentElement());
    } catch (ParserConfigurationException e) {
        throw new IOException("Parser misconfigured: " + e.getMessage());
    } catch (SAXException e) {
        throw new IOException("Parsing failed: " + e.getMessage());
    } catch (XFormsException e) {
        throw new IOException("An XForms error occurred when passing the host document: " + e.getMessage());
    }

}

From source file:de.betterform.xml.xforms.XFormsProcessorImpl.java

/**
 * reads serialized host document from ObjectInputStream and parses the resulting String
 * to a DOM Document. After that the host document is passed to the processor. init() is NOT yet
 * called on the processor to allow an using application to do its own configuration work (like
 * setting of baseURI and passing of context params).
 *
 * todo: rethink the question of the baseURI - is this still necessary when deaserializing? Presumably yes to further allow dynamic resolution.
 * @param objectInput//from ww w  . jav  a 2 s .com
 * @throws IOException
 * @throws ClassNotFoundException
 */
public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("deserializing XForms host document");
    }
    String read = objectInput.readUTF();
    Document host = null;
    try {
        host = DOMUtil.parseString(read, true, false);
        String baseURI = host.getDocumentElement().getAttribute("bf:baseURI");
        setContextParam("betterform.baseURI", baseURI);
        setBaseURI(baseURI);
        setXForms(host.getDocumentElement());
    } catch (ParserConfigurationException e) {
        throw new IOException("Parser misconfigured: " + e.getMessage());
    } catch (SAXException e) {
        throw new IOException("Parsing failed: " + e.getMessage());
    } catch (XFormsException e) {
        throw new IOException("An XForms error occurred when passing the host document: " + e.getMessage());
    }
}

From source file:com.weibo.api.motan.protocol.rpc.CompressRpcCodec.java

private Object decodeRequest(byte[] body, long requestId, String remoteIp, Serialization serialization)
        throws IOException, ClassNotFoundException {

    ObjectInput input = createInput(getInputStream(body));
    String interfaceName = null;/*w  w  w .  j a  v a 2 s.  co m*/
    String methodName = null;
    String paramtersDesc = null;
    String group = null;
    String version = null;

    String flag = input.readUTF();

    if (SIGN_FLAG.equals(flag)) {// ???
        String sign = input.readUTF();
        MethodInfo mInfo = SIGN_METHOD_MAP.get(sign);
        if (mInfo == null) {
            throw new MotanFrameworkException("decode error: invalid method sign: " + sign,
                    MotanErrorMsgConstant.FRAMEWORK_DECODE_ERROR);
        }
        interfaceName = mInfo.getInterfaceName();
        methodName = mInfo.getMethodName();
        paramtersDesc = mInfo.getParamtersDesc();
        group = mInfo.getGroup();
        version = mInfo.getVersion();
    } else {
        interfaceName = flag;
        methodName = input.readUTF();
        paramtersDesc = input.readUTF();
    }

    DefaultRequest rpcRequest = new DefaultRequest();
    rpcRequest.setRequestId(requestId);
    rpcRequest.setInterfaceName(interfaceName);
    rpcRequest.setMethodName(methodName);
    rpcRequest.setParamtersDesc(paramtersDesc);
    rpcRequest.setArguments(decodeRequestParameter(input, paramtersDesc, serialization));
    rpcRequest.setAttachments(decodeRequestAttachments(input));
    rpcRequest.setRpcProtocolVersion(RpcProtocolVersion.VERSION_2.getVersion());

    input.close();
    Map<String, String> attachments = rpcRequest.getAttachments();
    putSignedAttachment(attachments, remoteIp);// ???client?
    if (attachments.get(URLParamType.group.name()) == null) {
        // attachment sign?methodsigngroup?
        attachments.put(URLParamType.group.name(), group);
        attachments.put(URLParamType.version.name(), version);
    }

    return rpcRequest;
}

From source file:com.weibo.api.motan.protocol.rpc.CompressRpcCodec.java

private Map<String, String> decodeRequestAttachments(ObjectInput input)
        throws IOException, ClassNotFoundException {
    int size = input.readShort();

    if (size <= 0) {
        return null;
    }//w  ww .  java2s  .c o  m

    Map<String, String> attachments = new HashMap<String, String>();

    for (int i = 0; i < size; i++) {
        attachments.put(input.readUTF(), input.readUTF());
    }

    return attachments;
}