use of java.io.ObjectOutput in project jPOS by jpos.
the class ISOMsg2Test method testWriteHeaderThrowsNullPointerException.
@Test
public void testWriteHeaderThrowsNullPointerException() throws Throwable {
ISOMsg iSOVMsg = new ISOVMsg(new ISOMsg(), new ISOVError("testISOMsgDescription", "testISOMsgRejectCode"));
ObjectOutput out = new ObjectOutputStream(new ByteArrayOutputStream());
try {
iSOVMsg.writeHeader(out);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
assertNull("(ISOVMsg) iSOVMsg.header", ((ISOVMsg) iSOVMsg).header);
}
}
use of java.io.ObjectOutput in project Chronicle-Queue by OpenHFT.
the class DuplicateMessageReadTest method write.
private static void write(final ExcerptAppender appender, final Data data) throws Exception {
try (final DocumentContext dc = appender.writingDocument()) {
final ObjectOutput out = dc.wire().objectOutput();
out.writeInt(data.id);
}
}
use of java.io.ObjectOutput in project knime-core by knime.
the class PMMLNaiveBayesModelTranslator method setObjectExtension.
/**
* @param extension the {@link Extension} to write to
* @param fieldName the filed name
* @param fieldValue the value
*/
static void setObjectExtension(final Extension extension, final String fieldName, final Object fieldValue) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = null;
try {
out = new ObjectOutputStream(bos);
out.writeObject(fieldValue);
byte[] bytes = bos.toByteArray();
final String valString = new String(Base64.encode(bytes), CharEncoding.UTF_8);
setStringExtension(extension, fieldName, valString);
} catch (IOException e) {
throw new IllegalStateException(e);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException ex) {
// ignore close exception
}
try {
bos.close();
} catch (IOException ex) {
// ignore close exception
}
}
}
use of java.io.ObjectOutput in project apex-malhar by apache.
the class HiveStreamCodec method writeExternal.
@Override
public void writeExternal(ObjectOutput out) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream obj = new ObjectOutputStream(os);
Output output = new Output(obj);
kryo.writeClassAndObject(output, rollingOperator);
byte[] outBytes = output.toBytes();
out.writeInt(outBytes.length);
out.write(outBytes, 0, outBytes.length);
out.flush();
}
use of java.io.ObjectOutput in project drools by kiegroup.
the class KnowledgePackageImpl method writeExternal.
/**
* Handles the write serialization of the Package. Patterns in Rules may
* reference generated data which cannot be serialized by default methods.
* The Package uses PackageCompilationData to hold a reference to the
* generated bytecode. The generated bytecode must be restored before any
* Rules.
*
* @param stream out the stream to write the object to; should be an instance
* of DroolsObjectOutputStream or OutputStream
*/
public void writeExternal(ObjectOutput stream) throws IOException {
boolean isDroolsStream = stream instanceof DroolsObjectOutputStream;
ByteArrayOutputStream bytes = null;
ObjectOutput out;
if (isDroolsStream) {
out = stream;
} else {
bytes = new ByteArrayOutputStream();
out = new DroolsObjectOutputStream(bytes);
}
out.writeObject(this.name);
out.writeObject(this.classFieldAccessorStore);
out.writeObject(this.dialectRuntimeRegistry);
out.writeObject(this.typeDeclarations);
out.writeObject(this.imports);
out.writeObject(this.staticImports);
out.writeObject(this.functions);
out.writeObject(this.accumulateFunctions);
out.writeObject(this.factTemplates);
out.writeObject(this.ruleFlows);
out.writeObject(this.globals);
out.writeBoolean(this.valid);
out.writeBoolean(this.needStreamMode);
out.writeObject(this.rules);
out.writeObject(this.entryPointsIds);
out.writeObject(this.windowDeclarations);
out.writeObject(this.traitRegistry);
out.writeObject(this.resourceTypePackages);
// writing the whole stream as a byte array
if (!isDroolsStream) {
bytes.flush();
bytes.close();
stream.writeObject(bytes.toByteArray());
}
}
Aggregations