You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/08/31 13:06:53 UTC
svn commit: r991157 [1/2] - in /jackrabbit/branches/2.1: ./
jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/
jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/
jackrabbit-standalone/src/main/java/...
Author: jukka
Date: Tue Aug 31 11:06:52 2010
New Revision: 991157
URL: http://svn.apache.org/viewvc?rev=991157&view=rev
Log:
2.1: Add missing svn:eol-style settings.
Modified:
jackrabbit/branches/2.1/ (props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java (contents, props changed)
jackrabbit/branches/2.1/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp (contents, props changed)
Propchange: jackrabbit/branches/2.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 31 11:06:52 2010
@@ -2,4 +2,4 @@
/jackrabbit/sandbox/JCR-1456:774917-886178
/jackrabbit/sandbox/JCR-2170:812417-816332
/jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694,934405,934412,934849,935557,936668,938099,945528,950440,955222,955229,955307,955852,961487,961626,964362,965539,986682,986686,986715
+/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694,934405,934412,934849,935557,936668,938099,945528,950440,955222,955229,955307,955852,961487,961626,964362,965539,986682,986686,986715,991144
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java Tue Aug 31 11:06:52 2010
@@ -1,75 +1,75 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-/**
- * Filter that checks the declared type of an item
- *
- */
-public class DeclaringTypePredicate extends DepthPredicate {
-
- /**
- * The nodetype to check
- */
- protected final String nodeType;
-
- /**
- * indicates if only props should be checked
- */
- protected final boolean propsOnly;
-
- /**
- * Creates a new filter for the given nodetype and flags.
- * @param nodeType the nodetype name to check
- * @param propsOnly if <code>true</code> only properties are checked
- * @param minDepth the minimal depth
- * @param maxDepth the maximal depth
- */
- public DeclaringTypePredicate(String nodeType, boolean propsOnly,
- int minDepth, int maxDepth) {
- super(minDepth, maxDepth);
- this.nodeType = nodeType;
- this.propsOnly = propsOnly;
- }
-
- /**
- * Creates a new filter for the given nodetype and flags
- * @param nodeType the nodetype name to check
- * @param propsOnly if <code>true</code> only properties are checked
- */
- public DeclaringTypePredicate(String nodeType, boolean propsOnly) {
- this(nodeType, propsOnly, 0, Integer.MAX_VALUE);
- }
-
- /**
- * Matches if the declaring nodetype of the item is equal to the one
- * specified in this filter. If the item is a node and <code>propsOnly</code>
- * flag is <code>true</code> it returns <code>false</code>.
- * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
- */
- protected boolean matches(Item item) throws RepositoryException {
- if (item.isNode()) {
- return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType);
- }
- return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType);
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * Filter that checks the declared type of an item
+ *
+ */
+public class DeclaringTypePredicate extends DepthPredicate {
+
+ /**
+ * The nodetype to check
+ */
+ protected final String nodeType;
+
+ /**
+ * indicates if only props should be checked
+ */
+ protected final boolean propsOnly;
+
+ /**
+ * Creates a new filter for the given nodetype and flags.
+ * @param nodeType the nodetype name to check
+ * @param propsOnly if <code>true</code> only properties are checked
+ * @param minDepth the minimal depth
+ * @param maxDepth the maximal depth
+ */
+ public DeclaringTypePredicate(String nodeType, boolean propsOnly,
+ int minDepth, int maxDepth) {
+ super(minDepth, maxDepth);
+ this.nodeType = nodeType;
+ this.propsOnly = propsOnly;
+ }
+
+ /**
+ * Creates a new filter for the given nodetype and flags
+ * @param nodeType the nodetype name to check
+ * @param propsOnly if <code>true</code> only properties are checked
+ */
+ public DeclaringTypePredicate(String nodeType, boolean propsOnly) {
+ this(nodeType, propsOnly, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Matches if the declaring nodetype of the item is equal to the one
+ * specified in this filter. If the item is a node and <code>propsOnly</code>
+ * flag is <code>true</code> it returns <code>false</code>.
+ * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ if (item.isNode()) {
+ return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType);
+ }
+ return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType);
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DeclaringTypePredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java Tue Aug 31 11:06:52 2010
@@ -1,77 +1,77 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-
-/**
- * Implements a filter that filters item according to their (passed) depth.
- *
- */
-public class DepthPredicate implements Predicate {
-
- /**
- * The minimal depth
- */
- protected final int minDepth;
-
- /**
- * The maximal depth
- */
- protected final int maxDepth;
-
- /**
- * Creates a new depth filter for the given depths.
- * @param minDepth the minimal depth
- * @param maxDepth the maximal depth
- */
- public DepthPredicate(int minDepth, int maxDepth) {
- this.minDepth = minDepth;
- this.maxDepth = maxDepth;
- }
-
- /**
- * Matches if the given depth is greater or equal the minimum depth and
- * less or equal the maximum depth and if the call to {@link #matches(Item)}
- * returns <code>true</code>.
- * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
- */
- public boolean evaluate(Object item) {
- if ( item instanceof Item ) {
- try {
- final int depth = ((Item)item).getDepth();
- return depth >= minDepth && depth <= maxDepth && matches((Item)item);
- } catch (RepositoryException re) {
- return false;
- }
- }
- return false;
- }
-
- /**
- * Returns <code>true</code>. Subclasses can override to implement something
- * useful that is dependant of the depth.
- *
- * @param item the item to match
- * @return <code>true</code> if the item matches; <code>false</code> otherwise.
- * @throws RepositoryException if an error occurs.
- */
- protected boolean matches(Item item) throws RepositoryException {
- return true;
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+
+/**
+ * Implements a filter that filters item according to their (passed) depth.
+ *
+ */
+public class DepthPredicate implements Predicate {
+
+ /**
+ * The minimal depth
+ */
+ protected final int minDepth;
+
+ /**
+ * The maximal depth
+ */
+ protected final int maxDepth;
+
+ /**
+ * Creates a new depth filter for the given depths.
+ * @param minDepth the minimal depth
+ * @param maxDepth the maximal depth
+ */
+ public DepthPredicate(int minDepth, int maxDepth) {
+ this.minDepth = minDepth;
+ this.maxDepth = maxDepth;
+ }
+
+ /**
+ * Matches if the given depth is greater or equal the minimum depth and
+ * less or equal the maximum depth and if the call to {@link #matches(Item)}
+ * returns <code>true</code>.
+ * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
+ */
+ public boolean evaluate(Object item) {
+ if ( item instanceof Item ) {
+ try {
+ final int depth = ((Item)item).getDepth();
+ return depth >= minDepth && depth <= maxDepth && matches((Item)item);
+ } catch (RepositoryException re) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code>. Subclasses can override to implement something
+ * useful that is dependant of the depth.
+ *
+ * @param item the item to match
+ * @return <code>true</code> if the item matches; <code>false</code> otherwise.
+ * @throws RepositoryException if an error occurs.
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ return true;
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/DepthPredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java Tue Aug 31 11:06:52 2010
@@ -1,54 +1,54 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-/**
- * <code>IsMandatoryFilter</code>...
- *
- */
-public class IsMandatoryPredicate extends DepthPredicate {
-
- protected final boolean isMandatory;
-
- public IsMandatoryPredicate() {
- this(true);
- }
-
- public IsMandatoryPredicate(boolean isMandatory, int minDepth, int maxDepth) {
- super(minDepth, maxDepth);
- this.isMandatory = isMandatory;
- }
-
- public IsMandatoryPredicate(boolean isMandatory) {
- this(isMandatory, 0, Integer.MAX_VALUE);
- }
-
- /**
- * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
- */
- protected boolean matches(Item item) throws RepositoryException {
- if (item.isNode()) {
- return ((Node) item).getDefinition().isMandatory() == isMandatory;
- }
- return ((Property) item).getDefinition().isMandatory() == isMandatory;
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>IsMandatoryFilter</code>...
+ *
+ */
+public class IsMandatoryPredicate extends DepthPredicate {
+
+ protected final boolean isMandatory;
+
+ public IsMandatoryPredicate() {
+ this(true);
+ }
+
+ public IsMandatoryPredicate(boolean isMandatory, int minDepth, int maxDepth) {
+ super(minDepth, maxDepth);
+ this.isMandatory = isMandatory;
+ }
+
+ public IsMandatoryPredicate(boolean isMandatory) {
+ this(isMandatory, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ if (item.isNode()) {
+ return ((Node) item).getDefinition().isMandatory() == isMandatory;
+ }
+ return ((Property) item).getDefinition().isMandatory() == isMandatory;
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsMandatoryPredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java Tue Aug 31 11:06:52 2010
@@ -1,72 +1,72 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-
-/**
- * Item filter that checks if an item is a node.
- *
- */
-public class IsNodePredicate extends DepthPredicate {
-
- /**
- * Polarity of this filter
- */
- protected final boolean isNode;
-
- /**
- * Default constructor.
- */
- public IsNodePredicate() {
- this(true);
- }
-
- /**
- * Creates a new node item filter.
- *
- * @param polarity the polarity of this filter. if <code>true</code> it matches
- * nodes, if <code>false</code> it matches properties.
- * @param minDepth the minimum depth
- * @param maxDepth the maximum depth
- *
- * @see DepthPredicate
- */
- public IsNodePredicate(boolean polarity, int minDepth, int maxDepth) {
- super(minDepth, maxDepth);
- isNode = polarity;
- }
-
- /**
- * Creates a new node item filter
- * @param polarity the polarity of this filter. if <code>true</code> it matches
- * nodes, if <code>false</code> it matches properties.
- */
- public IsNodePredicate(boolean polarity) {
- this(polarity, 0, Integer.MAX_VALUE);
- }
-
- /**
- * Returns <code>true</code> if the item is a node and the polarity is
- * positive (true).
- * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
- */
- protected boolean matches(Item item) throws RepositoryException {
- return item.isNode() == isNode;
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+
+/**
+ * Item filter that checks if an item is a node.
+ *
+ */
+public class IsNodePredicate extends DepthPredicate {
+
+ /**
+ * Polarity of this filter
+ */
+ protected final boolean isNode;
+
+ /**
+ * Default constructor.
+ */
+ public IsNodePredicate() {
+ this(true);
+ }
+
+ /**
+ * Creates a new node item filter.
+ *
+ * @param polarity the polarity of this filter. if <code>true</code> it matches
+ * nodes, if <code>false</code> it matches properties.
+ * @param minDepth the minimum depth
+ * @param maxDepth the maximum depth
+ *
+ * @see DepthPredicate
+ */
+ public IsNodePredicate(boolean polarity, int minDepth, int maxDepth) {
+ super(minDepth, maxDepth);
+ isNode = polarity;
+ }
+
+ /**
+ * Creates a new node item filter
+ * @param polarity the polarity of this filter. if <code>true</code> it matches
+ * nodes, if <code>false</code> it matches properties.
+ */
+ public IsNodePredicate(boolean polarity) {
+ this(polarity, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Returns <code>true</code> if the item is a node and the polarity is
+ * positive (true).
+ * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ return item.isNode() == isNode;
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/IsNodePredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java Tue Aug 31 11:06:52 2010
@@ -1,60 +1,60 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-
-/**
- * Filters items according to their names.
- *
- */
-public class NamePredicate extends DepthPredicate {
-
- /**
- * The name to filter on
- */
- protected final String name;
-
- /**
- * Creates a new name filter with the given name and depths
- * @param name the name to filter on
- * @param minDepth the minimal depth
- * @param maxDepth the maximal depth
- */
- public NamePredicate(String name, int minDepth, int maxDepth) {
- super(minDepth, maxDepth);
- this.name = name;
- }
-
- /**
- * Creates a new name filter with the given name.
- * @param name the name to filter on
- */
- public NamePredicate(String name) {
- this(name, 0, Integer.MAX_VALUE);
- }
-
- /**
- * Returns <code>true</code> if the name of the given item is equal to
- * the configured name.
- * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
- */
- protected boolean matches(Item item) throws RepositoryException {
- return item.getName().equals(name);
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+
+/**
+ * Filters items according to their names.
+ *
+ */
+public class NamePredicate extends DepthPredicate {
+
+ /**
+ * The name to filter on
+ */
+ protected final String name;
+
+ /**
+ * Creates a new name filter with the given name and depths
+ * @param name the name to filter on
+ * @param minDepth the minimal depth
+ * @param maxDepth the maximal depth
+ */
+ public NamePredicate(String name, int minDepth, int maxDepth) {
+ super(minDepth, maxDepth);
+ this.name = name;
+ }
+
+ /**
+ * Creates a new name filter with the given name.
+ * @param name the name to filter on
+ */
+ public NamePredicate(String name) {
+ this(name, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Returns <code>true</code> if the name of the given item is equal to
+ * the configured name.
+ * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ return item.getName().equals(name);
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NamePredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java Tue Aug 31 11:06:52 2010
@@ -1,84 +1,84 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-/**
- * Filters on the node type of a node.
- *
- */
-public class NodeTypePredicate extends DepthPredicate {
-
- /**
- * the nodetype to filter on
- */
- protected final String nodeType;
-
- /**
- * indicates if supertypes should be respected
- */
- protected final boolean respectSupertype;
-
- /**
- * Creates a new node type filter.
- * @param nodeType the node type to filter on
- * @param respectSupertype indicates if supertype should be respected
- * @param minDepth the minimal depth
- * @param maxDepth the maximal depth
- */
- public NodeTypePredicate(String nodeType, boolean respectSupertype,
- int minDepth, int maxDepth) {
- super(minDepth, maxDepth);
- this.nodeType = nodeType;
- this.respectSupertype = respectSupertype;
- }
-
- /**
- * Creates a new node type filter.
- * @param nodeType the node type to filter on
- * @param respectSupertype indicates if supertype should be respected
- */
- public NodeTypePredicate(String nodeType, boolean respectSupertype) {
- this(nodeType, respectSupertype, 0, Integer.MAX_VALUE);
- }
-
- /**
- * Returns <code>true</code> if the item is a node and if the configured
- * nodetype is equal to the primary type of the node. if supertypes are
- * respected it also returns <code>true</code> if the items nodetype
- * extends from the configured node type (Node.isNodeType() check).
- * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
- */
- protected boolean matches(Item item) throws RepositoryException {
- if (item.isNode()) {
- if (respectSupertype) {
- try {
- return ((Node) item).isNodeType(nodeType);
- } catch (RepositoryException e) {
- // ignore
- return false;
- }
- }
- return ((Node) item).getPrimaryNodeType().getName().equals(nodeType);
- }
- return false;
-
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * Filters on the node type of a node.
+ *
+ */
+public class NodeTypePredicate extends DepthPredicate {
+
+ /**
+ * the nodetype to filter on
+ */
+ protected final String nodeType;
+
+ /**
+ * indicates if supertypes should be respected
+ */
+ protected final boolean respectSupertype;
+
+ /**
+ * Creates a new node type filter.
+ * @param nodeType the node type to filter on
+ * @param respectSupertype indicates if supertype should be respected
+ * @param minDepth the minimal depth
+ * @param maxDepth the maximal depth
+ */
+ public NodeTypePredicate(String nodeType, boolean respectSupertype,
+ int minDepth, int maxDepth) {
+ super(minDepth, maxDepth);
+ this.nodeType = nodeType;
+ this.respectSupertype = respectSupertype;
+ }
+
+ /**
+ * Creates a new node type filter.
+ * @param nodeType the node type to filter on
+ * @param respectSupertype indicates if supertype should be respected
+ */
+ public NodeTypePredicate(String nodeType, boolean respectSupertype) {
+ this(nodeType, respectSupertype, 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Returns <code>true</code> if the item is a node and if the configured
+ * nodetype is equal to the primary type of the node. if supertypes are
+ * respected it also returns <code>true</code> if the items nodetype
+ * extends from the configured node type (Node.isNodeType() check).
+ * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item)
+ */
+ protected boolean matches(Item item) throws RepositoryException {
+ if (item.isNode()) {
+ if (respectSupertype) {
+ try {
+ return ((Node) item).isNodeType(nodeType);
+ } catch (RepositoryException e) {
+ // ignore
+ return false;
+ }
+ }
+ return ((Node) item).getPrimaryNodeType().getName().equals(nodeType);
+ }
+ return false;
+
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NodeTypePredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java Tue Aug 31 11:06:52 2010
@@ -1,116 +1,116 @@
-/*
- * 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.commons.predicate;
-
-import javax.jcr.Item;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-/**
- * The nt file item filter matches all properties that are defined my the
- * nt:file or nt:resource nodetype. the later only, if the respective nodes
- * name is 'jcr:content'.
- *
- * Additionally the properties 'jcr:encoding' can be configured to be excluded.
- *
- */
-public class NtFilePredicate implements Predicate {
-
- public static final String NT_FILE = "nt:file";
- public static final String NT_HIERARCHYNODE = "nt:hierarchyNode";
- public static final String NT_RESOURCE = "nt:resource";
- public static final String JCR_CONTENT = "jcr:content";
- public static final String JCR_ENCODING = "jcr:encoding";
- public static final String JCR_MIMETYPE = "jcr:mimeType";
- public static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
-
- /**
- * indicates if the jcr:encoding property is to be excluded from this filter.
- */
- protected final boolean ignoreEncoding;
-
- /**
- * indicates if the jcr:mimeType property is to be excluded from this filter.
- */
- protected final boolean ignoreMimeType;
-
- public NtFilePredicate() {
- this(false, false);
- }
-
- public NtFilePredicate(boolean ignoreEncoding, boolean ignoreMimeType) {
- this.ignoreEncoding = ignoreEncoding;
- this.ignoreMimeType = ignoreMimeType;
- }
-
- /**
- * Returns the <code>ignore encoding</code> flag.
- * @return the <code>ignore encoding</code> flag.
- */
- public boolean isIgnoreEncoding() {
- return ignoreEncoding;
- }
-
- /**
- * Returns the <code>ignore mime type</code> flag.
- * @return the <code>ignore mime type</code> flag.
- */
- public boolean isIgnoreMimeType() {
- return ignoreMimeType;
- }
-
- /**
- * @return <code>true</code> if the item is a nt:file or nt:resource property
- * @see org.apache.jackrabbit.commons.predicate.Predicate#evaluate(java.lang.Object)
- */
- public boolean evaluate(Object item) {
- if ( item instanceof Item ) {
- if (!((Item)item).isNode()) {
- try {
- Property prop = (Property) item;
- String dnt = prop.getDefinition().getDeclaringNodeType().getName();
- // exclude all nt:file props
- if (dnt.equals(NT_FILE) || dnt.equals(NT_HIERARCHYNODE)) {
- return true;
- }
- if (ignoreEncoding && prop.getName().equals(JCR_ENCODING)) {
- return false;
- }
- if (ignoreMimeType && prop.getName().equals(JCR_MIMETYPE)) {
- return false;
- }
- // exclude nt:resource props, if parent is 'jcr:content'
- if (prop.getParent().getName().equals(JCR_CONTENT)) {
- if (dnt.equals(NT_RESOURCE)) {
- return true;
- }
- // exclude primary type if nt:resource
- /*
- if (prop.getName().equals(JCR_PRIMARY_TYPE)
- && prop.getValue().getString().equals(NT_RESOURCE)) {
- return true;
- }
- */
- }
- } catch (RepositoryException re) {
- return false;
- }
- }
- }
- return false;
- }
+/*
+ * 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.commons.predicate;
+
+import javax.jcr.Item;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * The nt file item filter matches all properties that are defined my the
+ * nt:file or nt:resource nodetype. the later only, if the respective nodes
+ * name is 'jcr:content'.
+ *
+ * Additionally the properties 'jcr:encoding' can be configured to be excluded.
+ *
+ */
+public class NtFilePredicate implements Predicate {
+
+ public static final String NT_FILE = "nt:file";
+ public static final String NT_HIERARCHYNODE = "nt:hierarchyNode";
+ public static final String NT_RESOURCE = "nt:resource";
+ public static final String JCR_CONTENT = "jcr:content";
+ public static final String JCR_ENCODING = "jcr:encoding";
+ public static final String JCR_MIMETYPE = "jcr:mimeType";
+ public static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
+
+ /**
+ * indicates if the jcr:encoding property is to be excluded from this filter.
+ */
+ protected final boolean ignoreEncoding;
+
+ /**
+ * indicates if the jcr:mimeType property is to be excluded from this filter.
+ */
+ protected final boolean ignoreMimeType;
+
+ public NtFilePredicate() {
+ this(false, false);
+ }
+
+ public NtFilePredicate(boolean ignoreEncoding, boolean ignoreMimeType) {
+ this.ignoreEncoding = ignoreEncoding;
+ this.ignoreMimeType = ignoreMimeType;
+ }
+
+ /**
+ * Returns the <code>ignore encoding</code> flag.
+ * @return the <code>ignore encoding</code> flag.
+ */
+ public boolean isIgnoreEncoding() {
+ return ignoreEncoding;
+ }
+
+ /**
+ * Returns the <code>ignore mime type</code> flag.
+ * @return the <code>ignore mime type</code> flag.
+ */
+ public boolean isIgnoreMimeType() {
+ return ignoreMimeType;
+ }
+
+ /**
+ * @return <code>true</code> if the item is a nt:file or nt:resource property
+ * @see org.apache.jackrabbit.commons.predicate.Predicate#evaluate(java.lang.Object)
+ */
+ public boolean evaluate(Object item) {
+ if ( item instanceof Item ) {
+ if (!((Item)item).isNode()) {
+ try {
+ Property prop = (Property) item;
+ String dnt = prop.getDefinition().getDeclaringNodeType().getName();
+ // exclude all nt:file props
+ if (dnt.equals(NT_FILE) || dnt.equals(NT_HIERARCHYNODE)) {
+ return true;
+ }
+ if (ignoreEncoding && prop.getName().equals(JCR_ENCODING)) {
+ return false;
+ }
+ if (ignoreMimeType && prop.getName().equals(JCR_MIMETYPE)) {
+ return false;
+ }
+ // exclude nt:resource props, if parent is 'jcr:content'
+ if (prop.getParent().getName().equals(JCR_CONTENT)) {
+ if (dnt.equals(NT_RESOURCE)) {
+ return true;
+ }
+ // exclude primary type if nt:resource
+ /*
+ if (prop.getName().equals(JCR_PRIMARY_TYPE)
+ && prop.getValue().getString().equals(NT_RESOURCE)) {
+ return true;
+ }
+ */
+ }
+ } catch (RepositoryException re) {
+ return false;
+ }
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/NtFilePredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java Tue Aug 31 11:06:52 2010
@@ -1,77 +1,77 @@
-/*
- * 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.commons.predicate;
-
-import java.util.regex.Pattern;
-
-import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-
-/**
- * The path filter provides hierarchical filtering.
- *
- */
-public class PathPredicate implements Predicate {
-
- /**
- * the internal regex pattern
- */
- protected final Pattern regex;
-
- /**
- * Creates a new default path filter
- * <xmp>
- * | Pattern | Matches
- * | /foo | exactly "/foo"
- * | /foo.* | all paths starting with "foo."
- * | foo.* | all files starting with "foo."
- * | /foo/* | all direct children of /foo
- * | /foo/** | all children of /foo
- * </xmp>
- * @param pattern the pattern
- */
- public PathPredicate(String pattern) {
- String suffix = "";
- String prefix = "";
- if (pattern.endsWith("/**")) {
- suffix = "/.*";
- pattern = pattern.substring(0, pattern.length() - 3);
- } else if (pattern.endsWith("*")) {
- suffix = "[^/]*$";
- pattern = pattern.substring(0, pattern.length() - 1);
- }
- if (pattern.charAt(0) != '/') {
- prefix = "^.*/";
- }
- pattern = prefix + pattern.replaceAll("\\.", "\\\\.") + suffix;
- regex = Pattern.compile(pattern);
- }
-
- /**
- * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
- */
- public boolean evaluate(Object item) {
- if ( item instanceof Item ) {
- try {
- return regex.matcher(((Item)item).getPath()).matches();
- } catch (RepositoryException re) {
- return false;
- }
- }
- return false;
- }
+/*
+ * 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.commons.predicate;
+
+import java.util.regex.Pattern;
+
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+
+/**
+ * The path filter provides hierarchical filtering.
+ *
+ */
+public class PathPredicate implements Predicate {
+
+ /**
+ * the internal regex pattern
+ */
+ protected final Pattern regex;
+
+ /**
+ * Creates a new default path filter
+ * <xmp>
+ * | Pattern | Matches
+ * | /foo | exactly "/foo"
+ * | /foo.* | all paths starting with "foo."
+ * | foo.* | all files starting with "foo."
+ * | /foo/* | all direct children of /foo
+ * | /foo/** | all children of /foo
+ * </xmp>
+ * @param pattern the pattern
+ */
+ public PathPredicate(String pattern) {
+ String suffix = "";
+ String prefix = "";
+ if (pattern.endsWith("/**")) {
+ suffix = "/.*";
+ pattern = pattern.substring(0, pattern.length() - 3);
+ } else if (pattern.endsWith("*")) {
+ suffix = "[^/]*$";
+ pattern = pattern.substring(0, pattern.length() - 1);
+ }
+ if (pattern.charAt(0) != '/') {
+ prefix = "^.*/";
+ }
+ pattern = prefix + pattern.replaceAll("\\.", "\\\\.") + suffix;
+ regex = Pattern.compile(pattern);
+ }
+
+ /**
+ * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
+ */
+ public boolean evaluate(Object item) {
+ if ( item instanceof Item ) {
+ try {
+ return regex.matcher(((Item)item).getPath()).matches();
+ } catch (RepositoryException re) {
+ return false;
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/PathPredicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java Tue Aug 31 11:06:52 2010
@@ -1,42 +1,42 @@
-/*
- * 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.commons.predicate;
-
-/**
- * Interface for object predicates, i.e. functions that evalute a given
- * object to a boolean value.
- */
-public interface Predicate {
-
- /**
- * Evaluates the predicate for the given object.
- *
- * @param object some object
- * @return predicate result
- */
- boolean evaluate(Object object);
-
- /**
- * Constant predicate that returns <code>true</code> for all objects.
- */
- static final Predicate TRUE = new Predicate() {
- public boolean evaluate(Object object) {
- return true;
- }
- };
-
-}
+/*
+ * 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.commons.predicate;
+
+/**
+ * Interface for object predicates, i.e. functions that evalute a given
+ * object to a boolean value.
+ */
+public interface Predicate {
+
+ /**
+ * Evaluates the predicate for the given object.
+ *
+ * @param object some object
+ * @return predicate result
+ */
+ boolean evaluate(Object object);
+
+ /**
+ * Constant predicate that returns <code>true</code> for all objects.
+ */
+ static final Predicate TRUE = new Predicate() {
+ public boolean evaluate(Object object) {
+ return true;
+ }
+ };
+
+}
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/Predicate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java?rev=991157&r1=991156&r2=991157&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java Tue Aug 31 11:06:52 2010
@@ -1,92 +1,92 @@
-/*
- * 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.commons.query.qom;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.qom.Join;
-import javax.jcr.query.qom.JoinCondition;
-import javax.jcr.query.qom.QueryObjectModelConstants;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Source;
-
-/**
- * Enumeration of the JCR 2.0 join types.
- *
- * @since Apache Jackrabbit 2.0
- */
-public enum JoinType {
-
- INNER(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER),
-
- LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER),
-
- RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
-
- /**
- * JCR name of this join type.
- */
- private final String name;
-
- private JoinType(String name) {
- this.name = name;
- }
-
- /**
- * Returns the join of the given sources.
- *
- * @param factory factory for creating the join
- * @param left left join source
- * @param right right join source
- * @param condition join condition
- * @return join
- * @throws RepositoryException if the join can not be created
- */
- public Join join(
- QueryObjectModelFactory factory,
- Source left, Source right, JoinCondition condition)
- throws RepositoryException {
- return factory.join(left, right, name, condition);
- }
-
- /**
- * Returns the JCR 2.0 name of this join type.
- *
- * @see QueryObjectModelConstants
- * @return JCR name of this join type
- */
- public String toString() {
- return name;
- }
-
- /**
- * Returns the join type with the given JCR name.
- *
- * @param name JCR name of a join type
- * @return join type with the given name
- * @throws RepositoryException if the given name is unknown
- */
- public static JoinType getJoinTypeByName(String name)
- throws RepositoryException {
- for (JoinType type : JoinType.values()) {
- if (type.name.equals(name)) {
- return type;
- }
- }
- throw new RepositoryException("Unknown join type name: " + name);
- }
-
-}
+/*
+ * 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.commons.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.query.qom.Join;
+import javax.jcr.query.qom.JoinCondition;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Source;
+
+/**
+ * Enumeration of the JCR 2.0 join types.
+ *
+ * @since Apache Jackrabbit 2.0
+ */
+public enum JoinType {
+
+ INNER(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER),
+
+ LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER),
+
+ RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
+
+ /**
+ * JCR name of this join type.
+ */
+ private final String name;
+
+ private JoinType(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the join of the given sources.
+ *
+ * @param factory factory for creating the join
+ * @param left left join source
+ * @param right right join source
+ * @param condition join condition
+ * @return join
+ * @throws RepositoryException if the join can not be created
+ */
+ public Join join(
+ QueryObjectModelFactory factory,
+ Source left, Source right, JoinCondition condition)
+ throws RepositoryException {
+ return factory.join(left, right, name, condition);
+ }
+
+ /**
+ * Returns the JCR 2.0 name of this join type.
+ *
+ * @see QueryObjectModelConstants
+ * @return JCR name of this join type
+ */
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Returns the join type with the given JCR name.
+ *
+ * @param name JCR name of a join type
+ * @return join type with the given name
+ * @throws RepositoryException if the given name is unknown
+ */
+ public static JoinType getJoinTypeByName(String name)
+ throws RepositoryException {
+ for (JoinType type : JoinType.values()) {
+ if (type.name.equals(name)) {
+ return type;
+ }
+ }
+ throw new RepositoryException("Unknown join type name: " + name);
+ }
+
+}
Propchange: jackrabbit/branches/2.1/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
------------------------------------------------------------------------------
svn:eol-style = native