@Override @SuppressWarnings("unchecked") public Integer read(DataInput dataInput) { return dataInput.readInt(); }
@Override @SuppressWarnings("unchecked") public List<Object> read(DataInput dataInput) throws RepositoryException, InterruptedException { int nrOfValues = dataInput.readInt(); List<Object> result = new ArrayList<Object>(nrOfValues); for (int i = 0 ; i < nrOfValues; i++) { result.add(valueType.read(dataInput)); } return result; }
@Override @SuppressWarnings("unchecked") public HierarchyPath read(DataInput dataInput) throws RepositoryException, InterruptedException { int nrOfValues = dataInput.readInt(); List<Object> result = new ArrayList<Object>(nrOfValues); for (int i = 0 ; i < nrOfValues; i++) { result.add(valueType.read(dataInput)); } return new HierarchyPath(result.toArray(new Object[result.size()])); }
DerefMapVariantPropertiesPattern deserializeVariantPropertiesPattern(DataInput dataInput) { final Map<String, String> pattern = new HashMap<String, String>(); final int nEntries = dataInput.readInt(); while (pattern.size() < nEntries) { final String name = dataInput.readUTF(); final String value = dataInput.readUTF(); pattern.put(name, value); } return new DerefMapVariantPropertiesPattern(pattern); }
@Override @SuppressWarnings("unchecked") public ByteArray read(DataInput dataInput) { int length = dataInput.readInt(); // We can use ByteArray.wrap here since in this use case the dataInput // will always be a DataInputImpl which copies the bytes when reading // them. return ByteArray.wrap(dataInput.readBytes(length)); }
public static Link read(DataInput dataInput, IdGenerator idGenerator) { // Format: see write(DataOutput). int tableLength = dataInput.readInt(); byte[] tableBytes = dataInput.readBytes(tableLength); int recordIdLength = dataInput.readInt(); byte[] recordIdBytes = null; if (recordIdLength > 0) { recordIdBytes = dataInput.readBytes(recordIdLength); } String args = dataInput.readUTF(); if (recordIdLength == 0 && args == null) { return new Link(); } LinkBuilder builder = Link.newBuilder(); if (tableLength > 0) { builder.table(new String(tableBytes)); } if (recordIdLength > 0) { RecordId id = idGenerator.fromBytes(recordIdBytes); builder.recordId(id); } if (args != null && args.length() > 0) { argsFromString(args, builder, args /* does not matter, should never be invalid */); } return builder.create(); }
/** * Decodes links from Lily 2.0 and earlier (before table name was added to Link serialization). */ public static Link decode(DataInput dataInput, IdGenerator idGenerator) { // The bytes format is as follows: // [byte representation of master record id, if not null][args: bytes of the string representation] int recordIdLength = dataInput.readInt(); byte[] recordIdBytes = null; if (recordIdLength > 0) { recordIdBytes = dataInput.readBytes(recordIdLength); } String args = dataInput.readUTF(); if (recordIdLength == 0 && args == null) { return new Link(); } LinkBuilder builder = Link.newBuilder(); if (recordIdLength > 0) { RecordId id = idGenerator.fromBytes(recordIdBytes); builder.recordId(id); } if (args != null && args.length() > 0) { argsFromString(args, builder, args /* does not matter, should never be invalid */); } return builder.create(); }
public static Link decodeLink(DataInput dataInput, IdGenerator idGenerator) { // Format: see toBytes. int recordIdLength = dataInput.readInt(); byte[] recordIdBytes = null; if (recordIdLength > 0) { recordIdBytes = dataInput.readBytes(recordIdLength); } String args = dataInput.readUTF(); if (recordIdLength == 0 && args == null) { return new Link(); } Link.LinkBuilder builder = Link.newBuilder(); if (recordIdLength > 0) { RecordId id = decode(new DataInputImpl(recordIdBytes), idGenerator); builder.recordId(id); } if (args != null && args.length() > 0) { argsFromString(args, builder, args /* does not matter, should never be invalid */); } return builder.create(); }