List of usage examples for java.io ObjectOutput writeUTF
void writeUTF(String s) throws IOException;
s
. From source file:org.apache.tapestry.engine.BaseEngine.java
/** * Writes the engine's persistent state; this is simply the list of active page * names. For efficiency, this is written as a count followed by each name * as a UTF String.// ww w . ja v a 2 s .co m * **/ public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); if (Tapestry.isEmpty(_activePageNames)) { out.writeInt(0); return; } int count = _activePageNames.size(); out.writeInt(count); Iterator i = _activePageNames.iterator(); while (i.hasNext()) { String name = (String) i.next(); out.writeUTF(name); } }
From source file:com.splicemachine.derby.stream.function.RowAndIndexGenerator.java
@Override public void writeExternal(ObjectOutput out) throws IOException { try {//from ww w.ja v a 2s. co m out.writeLong(heapConglom); out.writeBoolean(operationContext != null); if (operationContext != null) out.writeObject(operationContext); SIDriver.driver().getOperationFactory().writeTxn(txn, out); ArrayUtil.writeIntArray(out, pkCols); out.writeUTF(tableVersion); out.writeObject(execRowDefinition); out.writeInt(autoIncrementRowLocationArray.length); for (int i = 0; i < autoIncrementRowLocationArray.length; i++) out.writeObject(autoIncrementRowLocationArray[i]); out.writeInt(spliceSequences.length); for (int i = 0; i < spliceSequences.length; i++) { out.writeObject(spliceSequences[i]); } out.writeLong(heapConglom); out.writeInt(tentativeIndices.size()); for (DDLMessage.TentativeIndex ti : tentativeIndices) { byte[] message = ti.toByteArray(); out.writeInt(message.length); out.write(message); } } catch (Exception e) { throw new IOException(e); } }
From source file:com.splicemachine.derby.stream.output.update.UpdateTableWriterBuilder.java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(operationContext != null); if (operationContext != null) out.writeObject(operationContext); out.writeLong(heapConglom);//from w w w.j av a 2 s .c om ArrayUtil.writeIntArray(out, formatIds); ArrayUtil.writeIntArray(out, columnOrdering); ArrayUtil.writeIntArray(out, pkCols); out.writeObject(pkColumns); out.writeObject(heapList); out.writeUTF(tableVersion); SIDriver.driver().getOperationFactory().writeTxn(txn, out); ArrayUtil.writeIntArray(out, execRowTypeFormatIds); }
From source file:com.splicemachine.derby.impl.sql.execute.operations.scanner.TableScannerBuilder.java
private void writeNullableString(String nullableString, ObjectOutput out) throws IOException { out.writeBoolean(nullableString != null); if (nullableString != null) out.writeUTF(nullableString); }
From source file:com.akop.bach.util.SerializableCookie.java
public void writeExternal(final ObjectOutput out) throws IOException { nullMask |= (getName() == null) ? NAME : 0; nullMask |= (getValue() == null) ? VALUE : 0; nullMask |= (getComment() == null) ? COMMENT : 0; nullMask |= (getCommentURL() == null) ? COMMENT_URL : 0; nullMask |= (getExpiryDate() == null) ? EXPIRY_DATE : 0; nullMask |= (getDomain() == null) ? DOMAIN : 0; nullMask |= (getPath() == null) ? PATH : 0; nullMask |= (getPorts() == null) ? PORTS : 0; out.writeInt(nullMask);// w w w .j a v a 2 s . co m if ((nullMask & NAME) == 0) out.writeUTF(getName()); if ((nullMask & VALUE) == 0) out.writeUTF(getValue()); if ((nullMask & COMMENT) == 0) out.writeUTF(getComment()); if ((nullMask & COMMENT_URL) == 0) out.writeUTF(getCommentURL()); if ((nullMask & EXPIRY_DATE) == 0) out.writeLong(getExpiryDate().getTime()); out.writeBoolean(isPersistent()); if ((nullMask & DOMAIN) == 0) out.writeUTF(getDomain()); if ((nullMask & PATH) == 0) out.writeUTF(getPath()); if ((nullMask & PORTS) == 0) { out.writeInt(getPorts().length); for (int p : getPorts()) out.writeInt(p); } out.writeBoolean(isSecure()); out.writeInt(getVersion()); }
From source file:com.openlapi.AddressInfo.java
public void writeExternal(ObjectOutput out) throws IOException { byte[] attributeFlags = new byte[NUM_FIELDS]; int attributeCount = 0; for (int i = 1; i <= NUM_FIELDS; i++) { if (getField(i) != null) { attributeFlags[i - 1] = BYTE_ONE; attributeCount++;//ww w . ja v a2 s . c o m } } out.write(attributeCount); if (attributeCount > 0) { Integer[] attributes = new Integer[attributeCount]; int j = attributeCount; for (int i = 0; i < NUM_FIELDS; i++) { if (attributeFlags[i] == BYTE_ONE) { j--; attributes[j] = i; } } out.writeUTF(StringUtils.join(attributes, ",")); for (int i = 0; i < attributeCount; i++) { int attribute = attributes[i]; out.writeUTF(getField(attribute + 1)); } } }
From source file:com.weibo.api.motan.protocol.rpc.CompressRpcCodec.java
private void addAttachment(ObjectOutput output, Map<String, String> attachments) throws IOException { output.writeShort(attachments.size()); for (Map.Entry<String, String> entry : attachments.entrySet()) { output.writeUTF(entry.getKey()); output.writeUTF(entry.getValue()); }// w w w . java2 s.co m }
From source file:de.betterform.xml.xforms.XFormsProcessorImpl.java
public void writeExternal(ObjectOutput objectOutput) throws IOException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("serializing XFormsFormsProcessorImpl"); }/* w ww . ja v a 2s . c o m*/ try { if (getXForms().getDocumentElement().hasAttribute("bf:serialized")) { objectOutput.writeUTF(DOMUtil.serializeToString(getXForms())); } else { getXForms().getDocumentElement().setAttributeNS(NamespaceConstants.BETTERFORM_NS, "bf:baseURI", getBaseURI()); getXForms().getDocumentElement().setAttributeNS(NamespaceConstants.BETTERFORM_NS, "bf:serialized", "true"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("....::: XForms before writing ::::...."); DOMUtil.prettyPrintDOM(getXForms()); } DefaultSerializer serializer = new DefaultSerializer(this); Document serializedForm = serializer.serialize(); StringWriter stringWriter = new StringWriter(); Transformer transformer = null; StreamResult result = new StreamResult(stringWriter); try { 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()); } } catch (XFormsException e) { throw new IOException("baseURI couldn't be set"); } objectOutput.flush(); objectOutput.close(); }
From source file:com.inmobi.grill.server.query.QueryExecutionServiceImpl.java
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); // persist all drivers synchronized (drivers) { out.writeInt(drivers.size());/*from w ww . j a v a 2s .co m*/ for (GrillDriver driver : drivers) { out.writeUTF(driver.getClass().getName()); driver.writeExternal(out); } } // persist allQueries synchronized (allQueries) { out.writeInt(allQueries.size()); for (QueryContext ctx : allQueries.values()) { out.writeObject(ctx); boolean isDriverAvailable = (ctx.getSelectedDriver() != null); out.writeBoolean(isDriverAvailable); if (isDriverAvailable) { out.writeUTF(ctx.getSelectedDriver().getClass().getName()); } } } LOG.info("Persisted " + allQueries.size() + " queries"); }
From source file:com.weibo.api.motan.protocol.rpc.CompressRpcCodec.java
/** * response body ?//from w w w .ja v a 2 s . c o m * * <pre> * * body: * * byte[] : serialize (result) or serialize (exception) * * </pre> * * @param channel * @param value * @return * @throws IOException */ private byte[] encodeResponse(Channel channel, Response value) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ObjectOutput output = createOutput(outputStream); Serialization serialization = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension( channel.getUrl().getParameter(URLParamType.serialize.getName(), URLParamType.serialize.getValue())); byte flag = 0; output.writeLong(value.getProcessTime()); if (value.getException() != null) { output.writeUTF(value.getException().getClass().getName()); serialize(output, value.getException(), serialization); flag = MotanConstants.FLAG_RESPONSE_EXCEPTION; } else if (value.getValue() == null) { flag = MotanConstants.FLAG_RESPONSE_VOID; } else { output.writeUTF(value.getValue().getClass().getName()); serialize(output, value.getValue(), serialization); // v2?responseattachment Map<String, String> attachments = value.getAttachments(); if (attachments != null) { String signed = attachments.get(ATTACHMENT_SIGN); String unSigned = attachments.get(UN_ATTACHMENT_SIGN); attachments.clear(); // attachment???? if (StringUtils.isNotBlank(signed)) { attachments.put(ATTACHMENT_SIGN, signed); } if (StringUtils.isNotBlank(unSigned)) { attachments.put(UN_ATTACHMENT_SIGN, unSigned); } } if (attachments != null && !attachments.isEmpty()) {// ?? addAttachment(output, attachments); } else { // empty attachments output.writeShort(0); } flag = MotanConstants.FLAG_RESPONSE_ATTACHMENT; // v2flag } output.flush(); byte[] body = outputStream.toByteArray(); output.close(); Boolean usegz = channel.getUrl().getBooleanParameter(URLParamType.usegz.getName(), URLParamType.usegz.getBooleanValue()); int minGzSize = channel.getUrl().getIntParameter(URLParamType.mingzSize.getName(), URLParamType.mingzSize.getIntValue()); return encode(compress(body, usegz, minGzSize), flag, value.getRequestId()); }