/** * Wraps a byte[] instead of copying it like the constructor does. * <p> * Warning! This method should only be used when the user is absolutely * certain that the provided byte[] will not be modified anymore. * * @param bytes * the byte[] to wrap * @return a ByteArray */ public static ByteArray wrap(byte[] bytes) { ByteArray byteArray = new ByteArray(); byteArray.bytes = bytes; return byteArray; }
@Override public Object deserialize(DataInput dataInput) { int size = dataInput.readVInt(); return new ByteArray(dataInput.readBytes(size)); } }
protected ByteArray readByteArray(ValueHandle handle, ReadContext context) throws JsonFormatException, RepositoryException, InterruptedException { if (!handle.node.isTextual()) { throw new JsonFormatException("Expected base64 encoded value for property '" + handle.prop + "'"); } try { return new ByteArray(handle.node.getBinaryValue()); } catch (IOException e) { throw new JsonFormatException("Could not read base64 value for property '" + handle.prop + "'", e); } }
builder.value(name, new ByteArray(binaryValue.getBinaryValue())); } catch (IOException e) { throw new JsonFormatException("Invalid binary value for metadata field '"