@Override public byte[][] serializeType(RyaType ryaType) throws RyaTypeResolverException { byte[] bytes = serializeData(ryaType.getData()).getBytes(); return new byte[][] { bytes, Bytes.concat( TYPE_DELIM_BYTES, ryaType.getDataType().stringValue().getBytes(), TYPE_DELIM_BYTES, markerBytes) }; }
@Override public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException { if (!deserializable(bytes)) { throw new RyaTypeResolverException("Bytes not deserializable"); } RyaType rt = newInstance(); int length = bytes.length; int indexOfType = Bytes.indexOf(bytes, TYPE_DELIM_BYTE); if (indexOfType < 1) { throw new RyaTypeResolverException("Not a datatype literal"); } String label = deserializeData(new String(bytes, 0, indexOfType)); rt.setDataType(new URIImpl(new String(bytes, indexOfType + 1, (length - indexOfType) - 3))); rt.setData(label); return rt; }