You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2017/01/01 13:58:20 UTC

[2/6] jena git commit: Replacing only use of Ref with AtomicBoolean

Replacing only use of Ref with AtomicBoolean


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

Branch: refs/heads/master
Commit: 2f9759eb8ea37e6e9ac48b619f90cc65bbfe31b8
Parents: d753a3e
Author: ajs6f <aj...@virginia.edu>
Authored: Fri Dec 23 15:10:39 2016 -0500
Committer: ajs6f <aj...@virginia.edu>
Committed: Fri Dec 23 15:10:39 2016 -0500

----------------------------------------------------------------------
 .../org/apache/jena/atlas/json/io/JSWriter.java | 11 ++--
 .../java/org/apache/jena/atlas/lib/Ref.java     | 54 --------------------
 2 files changed, 5 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2f9759eb/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 25e52d3..10f1da8 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
@@ -26,12 +26,11 @@ import java.io.OutputStream ;
 import java.math.BigDecimal ;
 import java.util.ArrayDeque ;
 import java.util.Deque ;
-
+import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.jena.atlas.io.IndentedLineBuffer ;
 import org.apache.jena.atlas.io.IndentedWriter ;
 import org.apache.jena.atlas.lib.BitsInt ;
 import org.apache.jena.atlas.lib.Chars ;
-import org.apache.jena.atlas.lib.Ref ;
 
 /**
  * A low level streaming JSON writer - assumes correct sequence of calls (e.g.
@@ -69,7 +68,7 @@ public class JSWriter {
 
     // Remember whether we are in the first element of a compound 
     // (object or array).
-    Deque<Ref<Boolean>> stack = new ArrayDeque<>() ;
+    Deque<AtomicBoolean> stack = new ArrayDeque<>() ;
 
     public void startObject() {
         startCompound() ;
@@ -277,7 +276,7 @@ public class JSWriter {
     }
 
     private void startCompound() {
-        stack.push(new Ref<>(true)) ;
+        stack.push(new AtomicBoolean(true)) ;
     }
 
     private void finishCompound() {
@@ -285,11 +284,11 @@ public class JSWriter {
     }
 
     private boolean isFirst() {
-        return stack.peek().getValue() ;
+        return stack.peek().get() ;
     }
 
     private void setNotFirst() {
-        stack.peek().setValue(false) ;
+        stack.peek().set(false) ;
     }
 
     private void value(String x) {

http://git-wip-us.apache.org/repos/asf/jena/blob/2f9759eb/jena-base/src/main/java/org/apache/jena/atlas/lib/Ref.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/Ref.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/Ref.java
deleted file mode 100644
index e25b145..0000000
--- a/jena-base/src/main/java/org/apache/jena/atlas/lib/Ref.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.atlas.lib;
-
-
-/** A mutable container */
-public class Ref<T>
-{
-    private T value ;
-
-    public T getValue() { return value; }
-
-    public Ref(T initial)
-    { setValue(initial); }
-
-    public void setValue(T value)
-    { this.value = value; }
-
-    
-    // hashCode and equality are defined on object pointers. 
-//    @Override
-//    public int hashCode() { return value.hashCode()^0x1 ; }
-//    
-//    @Override
-//    public boolean equals(Object other)
-//    {
-//        if ( !(  other instanceof Ref ) )
-//            return false ;
-//        Ref<?> r = (Ref<?>)other ;
-//        return Lib.equals(value, r.value) ;
-//    }
-    
-    @Override
-    public String toString()
-    {
-        return "ref:"+value.toString() ; 
-    }
-}