jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1324654 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
Date Wed, 11 Apr 2012 08:59:34 GMT
Author: thomasm
Date: Wed Apr 11 08:59:33 2012
New Revision: 1324654

URL: http://svn.apache.org/viewvc?rev=1324654&view=rev
Log:
OAK-33: Values in oak-core (formatting; not ignore exceptions; "TODO" instead of "todo")

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java?rev=1324654&r1=1324653&r2=1324654&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
Wed Apr 11 08:59:33 2012
@@ -25,12 +25,16 @@ import org.apache.jackrabbit.oak.api.Sca
 
 public abstract class ScalarImpl implements Scalar {
 
+    private static final NullScalar NULL_SCALAR = new NullScalar();
+
+    private static final BooleanScalar TRUE_SCALAR = new BooleanScalar(true);
+    private static final BooleanScalar FALSE_SCALAR = new BooleanScalar(false);
+
     public static Scalar numberScalar(String value) {
-        // todo improve
+        // TODO don't use exception handling for flow control
         try {
             return longScalar(Long.parseLong(value));
-        }
-        catch (NumberFormatException e) {
+        } catch (NumberFormatException e) {
             return doubleScalar(Double.parseDouble(value));
         }
     }
@@ -38,7 +42,7 @@ public abstract class ScalarImpl impleme
     public static Scalar booleanScalar(final boolean value) {
         return value ? TRUE_SCALAR : FALSE_SCALAR;
     }
-    
+
     public static Scalar longScalar(final long value) {
         return new LongScalar(value);
     }
@@ -46,25 +50,25 @@ public abstract class ScalarImpl impleme
     public static Scalar nullScalar() {
         return NULL_SCALAR;
     }
-    
+
     public static Scalar doubleScalar(final double value) {
         return new DoubleScalar(value);
     }
-    
+
     public static Scalar stringScalar(final String value) {
         if (value == null) {
             throw new IllegalArgumentException("Value must not be null");
         }
         return new StringScalar(value);
     }
-    
+
     public static Scalar binaryScalar(final String value) {
         if (value == null) {
             throw new IllegalArgumentException("Value must not be null");
         }
         return new SmallBinaryScalar(value);
     }
-    
+
     public static Scalar binaryScalar(final Callable<InputStream> valueProvider) {
         if (valueProvider == null) {
             throw new IllegalArgumentException("Value must not be null");
@@ -91,10 +95,9 @@ public abstract class ScalarImpl impleme
     public InputStream getInputStream() {
         try {
             return new ByteArrayInputStream(getString().getBytes("UTF-8"));
-        }
-        catch (UnsupportedEncodingException e) {
-            // todo handle UnsupportedEncodingException
-            return null;
+        } catch (UnsupportedEncodingException e) {
+            // TODO handle UnsupportedEncodingException
+            throw new RuntimeException(e);
         }
     }
 
@@ -105,9 +108,6 @@ public abstract class ScalarImpl impleme
 
     //------------------------------------------------------------< private >---
 
-    private static final BooleanScalar TRUE_SCALAR = new BooleanScalar(true);
-    private static final BooleanScalar FALSE_SCALAR = new BooleanScalar(false);
-
     private static final class BooleanScalar extends ScalarImpl {
         private final boolean value;
 
@@ -145,13 +145,11 @@ public abstract class ScalarImpl impleme
 
         @Override
         public int hashCode() {
-            return (value ? 1 : 0);
+            return value ? 1 : 0;
         }
     }
 
-    private static final NullScalar NULL_SCALAR = new NullScalar();
-
-    private static final class NullScalar extends ScalarImpl {
+    static final class NullScalar extends ScalarImpl {
 
         @Override
         public Type getType() {
@@ -353,16 +351,16 @@ public abstract class ScalarImpl impleme
         public InputStream getInputStream() {
             try {
                 return valueProvider.call();
-            }
-            catch (Exception e) {
-                // todo handle Exception
-                return null;
+            } catch (Exception e) {
+                // TODO handle Exception
+                throw new RuntimeException(e);
             }
         }
 
         @Override
         public String getString() {
-            return ""; // todo implement getString
+            // TODO implement getString
+            return "";
         }
 
         @Override



Mime
View raw message