You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by sa...@apache.org on 2012/04/17 20:29:45 UTC

svn commit: r1327212 - in /incubator/jena/Jena2/ARQ/trunk/src/main/java: com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java org/openjena/riot/out/SinkQuadBracedOutput.java

Author: sallen
Date: Tue Apr 17 18:29:45 2012
New Revision: 1327212

URL: http://svn.apache.org/viewvc?rev=1327212&view=rev
Log:
Better error checking for opened/closed UpdateWriter and SinkQuadBracedOutput.

Modified:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkQuadBracedOutput.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java?rev=1327212&r1=1327211&r2=1327212&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/UpdateWriter.java Tue Apr 17 18:29:45 2012
@@ -36,7 +36,6 @@ import com.hp.hpl.jena.sparql.serializer
 import com.hp.hpl.jena.sparql.syntax.Element;
 import com.hp.hpl.jena.sparql.util.FmtUtils;
 import com.hp.hpl.jena.update.Update;
-import com.hp.hpl.jena.update.UpdateException;
 import com.hp.hpl.jena.update.UpdateRequest;
 
 public class UpdateWriter implements Closeable
@@ -47,7 +46,6 @@ public class UpdateWriter implements Clo
     private UpdateDataWriter udw;
     private boolean firstOp = true;
     private boolean opened = false;
-    private boolean closed = false;
     
     public UpdateWriter(IndentedWriter out, SerializationContext sCxt)
     {
@@ -68,7 +66,7 @@ public class UpdateWriter implements Clo
     {
         if (!opened)
         {
-            throw new UpdateException("UpdateStreamWriter is not opened.  Call open() first.");
+            throw new IllegalStateException("UpdateStreamWriter is not opened.  Call open() first.");
         }
     }
     
@@ -161,7 +159,7 @@ public class UpdateWriter implements Clo
     @Override
     public void close()
     {
-        if (!closed)
+        if (opened)
         {
             if (null != udw)
             {
@@ -172,7 +170,7 @@ public class UpdateWriter implements Clo
             // Update requests always end in newline.
             out.ensureStartOfLine();
             flush();
-            closed = true;
+            opened = false;
         }
     }
     

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkQuadBracedOutput.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkQuadBracedOutput.java?rev=1327212&r1=1327211&r2=1327212&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkQuadBracedOutput.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkQuadBracedOutput.java Tue Apr 17 18:29:45 2012
@@ -12,7 +12,6 @@ import com.hp.hpl.jena.graph.Triple;
 import com.hp.hpl.jena.sparql.core.Quad;
 import com.hp.hpl.jena.sparql.serializer.SerializationContext;
 import com.hp.hpl.jena.sparql.util.FmtUtils;
-import com.hp.hpl.jena.update.UpdateException;
 
 /**
  * A class that print quads, SPARQL style (maybe good for Trig too?)
@@ -24,9 +23,8 @@ public class SinkQuadBracedOutput implem
     protected final IndentedWriter out;
     protected final SerializationContext sCxt;
     protected boolean opened = false;
-    protected boolean closed = false;
     
-    private Node currentGraph;
+    protected Node currentGraph;
     
     public SinkQuadBracedOutput(OutputStream out)
     {
@@ -65,7 +63,7 @@ public class SinkQuadBracedOutput implem
     {
         if (!opened)
         {
-            throw new UpdateException("SinkQuadBracedOutput is not opened.  Call open() first.");
+            throw new IllegalStateException("SinkQuadBracedOutput is not opened.  Call open() first.");
         }
     }
     
@@ -134,9 +132,8 @@ public class SinkQuadBracedOutput implem
     @Override
     public void close()
     {
-        if (!closed)
+        if (opened)
         {
-            checkOpen();
             if (null != currentGraph)
             {
                 out.decIndent(BLOCK_INDENT);
@@ -148,7 +145,7 @@ public class SinkQuadBracedOutput implem
             
             // Since we didn't create the OutputStream, we'll just flush it
             flush();
-            closed = true;
+            opened = false;
         }
     }
 }