jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1384797 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint: Constraints.java ReferenceConstraint.java
Date Fri, 14 Sep 2012 14:23:55 GMT
Author: mduerig
Date: Fri Sep 14 14:23:54 2012
New Revision: 1384797

URL: http://svn.apache.org/viewvc?rev=1384797&view=rev
Log:
OAK-66: JCR Node Type Management
reference constraints

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ReferenceConstraint.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/Constraints.java

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=1384797&r1=1384796&r2=1384797&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 14 14:23:54 2012
@@ -17,12 +17,9 @@
 package org.apache.jackrabbit.oak.plugins.type.constraint;
 
 import javax.jcr.PropertyType;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 
 import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import org.apache.jackrabbit.oak.util.TODO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,29 +32,29 @@ public class Constraints {
     public static Predicate<Value> valueConstraint(int type, String constraint) {
         switch (type) {
             case PropertyType.STRING:
-                return stringConstraint(constraint);
+                return new StringConstraint(constraint);
             case PropertyType.BINARY:
-                return binaryConstraint(constraint);
+                return new BinaryConstraint(constraint);
             case PropertyType.LONG:
-                return longConstraint(constraint);
+                return new LongConstraint(constraint);
             case PropertyType.DOUBLE:
-                return doubleConstraint(constraint);
+                return new DoubleConstraint(constraint);
             case PropertyType.DATE:
-                return dateConstraint(constraint);
+                return new DateConstraint(constraint);
             case PropertyType.BOOLEAN:
-                return booleanConstraint(constraint);
+                return new BooleanConstraint(constraint);
             case PropertyType.NAME:
-                return nameConstraint(constraint);
+                return new NameConstraint(constraint);
             case PropertyType.PATH:
-                return pathConstraint(constraint);
+                return new PathConstraint(constraint);
             case PropertyType.REFERENCE:
-                return referenceConstraint(constraint);
+                return new ReferenceConstraint(constraint);
             case PropertyType.WEAKREFERENCE:
-                return weakRefConstraint(constraint);
+                return new ReferenceConstraint(constraint);
             case PropertyType.URI:
-                return uriConstraint(constraint);
+                return new StringConstraint(constraint);
             case PropertyType.DECIMAL:
-                return decimalConstraint(constraint);
+                return new DecimalConstraint(constraint);
             default:
                 String msg = "Invalid property type: " + type;
                 log.warn(msg);
@@ -65,65 +62,4 @@ public class Constraints {
         }
     }
 
-    private static Predicate<Value> stringConstraint(String constraint) {
-        return new StringConstraint(constraint);
-    }
-
-    private static Predicate<Value> binaryConstraint(String constraint) {
-        return new BinaryConstraint(constraint);
-    }
-
-    private static Predicate<Value> longConstraint(String constraint) {
-        return new LongConstraint(constraint);
-    }
-
-    private static Predicate<Value> doubleConstraint(String constraint) {
-        return new DoubleConstraint(constraint);
-    }
-
-    private static Predicate<Value> dateConstraint(String constraint) {
-        return new DateConstraint(constraint);
-    }
-
-    private static BooleanConstraint booleanConstraint(String constraint) {
-        return new BooleanConstraint(constraint);
-    }
-
-    private static Predicate<Value> nameConstraint(String constraint) {
-        return new NameConstraint(constraint);
-    }
-
-    private static Predicate<Value> pathConstraint(String constraint) {
-        return new PathConstraint(constraint);
-    }
-
-    private static Predicate<Value> referenceConstraint(String constraint) {
-        try {
-            // todo implement referenceConstraint
-            Predicate<Value> truePredicate = Predicates.alwaysTrue();
-            return TODO.dummyImplementation().returnValue(truePredicate);
-        }
-        catch (UnsupportedRepositoryOperationException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-
-    private static Predicate<Value> weakRefConstraint(String constraint) {
-        try {
-            // todo implement referenceConstraint
-            Predicate<Value> truePredicate = Predicates.alwaysTrue();
-            return TODO.dummyImplementation().returnValue(truePredicate);
-        }
-        catch (UnsupportedRepositoryOperationException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-
-    private static Predicate<Value> uriConstraint(String constraint) {
-        return new StringConstraint(constraint);
-    }
-
-    private static Predicate<Value> decimalConstraint(String constraint) {
-        return new DecimalConstraint(constraint);
-    }
 }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ReferenceConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ReferenceConstraint.java?rev=1384797&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ReferenceConstraint.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/constraint/ReferenceConstraint.java
Fri Sep 14 14:23:54 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.Value;
+
+import com.google.common.base.Predicate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ReferenceConstraint implements Predicate<Value> {
+    private static final Logger log = LoggerFactory.getLogger(ReferenceConstraint.class);
+
+    private final String requiredTargetType;
+
+    public ReferenceConstraint(String definition)  {
+        requiredTargetType = definition;
+    }
+
+    @Override
+    public boolean apply(Value value) {
+        // TODO implement ReferenceConstraint
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return '\'' + requiredTargetType + '\'';
+    }
+}

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

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



Mime
View raw message