@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeInt((Integer)value); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) throws RepositoryException, InterruptedException { List<Object> values = ((List<Object>) value); dataOutput.writeInt(values.size()); for (Object element : values) { valueType.write(element, dataOutput, parentRecords); } }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) throws RepositoryException, InterruptedException { Object[] elements = ((HierarchyPath) value).getElements(); dataOutput.writeInt(elements.length); for (Object element : elements) { valueType.write(element, dataOutput, parentRecords); } }
public void write(DataOutput dataOutput) { // The bytes format is as follows: // [byte representation of table, byte representation of master record id, if not null][args: bytes of the string representation] byte[] tableBytes = table == null ? new byte[0] : table.getBytes(); dataOutput.writeInt(tableBytes.length); if (tableBytes.length > 0) { dataOutput.writeBytes(tableBytes); } byte[] recordIdBytes = masterRecordId == null ? new byte[0] : masterRecordId.toBytes(); dataOutput.writeInt(recordIdBytes.length); if (recordIdBytes.length > 0) { dataOutput.writeBytes(recordIdBytes); } StringBuilder argsBuilder = new StringBuilder(); argstoString(argsBuilder); dataOutput.writeUTF(argsBuilder.toString()); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { ByteArray byteArray = (ByteArray) value; dataOutput.writeInt(byteArray.length()); // We can use getBytesUnsafe here since we know that in this use case // the // dataOutput will be a DataOutputImpl which copies the byte[] when // writing it. dataOutput.writeBytes(byteArray.getBytesUnsafe()); }
/** * Serializes a variant properties pattern. The serialization format is simply a list of variable length strings. * <code>null</code> values (meaning "any value" in the pattern) are written literaly as <code>null</code> Strings. * * @param variantPropertiesPattern pattern to serialize * @return serialized pattern */ byte[] serializeVariantPropertiesPattern(DerefMapVariantPropertiesPattern variantPropertiesPattern) throws IOException { final DataOutput dataOutput = new DataOutputImpl(); // total number of entries dataOutput.writeInt(variantPropertiesPattern.pattern.size()); for (Map.Entry<String, String> patternEntry : variantPropertiesPattern.pattern.entrySet()) { // name final String name = patternEntry.getKey(); dataOutput.writeUTF(name); // value (potentially null) final String value = patternEntry.getValue(); dataOutput.writeUTF(value); } return dataOutput.toByteArray(); }
public static void writeMetadataWithLengthSuffix(Metadata metadata, DataOutput output) { DataOutput tmp = new DataOutputImpl(); MetadataSerDeser.write(metadata, tmp); byte[] metadataBytes = tmp.toByteArray(); output.writeBytes(metadataBytes); output.writeInt(metadataBytes.length); }