[Mulgara-svn] r1916 - trunk/src/jar/query/java/org/mulgara/query

pag at mulgara.org pag at mulgara.org
Mon Feb 15 19:24:59 UTC 2010


Author: pag
Date: 2010-02-15 11:24:58 -0800 (Mon, 15 Feb 2010)
New Revision: 1916

Modified:
   trunk/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java
Log:
Added an option to not close the Answer being emitted. This is needed since some answer processing code needs to do the closing instead.

Modified: trunk/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java	2010-02-15 19:23:23 UTC (rev 1915)
+++ trunk/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java	2010-02-15 19:24:58 UTC (rev 1916)
@@ -169,7 +169,7 @@
    * @throws QueryException If there was an error accessing statements from the answer.
    */
   public static void writeRdfXml(GraphAnswer answer, OutputStream output) throws QueryException {
-    writeRdfXml(answer, output, true);
+    writeRdfXml(answer, output, true, true);
   }
   
   /**
@@ -181,13 +181,14 @@
    * @param includeDocHeader If <code>true</code>, the RDF/XML output will contain an XML
    *        header with entity definitions, and the body will use the entities to abbreviate
    *        RDF resource URI's.
+   * @param closeAns Close the Answer when it has been finished with.
    * @throws QueryException If there was an error accessing statements from the answer.
    */
-  public static void writeRdfXml(GraphAnswer answer, OutputStream output, boolean includeDocHeader) throws QueryException {
+  public static void writeRdfXml(GraphAnswer answer, OutputStream output, boolean includeDocHeader, boolean closeAns) throws QueryException {
     PrintWriter writer = new PrintWriter(new BufferedOutputStream(output));
     
     Map<String,String> nsMap = createInitialNsMap();
-    List<Triple> statements = getStatementList(answer, nsMap);
+    List<Triple> statements = getStatementList(answer, nsMap, closeAns);
     Collections.sort(statements, TRIPLE_COMPARATOR);
     
     if (includeDocHeader) {
@@ -210,7 +211,7 @@
    * @return An unsorted list of RDF statements.
    * @throws QueryException if there was an error accessing the statements.
    */
-  private static List<Triple> getStatementList(GraphAnswer answer, Map<String,String> nsMap) throws QueryException {
+  private static List<Triple> getStatementList(GraphAnswer answer, Map<String,String> nsMap, boolean closeAns) throws QueryException {
     assert answer != null;
     
     List<Triple> statements = new ArrayList<Triple>();
@@ -244,7 +245,7 @@
       throw new QueryException("Error accessing statements from GraphAnswer", te);
     } finally {
       try {
-        answer.close();
+        if (closeAns) answer.close();
       } catch (TuplesException te) {
         throw new QueryException("Error closing GraphAnswer", te);
       }




More information about the Mulgara-svn mailing list