jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [05/15] jena git commit: return 'this' for chaining style
Date Wed, 08 Feb 2017 12:50:13 GMT
return 'this' for chaining style


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/470bfc38
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/470bfc38
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/470bfc38

Branch: refs/heads/master
Commit: 470bfc38d94547507a0e2038050a7f224cff85df
Parents: 1085c89
Author: Andy Seaborne <andy@apache.org>
Authored: Tue Jan 31 19:28:33 2017 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Tue Jan 31 19:28:33 2017 +0000

----------------------------------------------------------------------
 .../org/apache/jena/atlas/json/io/JSWriter.java | 43 +++++++++++++-------
 1 file changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/470bfc38/jena-arq/src/main/java/org/apache/jena/atlas/json/io/JSWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/atlas/json/io/JSWriter.java b/jena-arq/src/main/java/org/apache/jena/atlas/json/io/JSWriter.java
index 10f1da8..521cfbc 100644
--- a/jena-arq/src/main/java/org/apache/jena/atlas/json/io/JSWriter.java
+++ b/jena-arq/src/main/java/org/apache/jena/atlas/json/io/JSWriter.java
@@ -70,13 +70,14 @@ public class JSWriter {
     // (object or array).
     Deque<AtomicBoolean> stack = new ArrayDeque<>() ;
 
-    public void startObject() {
+    public JSWriter startObject() {
         startCompound() ;
         out.print(ObjectStart) ;
         out.incIndent() ;
+        return this;
     }
 
-    public void finishObject() {
+    public JSWriter finishObject() {
         out.decIndent() ;
         if ( isFirst() )
             out.print(ObjectFinish) ;
@@ -85,9 +86,10 @@ public class JSWriter {
             out.println(ObjectFinish) ;
         }
         finishCompound() ;
+        return this;
     }
 
-    public void key(String key) {
+    public JSWriter key(String key) {
         if ( isFirst() ) {
             out.println() ;
             setNotFirst() ;
@@ -96,69 +98,80 @@ public class JSWriter {
         value(key) ;
         out.print(ObjectPairSep) ;
         // Ready to start the pair value.
+        return this;
     }
 
     // "Pair" is the name used in the JSON spec.
-    public void pair(String key, String value) {
+    public JSWriter pair(String key, String value) {
         key(key) ;
         value(value) ;
+        return this;
     }
 
-    public void pair(String key, boolean val) {
+    public JSWriter pair(String key, boolean val) {
         key(key) ;
         value(val) ;
+        return this;
     }
 
-    public void pair(String key, long val) {
+    public JSWriter pair(String key, long val) {
         key(key) ;
         value(val) ;
+        return this;
     }
     
-    public void pair(String key, Number val) {
+    public JSWriter pair(String key, Number val) {
         key(key) ;
         value(val) ;
+        return this;
     }
 
-    public void startArray() {
+    public JSWriter startArray() {
         startCompound() ;
         out.print(ArrayStart) ;
-        // Messy with objects out.incIndent() ;
+        return this;
     }
 
-    public void finishArray() {
+    public JSWriter finishArray() {
         // out.decIndent() ;
         out.print(ArrayFinish) ; // Leave on same line.
         finishCompound() ;
+        return this;
     }
 
-    public void arrayElement(String str) {
+    public JSWriter arrayElement(String str) {
         arrayElementProcess() ;
         value(str) ;
+        return this;
     }
 
-    private void arrayElementProcess() {
+    private JSWriter arrayElementProcess() {
         if ( isFirst() )
             setNotFirst() ;
         else
             out.print(ArraySep) ;
+        return this;
     }
 
-    public void arrayElement(boolean b) {
+    public JSWriter arrayElement(boolean b) {
         arrayElementProcess() ;
         value(b) ;
+        return this;
     }
 
-    public void arrayElement(long integer) {
+    public JSWriter arrayElement(long integer) {
         arrayElementProcess() ;
         value(integer) ;
+        return this;
     }
 
     /**
      * Useful if you are manually creating arrays and so need to print array
      * separators yourself
      */
-    public void arraySep() {
+    public JSWriter arraySep() {
         out.print(ArraySep) ;
+        return this;
     }
 
     public static String outputQuotedString(String string) {


Mime
View raw message