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:com.inmobi.grill.driver.hive.HiveDriver.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    // Write the query handle to hive handle map to output
    synchronized (hiveHandles) {
        out.writeInt(hiveHandles.size());
        for (Map.Entry<QueryHandle, OperationHandle> entry : hiveHandles.entrySet()) {
            out.writeObject(entry.getKey());
            out.writeObject(entry.getValue().toTOperationHandle());
            LOG.debug("Hive driver persisted " + entry.getKey() + ":" + entry.getValue());
        }/* ww w .j a va 2  s  . co m*/
        LOG.info("HiveDriver persisted " + hiveHandles.size() + " queries");
        out.writeInt(grillToHiveSession.size());
        for (Map.Entry<String, SessionHandle> entry : grillToHiveSession.entrySet()) {
            out.writeUTF(entry.getKey());
            out.writeObject(entry.getValue().toTSessionHandle());
        }
        LOG.info("HiveDriver persisted " + grillToHiveSession.size() + " sessions");
    }
}

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

public void writeExternal(ObjectOutput objectOutput) throws IOException {
    DefaultSerializer serializer = new DefaultSerializer(this);
    Document serializedForm = serializer.serialize();

    StringWriter stringWriter = new StringWriter();
    Transformer transformer = null;
    StreamResult result = new StreamResult(stringWriter);
    try {/*w w w.ja va2s .c  o  m*/
        transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
        transformer.transform(new DOMSource(serializedForm), result);
    } catch (TransformerConfigurationException e) {
        throw new IOException("TransformerConfiguration invalid: " + e.getMessage());
    } catch (TransformerException e) {
        throw new IOException("Error during serialization transform: " + e.getMessage());
    }
    objectOutput.writeUTF(stringWriter.getBuffer().toString());
    objectOutput.flush();
    objectOutput.close();

}

From source file:com.splicemachine.derby.impl.sql.execute.operations.scanner.TableScannerBuilder.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(template);//from w  w w . ja va 2 s .c  o  m
    writeScan(out);
    out.writeBoolean(rowColumnMap != null);
    if (rowColumnMap != null) {
        out.writeInt(rowColumnMap.length);
        //noinspection ForLoopReplaceableByForEach
        for (int i = 0; i < rowColumnMap.length; ++i) {
            out.writeInt(rowColumnMap[i]);
        }
    }
    writeTxn(out);
    ArrayUtil.writeIntArray(out, keyColumnEncodingOrder);
    out.writeBoolean(keyColumnSortOrder != null);
    if (keyColumnSortOrder != null) {
        ArrayUtil.writeBooleanArray(out, keyColumnSortOrder);
    }
    ArrayUtil.writeIntArray(out, keyColumnTypes);
    out.writeBoolean(keyDecodingMap != null);
    if (keyDecodingMap != null) {
        ArrayUtil.writeIntArray(out, keyDecodingMap);
    }
    out.writeBoolean(baseColumnMap != null);
    if (baseColumnMap != null) {
        ArrayUtil.writeIntArray(out, baseColumnMap);
    }
    out.writeObject(accessedKeys);
    out.writeBoolean(reuseRowLocation);
    out.writeBoolean(oneSplitPerRegion);
    out.writeBoolean(indexName != null);
    if (indexName != null)
        out.writeUTF(indexName);
    out.writeBoolean(tableVersion != null);
    if (tableVersion != null)
        out.writeUTF(tableVersion);

    out.writeBoolean(fieldLengths != null);
    if (fieldLengths != null) {
        out.writeInt(fieldLengths.length);
        //noinspection ForLoopReplaceableByForEach
        for (int i = 0; i < fieldLengths.length; ++i) {
            out.writeInt(fieldLengths[i]);
        }
        out.writeInt(columnPositionMap.length);
        //noinspection ForLoopReplaceableByForEach
        for (int i = 0; i < columnPositionMap.length; ++i) {
            out.writeInt(columnPositionMap[i]);
        }
        out.writeLong(baseTableConglomId);
    }
    out.writeLong(demarcationPoint);
    out.writeBoolean(optionalProbeValue != null);
    if (optionalProbeValue != null)
        out.writeObject(optionalProbeValue);
    out.writeBoolean(pin);
    writeNullableString(delimited, out);
    writeNullableString(escaped, out);
    writeNullableString(lines, out);
    writeNullableString(storedAs, out);
    writeNullableString(location, out);
}

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

