@Override public InputStream getContentAsByteStream() { if (is != null) { return is; } return new ByteArrayInputStream(getContentAsByteArray()); }
public MarkLogicNode getContentAsMarkLogicNode() { if (contentType == ContentType.XML || contentType == ContentType.TEXT) { return new MarkLogicNode(getContentAsText().toString(), contentType); } throw new UnsupportedOperationException( "Cannot convert JSON or binary data to MarkLogicNode."); }
private void readDocFromStream(long entryLength, DatabaseDocument doc) throws IOException { ByteArrayOutputStream baos; if (entryLength == -1) { baos = new ByteArrayOutputStream(); } else { baos = new ByteArrayOutputStream((int) entryLength); } int size; while ((size = zipIn.read(buf, 0, buf.length)) != -1) { baos.write(buf, 0, size); } doc.setContentType(type); doc.setContent(baos.toByteArray()); baos.close(); }
DatabaseDocument doc = (DatabaseDocument)value; if (formatNeeded) { options.setFormat(doc.getContentType().getDocumentFormat()); formatNeeded = false; if (doc.getContentType() == ContentType.BINARY) { content = ContentFactory.newContent(uri, doc.getContentAsByteArray(), options); } else { content = ContentFactory.newContent(uri, doc.getContentAsText().getBytes(), options);
((MarkLogicNode)value).set(result); } else if (valueClass.equals(DatabaseDocument.class)) { ((DatabaseDocument) value).set(result); } else { throw new UnsupportedOperationException("Value " +