@Override @SuppressWarnings("unchecked") public Long read(DataInput dataInput) { return dataInput.readLong(); }
@Override public Object deserialize(DataInput dataInput) { // Always construct UTC such that it is not depending on the default timezone of the current host return new DateTime(dataInput.readLong(), DateTimeZone.UTC); } }
@Override @SuppressWarnings("unchecked") public DateTime read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); // Always construct UTC such that it is not depending on the default timezone of the current host return new DateTime(dataInput.readLong(), DateTimeZone.UTC); }
@Override @SuppressWarnings("unchecked") public LocalDate read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); // Always construct UTC such that it is not depending on the default timezone of the current host return new LocalDate(dataInput.readLong(), DateTimeZone.UTC); }
/** * See write for the byte format. */ @Override @SuppressWarnings("unchecked") public Blob read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); int keyLength = dataInput.readVInt(); byte[] key = null; if (keyLength > 0) { key = dataInput.readBytes(keyLength); } String mediaType = dataInput.readUTF(); Long size = dataInput.readLong(); if (size == -1) { size = null; } String filename = dataInput.readUTF(); return new Blob(key, mediaType, size, filename); }
@Override @SuppressWarnings("unchecked") public Record read(DataInput dataInput) throws RepositoryException, InterruptedException { Record record = new RecordImpl(); dataInput.readByte(); // Ignore, there is currently only one encoding : 1 int length = dataInput.readVInt(); byte[] recordTypeId = dataInput.readBytes(length); Long recordTypeVersion = dataInput.readLong(); RecordType recordType = typeManager.getRecordTypeById(new SchemaIdImpl(recordTypeId), recordTypeVersion); record.setRecordType(recordType.getName(), recordTypeVersion); Map<SchemaId, QName> idToQNameMapping = new HashMap<SchemaId, QName>(); List<FieldType> fieldTypes = getSortedFieldTypes(recordType); for (FieldType fieldType : fieldTypes) { byte readByte = dataInput.readByte(); if (DEFINED == readByte) { Object value = fieldType.getValueType().read(dataInput); record.setField(fieldType.getName(), value); idToQNameMapping.put(fieldType.getId(), fieldType.getName()); } } Map<Scope, SchemaId> recordTypeIds = new EnumMap<Scope, SchemaId>(Scope.class); recordTypeIds.put(Scope.NON_VERSIONED, recordType.getId()); return new IdRecordImpl(record, idToQNameMapping, recordTypeIds); }