MARMOTTA-204: implemented handleBoolean() also for the SPARQLBooleanHTMLWriter 
(now write() passes to be deprecated in sesame 2.7.0)


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/a830bd01
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/a830bd01
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/a830bd01

Branch: refs/heads/develop
Commit: a830bd01799de0ff573afa94fa42b5db74c299de
Parents: f448464
Author: Sergio Fernández <[email protected]>
Authored: Mon Apr 22 09:08:39 2013 +0200
Committer: Sergio Fernández <[email protected]>
Committed: Mon Apr 22 09:08:39 2013 +0200

----------------------------------------------------------------------
 .../sparqlhtml/SPARQLBooleanHTMLWriter.java        |   62 ++++++++-------
 1 files changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/a830bd01/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLBooleanHTMLWriter.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLBooleanHTMLWriter.java
 
b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLBooleanHTMLWriter.java
index 28b83e3..3a94b2d 100644
--- 
a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLBooleanHTMLWriter.java
+++ 
b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLBooleanHTMLWriter.java
@@ -96,33 +96,13 @@ public class SPARQLBooleanHTMLWriter implements 
BooleanQueryResultWriter {
      * Writes the specified boolean value.
      */
     @Override
+    @Deprecated
     public void write(boolean value) throws IOException {
-        writer.write(value);
-
-        byte[] queryResult = xmlOut.toByteArray();
-
-        // get server uri
-        String server_uri = 
CDIContext.getInstance(ConfigurationService.class).getServerUri();
-
-        BufferedWriter writer = new BufferedWriter(new 
OutputStreamWriter(out));
-        try {
-            Source input = new StreamSource(new 
ByteArrayInputStream(queryResult));
-
-            Transformer transformer = stylesheet.newTransformer();
-            transformer.setParameter("serverurl", server_uri);
-
-            JDOMResult result = new JDOMResult();
-            transformer.transform(input,result);
-            Document output = result.getDocument();
-
-            XMLOutputter printer = new XMLOutputter(Format.getPrettyFormat());
-            printer.output(output, writer);
-            writer.flush();
-        } catch (Exception ex) {
-            throw new IOException("error while transforming XML results to 
HTML",ex);
-        } finally {
-            writer.close();
-        }
+       try {
+                       handleBoolean(value);
+               } catch (QueryResultHandlerException e) {
+                       throw new IOException(e);
+               }
     }
 
        @Override
@@ -181,8 +161,34 @@ public class SPARQLBooleanHTMLWriter implements 
BooleanQueryResultWriter {
        }
 
        @Override
-       public void handleBoolean(boolean arg0) throws 
QueryResultHandlerException {
-               // TODO Auto-generated method stub
+       public void handleBoolean(boolean value) throws 
QueryResultHandlerException {   
+        try {
+            writer.write(value);
+
+            byte[] queryResult = xmlOut.toByteArray();
+
+            // get server uri
+            String server_uri = 
CDIContext.getInstance(ConfigurationService.class).getServerUri();
+
+            BufferedWriter writer = new BufferedWriter(new 
OutputStreamWriter(out));
+               
+               Source input = new StreamSource(new 
ByteArrayInputStream(queryResult));
+
+            Transformer transformer = stylesheet.newTransformer();
+            transformer.setParameter("serverurl", server_uri);
+
+            JDOMResult result = new JDOMResult();
+            transformer.transform(input,result);
+            Document output = result.getDocument();
+
+            XMLOutputter printer = new XMLOutputter(Format.getPrettyFormat());
+            printer.output(output, writer);
+            writer.flush();
+        } catch (Exception ex) {
+            throw new QueryResultHandlerException("error while transforming 
XML results to HTML",ex);
+        } finally {
+            //writer.close();
+        }
                
        }
 

Reply via email to