/**
 * ???//  ww  w .ja  va  2 s . co m
 * 
 * @param output
 * @param request
 * @throws IOException
 */
private void addMethodInfo(ObjectOutput output, Request request) throws IOException {
    String methodInfoStr = MotanFrameworkUtil.getServiceKey(request) + request.getMethodName()
            + request.getParamtersDesc();
    String methodSign = METHOD_SIGN_MAP.get(methodInfoStr);
    if (methodSign == null) {
        MethodInfo temp = new MethodInfo(MotanFrameworkUtil.getGroupFromRequest(request),
                request.getInterfaceName(), request.getMethodName(), request.getParamtersDesc(),
                MotanFrameworkUtil.getVersionFromRequest(request));
        try {
            methodSign = temp.getSign();
            METHOD_SIGN_MAP.putIfAbsent(methodInfoStr, methodSign);
            LoggerUtil.info("add method sign:" + methodSign + ", methodinfo:" + temp.toString());
        } catch (Exception e) {
            LoggerUtil.warn("gen method sign fail!" + e.getMessage());
        }

    }
    if (methodSign != null) {
        output.writeUTF(SIGN_FLAG);// ??
        output.writeUTF(methodSign);
    } else {// ?????
        output.writeUTF(request.getInterfaceName());
        output.writeUTF(request.getMethodName());
        output.writeUTF(request.getParamtersDesc());
    }

}

From source file:org.apache.tapestry.engine.AbstractEngine.java

/**
 *  Writes the following properties://from ww  w  .  ja v a  2  s . c o  m
 *
 *  <ul>
 *  <li>locale name ({@link Locale#toString()})
 *  <li>visit
 *  </ul>
 *
 **/

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(_locale.toString());
    out.writeObject(_visit);
}

From source file:org.apache.lens.driver.hive.HiveDriver.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    // Write the query handle to hive handle map to output
    synchronized (hiveHandles) {
        out.writeInt(hiveHandles.size());
        for (Map.Entry<QueryHandle, OperationHandle> entry : hiveHandles.entrySet()) {
            out.writeObject(entry.getKey());
            out.writeObject(entry.getValue().toTOperationHandle());
            log.debug("Hive driver {} persisted {}:{}", getFullyQualifiedName(), entry.getKey(),
                    entry.getValue());//from   w w w  .  jav  a 2 s . c o m
        }
        log.info("Hive driver {} persisted {} queries ", getFullyQualifiedName(), hiveHandles.size());
        out.writeInt(lensToHiveSession.size());
        for (Map.Entry<String, SessionHandle> entry : lensToHiveSession.entrySet()) {
            out.writeUTF(entry.getKey());
            out.writeObject(entry.getValue().toTSessionHandle());
        }
        log.info("Hive driver {} persisted {} sessions", getFullyQualifiedName(), lensToHiveSession.size());
        out.writeInt(opHandleToSession.size());
        for (Map.Entry<OperationHandle, SessionHandle> entry : opHandleToSession.entrySet()) {
            out.writeObject(entry.getKey().toTOperationHandle());
            out.writeObject(entry.getValue().toTSessionHandle());
        }
        log.info("Hive driver {} persisted {} operation handles", getFullyQualifiedName(),
                opHandleToSession.size());
        out.writeInt(orphanedHiveSessions.size());
        for (SessionHandle sessionHandle : orphanedHiveSessions) {
            out.writeObject(sessionHandle.toTSessionHandle());
        }
        log.info("Hive driver {} persisted {} orphaned sessions", getFullyQualifiedName(),
                orphanedHiveSessions.size());
    }
}

