@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeUTF(((BigDecimal)value).toString()); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeUTF(((URI)value).toString()); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 dataOutput.writeUTF((String)value); }
public static byte[] encodeName(QName qname) { String name = qname.getName(); String namespace = qname.getNamespace(); int sizeEstimate = (((name == null) ? 1 : (name.length() * 2)) + ((namespace == null) ? 1 : (namespace.length() * 2))); DataOutput dataOutput = new DataOutputImpl(sizeEstimate); dataOutput.writeUTF(namespace); dataOutput.writeUTF(name); return dataOutput.toByteArray(); }
private static void writeNullOrString(String value, DataOutput output) { if (value == null) { output.writeByte(NULL_MARKER); } else { output.writeByte(NOT_NULL_MARKER); output.writeUTF(value); } }
/** * 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(); }
@Override public void writeBytes(DataOutput dataOutput) { if (recordIdBytes == null) { dataOutput.writeByte(IdGeneratorImpl.IdType.USER.getIdentifierByte()); dataOutput.writeUTF(basicRecordIdString, false); } else { dataOutput.writeBytes(recordIdBytes); } }
public static byte[] encodeValueType(String valueTypeName) { DataOutput dataOutput = new DataOutputImpl(); dataOutput.writeByte(valueTypeEncodingVersion); dataOutput.writeUTF(valueTypeName); return dataOutput.toByteArray(); }
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()); }
/** * Format of the bytes written : * - Length of the blob value : int of 4 bytes * - Blob Value * - Blob Media Type : UTF (which starts with an int of 4 bytes indicating its length) * - Blob size : long of 8 bytes * - Blob name : UTF (which starts with an int of 4 bytes indicating its length) * * <p> IMPORTANT: Any changes on this format has an impact on the {@link ContainsValueComparator} */ @Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 Blob blob = (Blob)value; byte[] key = blob.getValue(); if (key == null) { dataOutput.writeVInt(0); } else { dataOutput.writeVInt(key.length); dataOutput.writeBytes(key); } dataOutput.writeUTF(blob.getMediaType()); Long size = blob.getSize(); if (size == null) { size = Long.valueOf(-1); } dataOutput.writeLong(size); dataOutput.writeUTF(blob.getName()); }