/** * Write the commit time into the document. * * @param commitTime * The commit time. */ public void commit(final long commitTime) throws IOException { // Total elapsed milliseconds from start of update request. final long totalElapsedMillis = TimeUnit.NANOSECONDS .toMillis(System.nanoTime() - begin); body.node("p") .text("COMMIT: totalElapsed=" + totalElapsedMillis + "ms, commitTime=" + commitTime + ", mutationCount=" + mutationCount.get())// .close(); }
/** * Write the commit time into the document. * * @param commitTime * The commit time. */ public void commit(final long commitTime) throws IOException { // Total elapsed milliseconds from start of update request. final long totalElapsedMillis = TimeUnit.NANOSECONDS .toMillis(System.nanoTime() - begin); body.node("p") .text("COMMIT: totalElapsed=" + totalElapsedMillis + "ms, commitTime=" + commitTime + ", mutationCount=" + mutationCount.get())// .close(); }
@Override public Void call() throws Exception { BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); final StringWriter w = new StringWriter(); final RepositoryResult<Resource> it = conn.getContextIDs(); try { final XMLBuilder t = new XMLBuilder(w); final Node root = t.root("contexts"); while (it.hasNext()) { root.node("context").attr("uri", it.next()).close(); } root.close(); } finally { it.close(); } buildResponse(QueryServlet.HTTP_OK, QueryServlet.MIME_APPLICATION_XML, w.toString()); return null; } finally { if (conn != null) { conn.close(); } } }
/** * Generate an open element for the tag, output the indicated text, and * then output the closing element for that tag. * * @param tag * The tag (element name). * @param text * The text, which will be automatically encoded as * appropriate for a CDATA section. * * @return This {@link Node}. * * @throws IOException */ public Node node(final String tag, final String text) throws IOException { closeHead(); m_nodes++; final Node tmp = new Node(tag, this); tmp.text(text); final Node ret = tmp.close(); assert ret == this; return ret; }
/** * Generate an open element for the tag, output the indicated text, and * then output the closing element for that tag. * * @param tag * The tag (element name). * @param text * The text, which will be automatically encoded as * appropriate for a CDATA section. * * @return This {@link Node}. * * @throws IOException */ public Node node(final String tag, final String text) throws IOException { closeHead(); m_nodes++; final Node tmp = new Node(tag, this); tmp.text(text); final Node ret = tmp.close(); assert ret == this; return ret; }
/** * @todo This does not actually test anything. You have to inspect the * output. */ public void testXMLBuilder() throws IOException { final StringWriter w = new StringWriter(); final XMLBuilder xml = new XMLBuilder(w); XMLBuilder.Node close = xml.root("data") .attr("id", "TheRoot") .attr("name", "Test") .node("child", "My Child") .node("child") .attr("name", "My Child") .close() .node("child") .attr("name", "My Child") .text("Content") .close() .close(); assertTrue(close == null); if(log.isInfoEnabled()) log.info(w.toString()); }
/** * Report an access path range count and elapsed time back to the user agent. * * @param resp * The response. * @param rangeCount * The mutation count. * @param elapsed * The elapsed time (milliseconds). * * @throws IOException */ static protected void buildAndCommitRangeCountResponse( final HttpServletResponse resp, final long rangeCount, final long elapsed) throws IOException { final StringWriter w = new StringWriter(); final XMLBuilder t = new XMLBuilder(w); t.root("data").attr("rangeCount", rangeCount) .attr("milliseconds", elapsed).close(); buildAndCommitResponse(resp, HTTP_OK, MIME_APPLICATION_XML, w.toString()); }
/** * Utility method to consolidate header into a single location. * * The post-condition is that the current node is open for writing on the * body element. * * @param current * @throws IOException */ public static void addHtmlHeader(Node current, String charset) throws IOException { current = current.node("head"); current.node("meta").attr("http-equiv", "Content-Type") .attr("content", "text/html;charset=" + charset).close(); current.node("title").textNoEncode("blazegraph™ by SYSTAP") .close(); current = current.close();// close the head. // open the body current = current.node("body"); }
@Override public Void call() throws Exception { BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); final StringWriter w = new StringWriter(); final RepositoryResult<Resource> it = conn.getContextIDs(); try { final XMLBuilder t = new XMLBuilder(w); final Node root = t.root("contexts"); while (it.hasNext()) { root.node("context").attr("uri", it.next()).close(); } root.close(); } finally { it.close(); } buildResponse(QueryServlet.HTTP_OK, QueryServlet.MIME_APPLICATION_XML, w.toString()); return null; } finally { if (conn != null) { conn.close(); } } }
/** * @todo This does not actually test anything. You have to inspect the * output. */ public void testXMLBuilder() throws IOException { final StringWriter w = new StringWriter(); final XMLBuilder xml = new XMLBuilder(w); XMLBuilder.Node close = xml.root("data") .attr("id", "TheRoot") .attr("name", "Test") .node("child", "My Child") .node("child") .attr("name", "My Child") .close() .node("child") .attr("name", "My Child") .text("Content") .close() .close(); assertTrue(close == null); if(log.isInfoEnabled()) log.info(w.toString()); }
/** * Utility method to consolidate header into a single location. * * The post-condition is that the current node is open for writing on the * body element. * * @param current * @throws IOException */ public static void addHtmlHeader(Node current, String charset) throws IOException { current = current.node("head"); current.node("meta").attr("http-equiv", "Content-Type") .attr("content", "text/html;charset=" + charset).close(); current.node("title").textNoEncode("blazegraph™ by SYSTAP") .close(); current = current.close();// close the head. // open the body current = current.node("body"); }
/** * Report an access path range count and elapsed time back to the user agent. * * @param resp * The response. * @param rangeCount * The mutation count. * @param elapsed * The elapsed time (milliseconds). * * @throws IOException */ static protected void buildAndCommitRangeCountResponse( final HttpServletResponse resp, final long rangeCount, final long elapsed) throws IOException { final StringWriter w = new StringWriter(); final XMLBuilder t = new XMLBuilder(w); t.root("data").attr("rangeCount", rangeCount) .attr("milliseconds", elapsed).close(); buildAndCommitResponse(resp, HTTP_OK, MIME_APPLICATION_XML, w.toString()); }
public Node root(String name, String nodeText) throws IOException { Node root = new Node(name, null); root.text(nodeText); return root.close(); }
public void closeAll(Node node) throws IOException { while (node != null) { node = node.close(); } }
public Node root(String name, String nodeText) throws IOException { Node root = new Node(name, null); root.text(nodeText); return root.close(); }
public void closeAll(Node node) throws IOException { while (node != null) { node = node.close(); } }