/** * Initializes the handle with a character reader for the content. * @param content a character reader */ public ReaderHandle(Reader content) { this(); set(content); }
handle.set(docStream);
/** * Assigns a character reader as the content and returns the handle * as a fluent convenience. * @param content a reader * @return this handle */ public ReaderHandle with(Reader content) { set(content); return this; }
/** * Assigns a character reader as the content and returns the handle * as a fluent convenience. * @param content a reader * @return this handle */ public ReaderHandle with(Reader content) { set(content); return this; }
/** * Initializes the handle with a character reader for the content. * @param content a character reader */ public ReaderHandle(Reader content) { this(); set(content); }
/** * Write document to databae using ReaderHandle * * @param client * : the database client connection * @param filename * : the filename * @param uri * : the document uri * @param type * : the document type (XML, Text, JSON, or Binary) * @throws IOException */ public void writeDocumentReaderHandle(DatabaseClient client, String filename, String uri, String type) throws IOException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // acquire the content BufferedReader docStream = new BufferedReader(new FileReader("src/test/java/com/marklogic/client/functionaltest/data/" + filename)); // create an identifier for the document String docId = uri + filename; // create a handle on the content ReaderHandle handle = new ReaderHandle(); handle.set(docStream); // write the document content docMgr.write(docId, handle); System.out.println("Write " + docId + " to database"); docStream.close(); }
/** * Update document using ReaderHandle * * @param client * @param filename * @param uri * @param type * @throws IOException */ public void updateDocumentReaderHandle(DatabaseClient client, String filename, String uri, String type) throws IOException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // acquire the content BufferedReader docStream = new BufferedReader(new FileReader("src/test/java/com/marklogic/client/functionaltest/data/" + filename)); // create an identifier for the document String docId = uri; // create a handle on the content ReaderHandle handle = new ReaderHandle(); handle.set(docStream); // write the document content docMgr.write(docId, handle); System.out.println("Update " + docId + " to database"); docStream.close(); }
/** * Set query option in XML * * @param client * @param queryOptionName * @throws FileNotFoundException */ public void setQueryOption(DatabaseClient client, String queryOptionName) throws FileNotFoundException { // create a manager for writing query options QueryOptionsManager optionsMgr = client.newServerConfigManager().newQueryOptionsManager(); // create handle ReaderHandle handle = new ReaderHandle(); // write the files BufferedReader docStream = new BufferedReader(new FileReader("src/test/java/com/marklogic/client/functionaltest/queryoptions/" + queryOptionName)); handle.set(docStream); // handle.setFormat(Format.XML); // write the query options to the database optionsMgr.writeOptions(queryOptionName, handle); System.out.println("Write " + queryOptionName + " to database"); }
@Test public void testWrite_rdfxml_FileHandle() throws Exception { BufferedReader buffreader = new BufferedReader(new FileReader(datasource + "semantics.rdf")); ReaderHandle handle = new ReaderHandle(); handle.set(buffreader); gmWriter.write("http://test.reader.handle/bufferreadtrig", handle.withMimetype(RDFMimeTypes.RDFXML)); buffreader.close(); ReaderHandle read = gmWriter.read("http://test.reader.handle/bufferreadtrig", new ReaderHandle().withMimetype(RDFMimeTypes.RDFXML)); Reader readFile = read.get(); String readContent = convertReaderToString(readFile); assertTrue("Did not get receive expected string content, Received:: " + readContent, readContent.contains("http://www.daml.org/2001/12/factbook/vi#A113932")); handle.close(); read.close(); }
handle.set(docStream);
handle.set(docStream);