protected Object readContent(ObjectDataInput in) throws IOException { if (in.readBoolean()) { if (repo == null) { repo = getRepository(); } if (repo != null) { ContentSerializer cs = repo.getSerializer(contentType); if (cs != null) { return cs.readContent(in); } } throw new IllegalStateException("Cannot read serialized content: absent SchemaRepository"); } return in.readObject(); }
for (Map.Entry<String, Object> entry: documents.entrySet()) { out.writeUTF(entry.getKey()); cs.writeContent(out, entry.getValue());
public static Object readCompressedContent(ObjectDataInput in, ContentSerializer<Object> cs) throws IOException { InternalSerializationService ss = in.getSerializationService(); ObjectDataInput odi = ss.createObjectDataInput(IOUtil.decompress(in.readByteArray())); return cs.readContent(odi); }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void writeData(ObjectDataOutput out) throws IOException { super.writeData(out); boolean compress = Boolean.parseBoolean(context.getProperty(pn_document_compress, "false")); String format = context.getProperty(pn_document_data_format); if (format != null) { ContentSerializer cs = repo.getSerializer(format); if (cs != null) { if (compress) { writeCompressedContent(out, cs, content); } else { cs.writeContent(out, content); } return; } } if (compress) { writeCompressedData(out, content); } else { out.writeObject(content); } }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void readData(ObjectDataInput in) throws IOException { super.readData(in); checkRepo(); boolean compress = Boolean.parseBoolean(context.getProperty(pn_document_compress, "false")); String format = context.getProperty(pn_document_data_format); if (format != null) { ContentSerializer cs = repo.getSerializer(format); if (cs != null) { if (compress) { content = readCompressedContent(in, cs); } else { content = cs.readContent(in); } return; } } if (compress) { content = readCompressedData(in); } else { content = in.readObject(); } }
public static void writeCompressedContent(ObjectDataOutput out, ContentSerializer<Object> cs, Object data) throws IOException { InternalSerializationService ss = (InternalSerializationService) out.getSerializationService(); ObjectDataOutput tmp = ss.createObjectDataOutput(); cs.writeContent(tmp, data); out.writeByteArray(IOUtil.compress(tmp.toByteArray())); } }
documents.put(in.readUTF(), cs.readContent(in));
protected void writeContent(ObjectDataOutput out) throws IOException { if (repo == null) { repo = getRepository(); } if (repo != null) { ContentSerializer cs = repo.getSerializer(contentType); if (cs != null) { out.writeBoolean(true); cs.writeContent(out, content); return; } } out.writeBoolean(false); out.writeObject(content); }