jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1382001 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint: BinaryConstraint.java Constraints.java DecimalConstraint.java DoubleConstraint.java LongConstraint.java
Date Fri, 07 Sep 2012 12:55:27 GMT
Author: mduerig
Date: Fri Sep  7 12:55:27 2012
New Revision: 1382001

URL: http://svn.apache.org/viewvc?rev=1382001&view=rev
Log:
OAK-66: JCR Node Type Management
value constraints for Decimal

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DecimalConstraint.java
      - copied, changed from r1381993, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DoubleConstraint.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java?rev=1382001&r1=1382000&r2=1382001&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
Fri Sep  7 12:55:27 2012
@@ -28,5 +28,4 @@ public class BinaryConstraint extends Lo
     protected Long getValue(Value value) throws RepositoryException {
         return value.getBinary().getSize();
     }
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java?rev=1382001&r1=1382000&r2=1382001&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java
Fri Sep  7 12:55:27 2012
@@ -108,6 +108,6 @@ public class Constraints {
     }
 
     private static Predicate<Value> decimalConstraint(String constraint) {
-        return Predicates.alwaysTrue(); // todo implement decimalConstraint
+        return new DecimalConstraint(constraint);
     }
 }

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DecimalConstraint.java
(from r1381993, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DecimalConstraint.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DecimalConstraint.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java&r1=1381993&r2=1382001&rev=1382001&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DecimalConstraint.java
Fri Sep  7 12:55:27 2012
@@ -16,33 +16,35 @@
  */
 package org.apache.jackrabbit.oak.plugins.type.constraint;
 
+import java.math.BigDecimal;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LongConstraint extends NumericConstraint<Long> {
-    private static final Logger log = LoggerFactory.getLogger(LongConstraint.class);
-
-    public LongConstraint(String definition) {
+public class DecimalConstraint extends NumericConstraint<BigDecimal> {
+    public DecimalConstraint(String definition) {
         super(definition);
     }
 
     @Override
-    protected Long getBound(String bound) {
-        return  bound == null || bound.isEmpty()
+    protected BigDecimal getBound(String bound) {
+        return bound == null || bound.isEmpty()
             ? null
-            : Long.parseLong(bound);
+            : new BigDecimal(bound);
+    }
+
+    @Override
+    protected BigDecimal getValue(Value value) throws RepositoryException {
+        return value.getDecimal();
     }
 
     @Override
-    protected Long getValue(Value value) throws RepositoryException {
-        return value.getLong();
+    protected boolean less(BigDecimal val, BigDecimal bound) {
+        return val.compareTo(bound) < 0;
     }
 
     @Override
-    protected boolean less(Long val, Long bound) {
-        return val < bound;
+    protected boolean equals(BigDecimal val, BigDecimal bound) {
+        return val.compareTo(bound) == 0;
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DoubleConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DoubleConstraint.java?rev=1382001&r1=1382000&r2=1382001&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DoubleConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/DoubleConstraint.java
Fri Sep  7 12:55:27 2012
@@ -25,8 +25,8 @@ import org.slf4j.LoggerFactory;
 public class DoubleConstraint extends NumericConstraint<Double> {
     private static final Logger log = LoggerFactory.getLogger(DoubleConstraint.class);
 
-    public DoubleConstraint(String constraint) {
-        super(constraint);
+    public DoubleConstraint(String definition) {
+        super(definition);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java?rev=1382001&r1=1382000&r2=1382001&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/LongConstraint.java
Fri Sep  7 12:55:27 2012
@@ -31,7 +31,7 @@ public class LongConstraint extends Nume
 
     @Override
     protected Long getBound(String bound) {
-        return  bound == null || bound.isEmpty()
+        return bound == null || bound.isEmpty()
             ? null
             : Long.parseLong(bound);
     }



Mime
View raw message