From source file:org.codehaus.groovy.grails.web.util.StreamCharBuffer.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(EXTERNALIZABLE_VERSION);
    StringChunk stringChunk = readToSingleStringChunk(false);
    if (stringChunk != null && stringChunk.str.length() > 0) {
        char[] buf = StringCharArrayAccessor.getValue(stringChunk.str);
        out.writeInt(buf.length);//from w  ww  .j av a2s.  co m
        Writer writer = new OutputStreamWriter((OutputStream) out, "UTF-8");
        writer.write(buf);
        writer.flush();
        if (stringChunk instanceof MultipartStringChunk) {
            MultipartStringChunk mpStringChunk = (MultipartStringChunk) stringChunk;
            out.writeInt(mpStringChunk.partCount());
            EncodingStatePart current = mpStringChunk.firstPart;
            while (current != null) {
                out.writeInt(current.len);
                if (current.encodingState != null && current.encodingState.getEncoders() != null
                        && current.encodingState.getEncoders().size() > 0) {
                    out.writeInt(current.encodingState.getEncoders().size());
                    for (Encoder encoder : current.encodingState.getEncoders()) {
                        out.writeUTF(encoder.getCodecIdentifier().getCodecName());
                        out.writeBoolean(encoder.isSafe());
                    }
                } else {
                    out.writeInt(0);
                }
                current = current.next;
            }
        } else {
            out.writeInt(0);
        }
    } else {
        out.writeInt(0);
    }
}

From source file:org.apache.lens.server.query.QueryExecutionServiceImpl.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    // persist all drivers
    synchronized (drivers) {
        out.writeInt(drivers.size());//w w  w . jav a2s.  c  o  m
        LensDriver driver = null;
        for (Map.Entry<String, LensDriver> driverEntry : drivers.entrySet()) {
            driver = driverEntry.getValue();
            synchronized (driver) {
                out.writeUTF(driverEntry.getKey());
                out.writeUTF(driver.getClass().getName());
                driver.writeExternal(out);
            }
        }
    }
    // persist allQueries
    synchronized (allQueries) {
        out.writeInt(allQueries.size());
        for (QueryContext ctx : allQueries.values()) {
            synchronized (ctx) {
                out.writeObject(ctx);
                boolean isDriverAvailable = (ctx.getSelectedDriver() != null);
                out.writeBoolean(isDriverAvailable);
                if (isDriverAvailable) {
                    out.writeUTF(ctx.getSelectedDriver().getFullyQualifiedName());
                }
            }
        }
        log.info("Persisted {} queries", allQueries.size());
    }
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

@Override
public void writeExternal(ObjectOutput output) throws IOException {
    output.writeLong(serialVersionUID);//w  ww .  ja  v a2  s . co  m
    output.writeInt(progressVisible);
    output.writeUTF(progressCancelBtnText);
    output.writeUTF(progressMsgText);
    output.writeInt(lclPos);
    output.writeInt(lclPosTop);
    output.writeInt(profPos);
    output.writeInt(profPosTop);
    output.writeInt(remPos);
    output.writeInt(remPosTop);
    output.writeInt(dialogVisible);
    output.writeUTF(dialogMsgText);

}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

@Override
public void writeExternal(ObjectOutput objout) throws IOException {
    //      Log.v("","wr");
    objout.writeLong(serialVersionUID);//from  w  w w  .  j  a  v  a 2s. c o  m
    SerializeUtil.writeArrayList(objout, paste_list);
    SerializeUtil.writeUtf(objout, paste_from_url);
    SerializeUtil.writeUtf(objout, paste_to_url);
    SerializeUtil.writeUtf(objout, paste_item_list);

    objout.writeBoolean(is_paste_copy);
    objout.writeBoolean(is_paste_enabled);
    objout.writeBoolean(is_paste_from_local);

    SerializeUtil.writeArrayList(objout, local_dir_hist);
    SerializeUtil.writeArrayList(objout, remote_dir_hist);

    SerializeUtil.writeArrayList(objout, remote_file_list_cache);
    objout.writeObject(remote_curr_file_list);
    SerializeUtil.writeArrayList(objout, local_file_list_cache);
    objout.writeObject(local_curr_file_list);
    vsa.writeExternal(objout);
    objout.writeUTF(dialog_msg_cat);

    SerializeUtil.writeUtf(objout, remoteBase);
    SerializeUtil.writeUtf(objout, localBase);
    SerializeUtil.writeUtf(objout, remoteDir);
    SerializeUtil.writeUtf(objout, localDir);
    SerializeUtil.writeUtf(objout, currentTabName);
    SerializeUtil.writeUtf(objout, smbUser);
    SerializeUtil.writeUtf(objout, smbPass);

    objout.writeBoolean(localUpButtonEnabled);
    objout.writeBoolean(localTopButtonEnabled);
    objout.writeBoolean(remoteUpButtonEnabled);
    objout.writeBoolean(remoteTopButtonEnabled);
}