public static void writeTo(ObjectOutput output, XidImpl xid) throws IOException { output.writeInt(xid.formatId); MarshallUtil.marshallByteArray(xid.rawId, output); }
@Override public void writeTo(ObjectOutput output) throws IOException { if (indexName == null) { output.writeBoolean(false); } else { output.writeBoolean(true); output.writeUTF(indexName); } MarshallUtil.marshallByteArray(serializedModel, output); }
@Override public void writeObject(ObjectOutput output, WrappedByteArray object) throws IOException { MarshallUtil.marshallByteArray(object.bytes, output); if (object.initializedHashCode) { output.writeBoolean(true); output.writeInt(object.hashCode); } else { output.writeBoolean(false); } }
@Override public void writeTo(ObjectOutput output) throws IOException { if (indexName == null) { output.writeBoolean(false); } else { output.writeBoolean(true); output.writeUTF(indexName); } MarshallUtil.marshallByteArray(serializedModel, output); }
@Override public void writeObject(ObjectOutput output, InitializerState value) throws IOException { output.writeByte(VERSION_1); MarshallUtil.marshallString(value.getRealmId(), output); output.writeInt(value.segmentsCount); MarshallUtil.marshallByteArray(value.segments.toByteArray(), output); }
@Test public void testByteArray() throws IOException, ClassNotFoundException { ObjectInputOutput io = new ObjectInputOutput(); MarshallUtil.marshallByteArray(null, io); Assert.assertNull(MarshallUtil.unmarshallByteArray(io)); Assert.assertEquals(0, io.buffer.size()); io.reset(); byte[] array = Util.EMPTY_BYTE_ARRAY; MarshallUtil.marshallByteArray(array, io); Assert.assertTrue(Arrays.equals(array, MarshallUtil.unmarshallByteArray(io))); Assert.assertEquals(0, io.buffer.size()); io.reset(); array = new byte[] {1, 2, 3}; MarshallUtil.marshallByteArray(array, io); Assert.assertTrue(Arrays.equals(array, MarshallUtil.unmarshallByteArray(io))); Assert.assertEquals(0, io.buffer.size()); io.reset(); }