jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1381993 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ oak-jcr/
Date Fri, 07 Sep 2012 12:19:11 GMT
Author: mduerig
Date: Fri Sep  7 12:19:11 2012
New Revision: 1381993

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

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
  (with props)
Modified:
    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/NumericConstraint.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Added: 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=1381993&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
Fri Sep  7 12:19:11 2012
@@ -0,0 +1,32 @@
+/*
+ * 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.jackrabbit.oak.plugins.type.constraint;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+public class BinaryConstraint extends LongConstraint {
+    public BinaryConstraint(String definition) {
+        super(definition);
+    }
+
+    @Override
+    protected Long getValue(Value value) throws RepositoryException {
+        return value.getBinary().getSize();
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/BinaryConstraint.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

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=1381993&r1=1381992&r2=1381993&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:19:11 2012
@@ -68,7 +68,7 @@ public class Constraints {
     }
 
     private static Predicate<Value> binaryConstraint(String constraint) {
-        return Predicates.alwaysTrue(); // todo implement binaryConstraint
+        return new BinaryConstraint(constraint);
     }
 
     private static Predicate<Value> longConstraint(String constraint) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/NumericConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/NumericConstraint.java?rev=1381993&r1=1381992&r2=1381993&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/NumericConstraint.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/NumericConstraint.java
Fri Sep  7 12:19:11 2012
@@ -38,21 +38,19 @@ public abstract class NumericConstraint<
 
     protected NumericConstraint(String definition) {
         // format: '(<min>, <max>)',  '[<min>, <max>]', '(, <max>)'
etc.
-        Pattern pattern = Pattern.compile("([\\(\\[])[^,]*,[^\\)\\]]*([\\)\\]])");
+        Pattern pattern = Pattern.compile("([\\(\\[])([^,]*),([^\\)\\]]*)([\\)\\]])");
         Matcher matcher = pattern.matcher(definition);
         if (matcher.matches()) {
             try {
-                // group 1 is lower inclusive/exclusive
-                String match = matcher.group(1);
-                lowerInclusive = "[".equals(match);
+                // group 1 is lower bound inclusive/exclusive
+                lowerInclusive = "[".equals(matcher.group(1));
 
-                // group 2 is lower, group 3 is upper  bound
+                // group 2 is lower, group 3 is upper bound
                 lowerBound = getBound(matcher.group(2));
                 upperBound = getBound(matcher.group(3));
 
-                // group 4 is lower inclusive/exclusive
-                match = matcher.group(4);
-                upperInclusive = "]".equals(match);
+                // group 4 is upper bound inclusive/exclusive
+                upperInclusive = "]".equals(matcher.group(4));
             }
             catch (NumberFormatException e) {
                 invalid(definition);

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1381993&r1=1381992&r2=1381993&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Fri Sep  7 12:19:11 2012
@@ -73,7 +73,6 @@ org.apache.jackrabbit.test.api.lock.Lock
 org.apache.jackrabbit.test.api.SetPropertyConstraintViolationExceptionTest<!-- OAK-66
-->
 org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest<!-- OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.PropertyDefTest#testIsMandatory
-org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBinaryTest#testValueConstraintNotSatisfied<!--
OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBinaryTest#testValueConstraintNotSatisfiedMultiple<!--
OAK-66 -->
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyDateTest#testConversions
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyPathTest#testConversions



Mime
View raw message