jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792142 [32/35] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrab...
Date Wed, 08 Jul 2009 13:57:46 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/LocationStepQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/LocationStepQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/LocationStepQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/LocationStepQueryNode.java Wed Jul  8 13:57:13 2009
@@ -32,7 +32,7 @@
  * /     -> descendants = false, nameTest = ""
  * </code>
  */
-public class LocationStepQueryNode extends NAryQueryNode {
+public class LocationStepQueryNode extends NAryQueryNode<QueryNode> {
 
     /** Constant value for position index = last() */
     public static final int LAST = Integer.MIN_VALUE;
@@ -46,7 +46,7 @@
      * TODO: The root location step should be refactored somehow
      */
     public static final Name EMPTY_NAME = NameFactoryImpl.getInstance().create("", "");
-
+    
     /** Empty <code>QueryNode</code> array for us as return value */
     private static final QueryNode[] EMPTY = new QueryNode[0];
 
@@ -68,9 +68,11 @@
     private int index = NONE;
 
     /**
-     * Creates a new <code>LocationStepQueryNode</code> that matches only
-     * the empty name (the repository root). The created location step
-     * uses only the child axis.
+     * Creates a new <code>LocationStepQueryNode</code> that matches only the
+     * empty name (the repository root). The created location step uses only the
+     * child axis.
+     *
+     * @param parent the parent of this query node.
      */
     protected LocationStepQueryNode(QueryNode parent) {
         super(parent);
@@ -132,7 +134,7 @@
         if (operands == null) {
             return EMPTY;
         } else {
-            return (QueryNode[]) operands.toArray(new QueryNode[operands.size()]);
+            return operands.toArray(new QueryNode[operands.size()]);
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NAryQueryNode.java Wed Jul  8 13:57:13 2009
@@ -26,7 +26,7 @@
 /**
  * Defines an abstract query node for nodes that have child nodes.
  */
-public abstract class NAryQueryNode extends QueryNode {
+public abstract class NAryQueryNode<T extends QueryNode> extends QueryNode {
 
     /**
      * Empty result.
@@ -36,7 +36,7 @@
     /**
      * The list of operands / children
      */
-    protected List operands = null;
+    protected List<T> operands = null;
 
     /**
      * Creates a new <code>NAryQueryNode</code> with a reference to a parent
@@ -55,10 +55,10 @@
      * @param parent   the parent node.
      * @param operands child nodes of this <code>NAryQueryNode</code>.
      */
-    public NAryQueryNode(QueryNode parent, QueryNode[] operands) {
+    public NAryQueryNode(QueryNode parent, T[] operands) {
         super(parent);
         if (operands.length > 0) {
-            this.operands = new ArrayList();
+            this.operands = new ArrayList<T>();
             this.operands.addAll(Arrays.asList(operands));
         }
     }
@@ -68,9 +68,9 @@
      *
      * @param operand the child {@link QueryNode} to add.
      */
-    public void addOperand(QueryNode operand) {
+    public void addOperand(T operand) {
         if (operands == null) {
-            operands = new ArrayList();
+            operands = new ArrayList<T>();
         }
         operands.add(operand);
     }
@@ -83,7 +83,7 @@
      *  and has been removed; <code>false</code> if this node does not contain
      *  <code>operand</code> as a child node.
      */
-    public boolean removeOperand(QueryNode operand) {
+    public boolean removeOperand(T operand) {
         if (operands == null) {
             return false;
         }
@@ -108,7 +108,7 @@
         if (operands == null) {
             return new QueryNode[0];
         } else {
-            return (QueryNode[]) operands.toArray(new QueryNode[operands.size()]);
+            return operands.toArray(new QueryNode[operands.size()]);
         }
     }
 
@@ -131,16 +131,16 @@
      * @param visitor the visitor to call back.
      * @param data    arbitrary data for the visitor.
      * @return the return values of the <code>visitor.visit()</code> calls.
-     * @throws RepositoryException
+     * @throws RepositoryException if an error occurs.
      */
     public Object[] acceptOperands(QueryNodeVisitor visitor, Object data) throws RepositoryException {
         if (operands == null) {
             return EMPTY;
         }
 
-        List result = new ArrayList(operands.size());
-        for (int i = 0; i < operands.size(); i++) {
-            Object r = ((QueryNode) operands.get(i)).accept(visitor, data);
+        List<Object> result = new ArrayList<Object>(operands.size());
+        for (T operand : operands) {
+            Object r = operand.accept(visitor, data);
             if (r != null) {
                 result.add(r);
             }
@@ -166,9 +166,8 @@
         if (operands == null) {
             return false;
         }
-        for (Iterator iter = operands.iterator(); iter.hasNext();) {
-            QueryNode queryNode = (QueryNode) iter.next();
-            if (queryNode.needsSystemTree()) {
+        for (T operand : operands) {
+            if (operand.needsSystemTree()) {
                 return true;
             }
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NotQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NotQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NotQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/NotQueryNode.java Wed Jul  8 13:57:13 2009
@@ -21,7 +21,7 @@
 /**
  * Implements a query node that defines a not operation on the child query.
  */
-public class NotQueryNode extends NAryQueryNode {
+public class NotQueryNode extends NAryQueryNode<QueryNode> {
 
     /**
      * Creates a new <code>NotQueryNode</code> instance.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/OrQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/OrQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/OrQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/OrQueryNode.java Wed Jul  8 13:57:13 2009
@@ -22,7 +22,7 @@
  * Implements a query node that defines an OR operation between arbitrary
  * other {@link QueryNode}s.
  */
-public class OrQueryNode extends NAryQueryNode {
+public class OrQueryNode extends NAryQueryNode<QueryNode> {
 
     /**
      * Creates a new <code>OrQueryNode</code> with a <code>parent</code>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PathQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PathQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PathQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/PathQueryNode.java Wed Jul  8 13:57:13 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.spi.commons.query;
 
-import java.util.List;
+import java.util.Collection;
 
 import javax.jcr.RepositoryException;
 
@@ -26,7 +26,7 @@
 /**
  * Implements a query node that defines a path restriction.
  */
-public class PathQueryNode extends NAryQueryNode {
+public class PathQueryNode extends NAryQueryNode<LocationStepQueryNode> {
 
     /**
      * Flag indicating whether this path is absolute.
@@ -34,9 +34,10 @@
     private boolean absolute = false;
 
     /**
-     * List of valid node type names under /jcr:system
+     * Valid node type names under /jcr:system. Used to determine if a
+     * query needs to be executed also against the /jcr:system tree.
      */
-    private final List validJcrSystemNodeTypeNames;
+    private final Collection<Name> validJcrSystemNodeTypeNames;
 
     /**
      * Empty step node array.
@@ -45,21 +46,23 @@
 
     /**
      * Creates a relative <code>PathQueryNode</code> with no location steps and
-     * the list of node types under /jcr:system.
+     * the collection of node types under /jcr:system.
      *
      * @param parent the parent query node.
+     * @param validJcrSystemNodeTypeNames valid node types under /jcr:system
      */
-    protected PathQueryNode(QueryNode parent, List validJcrSystemNodeTypeNames) {
+    protected PathQueryNode(
+            QueryNode parent, Collection<Name> validJcrSystemNodeTypeNames) {
         super(parent);
         this.validJcrSystemNodeTypeNames = validJcrSystemNodeTypeNames;
     }
 
     /**
-     * Returns a list of valid node types under /jcr:system. List&lt;Name>.
+     * Returns the collection of valid node types under /jcr:system.
      *
-     * @return a list of valid node types under /jcr:system.
+     * @return valid node types under /jcr:system.
      */
-    public List getValidJcrSystemNodeTypeNames() {
+    public Collection<Name> getValidJcrSystemNodeTypeNames() {
         return validJcrSystemNodeTypeNames;
     }
 
@@ -98,7 +101,7 @@
         if (operands == null) {
             return EMPTY;
         } else {
-            return (LocationStepQueryNode[]) operands.toArray(new LocationStepQueryNode[operands.size()]);
+            return operands.toArray(new LocationStepQueryNode[operands.size()]);
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeDump.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeDump.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeDump.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryTreeDump.java Wed Jul  8 13:57:13 2009
@@ -205,14 +205,14 @@
         buffer.append(PADDING, 0, indent);
         buffer.append("+ RelationQueryNode: Op: ");
         buffer.append(QueryConstants.OPERATION_NAMES.getName(node.getOperation()));
-        buffer.append(" Prop=");
-        Path relPath = node.getRelativePath();
+        buffer.append(" Prop=[");
+        PathQueryNode relPath = node.getRelativePath();
         if (relPath == null) {
             buffer.append(relPath);
         } else {
-            appendPath(relPath, buffer);
+            visit(relPath, buffer);
         }
-        buffer.append(" Type=").append(QueryConstants.TYPE_NAMES.getName(node.getValueType()));
+        buffer.append("] Type=").append(QueryConstants.TYPE_NAMES.getName(node.getValueType()));
         if (node.getValueType() == QueryConstants.TYPE_DATE) {
             buffer.append(" Value=").append(node.getDateValue());
         } else if (node.getValueType() == QueryConstants.TYPE_DOUBLE) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java Wed Jul  8 13:57:13 2009
@@ -22,14 +22,12 @@
 
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.Path.Element;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
-import org.apache.jackrabbit.spi.commons.name.PathBuilder;
-
 /**
  * Implements a query node that defines property value relation.
  */
-public class RelationQueryNode extends NAryQueryNode implements QueryConstants {
+public class RelationQueryNode extends NAryQueryNode<QueryNode> implements QueryConstants {
 
     /**
      * Acts as an syntetic placeholder for a location step that matches any
@@ -41,7 +39,7 @@
     /**
      * The relative path to the property.
      */
-    private Path relPath;
+    private PathQueryNode relPath;
 
     /**
      * If <code>true</code> this relation query node contains a value preceded
@@ -90,15 +88,23 @@
      */
     private int type;
 
+    private final QueryNodeFactory factory;
+
     /**
      * Creates a new <code>RelationQueryNode</code> without a type nor value
      * assigned.
      *
-     * @param parent the parent node for this query node.
-     */
-    protected RelationQueryNode(QueryNode parent, int operation) {
+     * @param parent    the parent node for this query node.
+     * @param operation the operation.
+     * @param factory   the query node factory.
+     */
+    protected RelationQueryNode(QueryNode parent,
+                                int operation,
+                                QueryNodeFactory factory) {
         super(parent);
         this.operation = operation;
+        this.factory = factory;
+        this.relPath = factory.createPathQueryNode(this);
     }
 
     /**
@@ -138,38 +144,9 @@
     }
 
     /**
-     * Returns the name of the property in this relation query node. Please
-     * note that this method does not return the full relative path that
-     * reference the property to match, but only the name of the final name
-     * element of the path returned by {@link #getRelativePath()}.
-     *
-     * @return the name of the property in this relation query node.
-     * @deprecated Use {@link #getRelativePath()} instead.
-     */
-    public Name getProperty() {
-        return relPath == null ? null : relPath.getNameElement().getName();
-    }
-
-    /**
-     * Sets a new property name for this relation query node.
-     *
-     * @param name the new property name.
-     * @deprecated Use {@link #setRelativePath(Path)} instead.
-     */
-    public void setProperty(Name name) {
-        PathBuilder builder = new PathBuilder();
-        builder.addLast(name);
-        try {
-            this.relPath = builder.getPath();
-        } catch (MalformedPathException e) {
-            // path is always valid
-        }
-    }
-
-    /**
      * @return the relative path that references the property in this relation.
      */
-    public Path getRelativePath() {
+    public PathQueryNode getRelativePath() {
         return relPath;
     }
 
@@ -180,10 +157,14 @@
      * @throws IllegalArgumentException if <code>relPath</code> is absolute.
      */
     public void setRelativePath(Path relPath) {
-        if (relPath != null && relPath.isAbsolute()) {
+        if (relPath.isAbsolute()) {
             throw new IllegalArgumentException("relPath must be relative");
         }
-        this.relPath = relPath;
+        
+        Element[] elements = relPath.getElements();
+        for (Element element : elements) {
+            addPathElement(element);
+        }
     }
 
     /**
@@ -193,23 +174,9 @@
      * @param element the path element to append.
      */
     public void addPathElement(Path.Element element) {
-        PathBuilder builder = new PathBuilder();
-        if (relPath != null) {
-            builder.addAll(relPath.getElements());
-        }
-        builder.addLast(element);
-        try {
-            relPath = builder.getPath();
-        }
-        catch (MalformedPathException e) {
-            // path is always valid
-        }
-        // try to normalize the path
-        try {
-          relPath = relPath.getNormalizedPath();
-        } catch (RepositoryException e) {
-            // just keep the original in that case
-        }
+        LocationStepQueryNode step = factory.createLocationStepQueryNode(relPath);
+        step.setNameTest(element.getName());
+        relPath.addPathStep(step);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/AbstractQOMNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/AbstractQOMNode.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/AbstractQOMNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/AbstractQOMNode.java Wed Jul  8 13:57:13 2009
@@ -45,10 +45,10 @@
     //---------------------------< internal >-----------------------------------
 
     /**
-     * Returns the prefixed JCR name for the given qualified name or
+     * Returns the JCR name string for the given <code>Name</code> or
      * <code>null</code> if <code>name</code> is <code>null</code>.
      *
-     * @param name the qualified name.
+     * @param name the <code>Name</code>.
      * @return the prefixed JCR name or <code>name.toString()</code> if an
      *         unknown namespace URI is encountered.
      */
@@ -64,12 +64,12 @@
     }
 
     /**
-     * Returns the prefixed JCR path for the given qualified path or
+     * Returns the JCR path String for the given <code>Path</code> object or
      * <code>null</code> if <code>path</code> is <code>null</code>.
      *
-     * @param path qualified path
-     * @return prefixed JCR path or <code>path.toString()</code> if an unknown
-     *         namespace URI is encountered.
+     * @param path A <code>Path</code> object.
+     * @return JCR path in the standard form or <code>path.toString()</code>
+     * if an unknown namespace URI is encountered.
      */
     protected String getJCRPath(Path path) {
         if (path == null) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/ColumnImpl.java Wed Jul  8 13:57:13 2009
@@ -44,12 +44,12 @@
     /**
      * The name of the column.
      */
-    private final Name columnName;
+    private final String columnName;
 
     ColumnImpl(NamePathResolver resolver,
                Name selectorName,
                Name propertyName,
-               Name columnName) {
+               String columnName) {
         super(resolver);
         this.selectorName = selectorName;
         this.propertyName = propertyName;
@@ -75,18 +75,6 @@
         return propertyName;
     }
 
-    /**
-     * Gets the column name.
-     * <p/>
-     *
-     * @return the column name; must be null if <code>getPropertyName</code> is
-     *         null and non-null otherwise
-     */
-    public Name getColumnQName() {
-        return columnName;
-    }
-
-
     //---------------------------< Column >-------------------------------------
 
     /**
@@ -116,7 +104,7 @@
      *         null and non-null otherwise
      */
     public String getColumnName() {
-        return getJCRName(columnName);
+        return columnName;
     }
 
     //------------------------< AbstractQOMNode >-------------------------------

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinType.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinType.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/JoinType.java Wed Jul  8 13:57:13 2009
@@ -32,11 +32,9 @@
 
     INNER(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER),
 
-    LEFT("{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter"),
-    // LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER),
+    LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER),
 
-    RIGHT("{http://www.jcp.org/jcr/1.0}joinTypeRightOuter");
-    // RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
+    RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
 
     /**
      * JCR name of this join type.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/Operator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/Operator.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/Operator.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/Operator.java Wed Jul  8 13:57:13 2009
@@ -30,11 +30,9 @@
  */
 public enum Operator {
 
-    EQ("{http://www.jcp.org/jcr/1.0}operatorEqualTo", "="),
-    // EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
+    EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
 
-    NE("{http://www.jcp.org/jcr/1.0}operatorNotEqualTo", "!=", "<>"),
-    // NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
+    NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
 
     GT(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, ">"),
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/OrderingImpl.java Wed Jul  8 13:57:13 2009
@@ -40,14 +40,14 @@
     /**
      * The order.
      */
-    private final String order;
+    private final Order order;
 
     OrderingImpl(NamePathResolver resolver,
                  DynamicOperandImpl operand,
                  String order) {
         super(resolver);
         this.operand = operand;
-        this.order = order;
+        this.order = Order.getOrderByName(order);
     }
 
     /**
@@ -67,9 +67,16 @@
      *         </ul>
      */
     public String getOrder() {
-        return order;
+        return order.getName();
     }
 
+    /**
+     * @return <code>true</code> if this ordering is ascending. Returns
+     *         <code>false</code> if ordering is descending.
+     */
+    public boolean isAscending() {
+        return order == Order.ASCENDING;
+    }
 
     //------------------------< AbstractQOMNode >-------------------------------
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java Wed Jul  8 13:57:13 2009
@@ -60,22 +60,12 @@
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * <code>QueryObjectModelFactoryImpl</code> implements the query object model
  * factory from JSR 283.
  */
 public abstract class QueryObjectModelFactoryImpl implements QueryObjectModelFactory {
 
-    private static final Set<String> VALID_ORDERS = new HashSet<String>();
-
-    static {
-        VALID_ORDERS.add(QueryObjectModelConstants.JCR_ORDER_ASCENDING);
-        VALID_ORDERS.add(QueryObjectModelConstants.JCR_ORDER_DESCENDING);
-    }
-
     /**
      * The name and path resolver for this QOM factory.
      */
@@ -151,8 +141,7 @@
                                         Column[] columns)
             throws InvalidQueryException, RepositoryException {
         if (source == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("source must not be null");
+            throw new InvalidQueryException("source must not be null");
         }
         if (!(source instanceof SourceImpl)) {
             throw new RepositoryException("Unknown Source implementation");
@@ -378,8 +367,7 @@
     public And and(Constraint constraint1, Constraint constraint2)
             throws InvalidQueryException, RepositoryException {
         if (constraint1 == null || constraint2 == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("Constraints must not be null");
+            throw new InvalidQueryException("Constraints must not be null");
         }
         if (constraint1 instanceof ConstraintImpl
                 && constraint2 instanceof ConstraintImpl) {
@@ -404,8 +392,7 @@
     public Or or(Constraint constraint1, Constraint constraint2)
             throws InvalidQueryException, RepositoryException {
         if (constraint1 == null || constraint2 == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("Constraints must not be null");
+            throw new InvalidQueryException("Constraints must not be null");
         }
         if (constraint1 instanceof ConstraintImpl
                 && constraint2 instanceof ConstraintImpl) {
@@ -851,8 +838,7 @@
     public BindVariableValue bindVariable(String bindVariableName)
             throws InvalidQueryException, RepositoryException {
         if (bindVariableName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("bindVariableName must not be null");
+            throw new InvalidQueryException("bindVariableName must not be null");
         }
         try {
             return new BindVariableValueImpl(
@@ -873,8 +859,7 @@
     public Literal literal(Value value)
             throws InvalidQueryException, RepositoryException {
         if (value == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("value must not be null");
+            throw new InvalidQueryException("value must not be null");
         }
         return new LiteralImpl(resolver, value);
     }
@@ -940,7 +925,7 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        return new ColumnImpl(resolver, null, propName, propName);
+        return new ColumnImpl(resolver, null, propName, propertyName);
     }
 
     /**
@@ -961,8 +946,7 @@
     public Column column(String propertyName, String columnName)                  // CM
             throws InvalidQueryException, RepositoryException {
         if (propertyName == null && columnName != null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "columnName must be null if propertyName is null");
         }
         Name propName = null;
@@ -973,15 +957,7 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        Name colName = null;
-        if (columnName != null) {
-            try {
-                colName = resolver.getQName(columnName);
-            } catch (NameException e) {
-                throw new InvalidQueryException(e.getMessage());
-            }
-        }
-        return new ColumnImpl(resolver, null, propName, colName);
+        return new ColumnImpl(resolver, null, propName, columnName);
     }
 
     /**
@@ -1003,8 +979,7 @@
                          String propertyName,
                          String columnName) throws InvalidQueryException, RepositoryException {
         if (propertyName == null && columnName != null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "columnName must be null if propertyName is null");
         }
         Name propName = null;
@@ -1015,16 +990,8 @@
                 throw new InvalidQueryException(e.getMessage());
             }
         }
-        Name colName = null;
-        if (columnName != null) {
-            try {
-                colName = resolver.getQName(columnName);
-            } catch (NameException e) {
-                throw new InvalidQueryException(e.getMessage());
-            }
-        }
         return new ColumnImpl(resolver, checkSelectorName(selectorName),
-                propName, colName);
+                propName, columnName);
     }
 
     //------------------------------< internal >--------------------------------
@@ -1032,8 +999,7 @@
     private Name checkSelectorName(String selectorName)
             throws RepositoryException {
         if (selectorName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("selectorName must not be null");
+            throw new InvalidQueryException("selectorName must not be null");
         }
         try {
             return resolver.getQName(selectorName);
@@ -1045,8 +1011,7 @@
     private Name checkNodeTypeName(String nodeTypeName)
             throws RepositoryException {
         if (nodeTypeName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("nodeTypeName must not be null");
+            throw new InvalidQueryException("nodeTypeName must not be null");
         }
         try {
             return resolver.getQName(nodeTypeName);
@@ -1057,8 +1022,7 @@
 
     private Path checkPath(String path) throws RepositoryException {
         if (path == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("path must not be null");
+            throw new InvalidQueryException("path must not be null");
         }
         try {
             return resolver.getQPath(path);
@@ -1070,8 +1034,7 @@
     private Name checkPropertyName(String propertyName)
             throws RepositoryException {
         if (propertyName == null) {
-            // TODO: correct exception?
-            throw new RepositoryException("propertyName must not be null");
+            throw new InvalidQueryException("propertyName must not be null");
         }
         try {
             return resolver.getQName(propertyName);
@@ -1083,8 +1046,7 @@
     private StaticOperand checkFullTextSearchExpression(StaticOperand fullTextSearchExpression)
             throws RepositoryException {
         if (fullTextSearchExpression == null) {
-            // TODO: correct exception?
-            throw new RepositoryException(
+            throw new InvalidQueryException(
                     "fullTextSearchExpression must not be null");
         }
         return fullTextSearchExpression;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java Wed Jul  8 13:57:13 2009
@@ -50,6 +50,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -838,7 +839,8 @@
          * @param validJcrSystemNodeTypeNames names of valid node types under
          *        /jcr:system.
          */
-        MergingPathQueryNode(int operation, List validJcrSystemNodeTypeNames) {
+        MergingPathQueryNode(
+                int operation, Collection<Name> validJcrSystemNodeTypeNames) {
             super(null, validJcrSystemNodeTypeNames);
             if (operation != QueryNode.TYPE_OR && operation != QueryNode.TYPE_AND && operation != QueryNode.TYPE_NOT) {
                 throw new IllegalArgumentException("operation");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/QueryFormat.java Wed Jul  8 13:57:13 2009
@@ -406,14 +406,14 @@
         StringBuffer sb = (StringBuffer) data;
         try {
             StringBuffer propName = new StringBuffer();
-            Path relPath = node.getRelativePath();
+            PathQueryNode relPath = node.getRelativePath();
             if (relPath == null) {
                 propName.append(".");
-            } else if (relPath.getLength() > 1) {
+            } else if (relPath.getPathSteps().length > 1) {
                 exceptions.add(new InvalidQueryException("Child axis not supported in SQL"));
                 return data;
             } else {
-                appendName(relPath.getNameElement().getName(), resolver, propName);
+                visit(relPath, data);
             }
             // surround name with property function
             node.acceptOperands(this, propName);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java Wed Jul  8 13:57:13 2009
@@ -120,6 +120,9 @@
             read("BY");
             orderings = parseOrder();
         }
+        if (currentToken.length() > 0) {
+            throw getSyntaxError("<end>");
+        }
         return factory.createQuery(source, constraint, orderings, columnArray);
     }
 
@@ -192,7 +195,7 @@
         String name = readName();
         JoinCondition c;
         if (identifier && readIf("(")) {
-            if ("ISSAMENODE".equals(name)) {
+            if ("ISSAMENODE".equalsIgnoreCase(name)) {
                 String selector1 = readName();
                 read(",");
                 String selector2 = readName();
@@ -202,11 +205,11 @@
                     // TODO verify "." is correct
                     c = factory.sameNodeJoinCondition(selector1, selector2, ".");
                 }
-            } else if ("ISCHILDNODE".equals(name)) {
+            } else if ("ISCHILDNODE".equalsIgnoreCase(name)) {
                 String childSelector = readName();
                 read(",");
                 c = factory.childNodeJoinCondition(childSelector, readName());
-            } else if ("ISDESCENDANTNODE".equals(name)) {
+            } else if ("ISDESCENDANTNODE".equalsIgnoreCase(name)) {
                 String descendantSelector = readName();
                 read(",");
                 c = factory.descendantNodeJoinCondition(descendantSelector, readName());
@@ -245,7 +248,7 @@
     private Constraint parseCondition() throws RepositoryException {
         Constraint a;
         if (readIf("NOT")) {
-            a = parseConstraint();
+            a = factory.not(parseConstraint());
         } else if (readIf("(")) {
             a = parseConstraint();
             read(")");
@@ -322,7 +325,7 @@
 
     private Constraint parseConditionFuntionIf(String functionName) throws RepositoryException {
         Constraint c;
-        if ("CONTAINS".equals(functionName)) {
+        if ("CONTAINS".equalsIgnoreCase(functionName)) {
             String name = readName();
             if (readIf(".")) {
                 if (readIf("*")) {
@@ -338,21 +341,21 @@
                 read(",");
                 c = factory.fullTextSearch(getOnlySelectorName(), name, readString());
             }
-        } else if ("ISSAMENODE".equals(functionName)) {
+        } else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
             String name = readName();
             if (readIf(",")) {
                 c = factory.sameNode(name, readPath());
             } else {
                 c = factory.sameNode(getOnlySelectorName(), name);
             }
-        } else if ("ISCHILDNODE".equals(functionName)) {
+        } else if ("ISCHILDNODE".equalsIgnoreCase(functionName)) {
             String name = readName();
             if (readIf(",")) {
                 c = factory.childNode(name, readPath());
             } else {
                 c = factory.childNode(getOnlySelectorName(), name);
             }
-        } else if ("ISDESCENDANTNODE".equals(functionName)) {
+        } else if ("ISDESCENDANTNODE".equalsIgnoreCase(functionName)) {
             String name = readName();
             if (readIf(",")) {
                 c = factory.descendantNode(name, readPath());
@@ -382,29 +385,29 @@
 
     private DynamicOperand parseExpressionFunction(String functionName) throws RepositoryException {
         DynamicOperand op;
-        if ("LENGTH".equals(functionName)) {
+        if ("LENGTH".equalsIgnoreCase(functionName)) {
             op = factory.length(parsePropertyValue(readName()));
-        } else if ("NAME".equals(functionName)) {
+        } else if ("NAME".equalsIgnoreCase(functionName)) {
             if (isToken(")")) {
                 op = factory.nodeName(getOnlySelectorName());
             } else {
                 op = factory.nodeName(readName());
             }
-        } else if ("LOCALNAME".equals(functionName)) {
+        } else if ("LOCALNAME".equalsIgnoreCase(functionName)) {
             if (isToken(")")) {
                 op = factory.nodeLocalName(getOnlySelectorName());
             } else {
                 op = factory.nodeLocalName(readName());
             }
-        } else if ("SCORE".equals(functionName)) {
+        } else if ("SCORE".equalsIgnoreCase(functionName)) {
             if (isToken(")")) {
                 op = factory.fullTextSearchScore(getOnlySelectorName());
             } else {
                 op = factory.fullTextSearchScore(readName());
             }
-        } else if ("LOWER".equals(functionName)) {
+        } else if ("LOWER".equalsIgnoreCase(functionName)) {
             op = factory.lowerCase(parseDynamicOperand());
-        } else if ("UPPER".equals(functionName)) {
+        } else if ("UPPER".equalsIgnoreCase(functionName)) {
             op = factory.upperCase(parseDynamicOperand());
         } else {
             throw getSyntaxError("LENGTH, NAME, LOCALNAME, SCORE, LOWER, UPPER, or CAST");
@@ -454,6 +457,9 @@
         } else if (currentTokenType == PARAMETER) {
             read();
             String name = readName();
+            if (readIf(":")) {
+                name = name + ":" + readName();
+            }
             BindVariableValue var = bindVariables.get(name);
             if (var == null) {
                 var = factory.bindVariable(name);
@@ -483,42 +489,32 @@
             throw getSyntaxError("static operand");
         }
     }
-    
+
     private Value parseCastAs(Value value) throws RepositoryException {
         if (readIf("STRING")) {
             return valueFactory.createValue(value.getString());
         } else if(readIf("BINARY")) {
-            // TODO getBinary
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getBinary());
         } else if(readIf("DATE")) {
-            // TODO getDate
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDate());
         } else if(readIf("LONG")) {
-            // TODO getLong
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getLong());
         } else if(readIf("DOUBLE")) {
-            // TODO getDouble
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDouble());
         } else if(readIf("DECIMAL")) {
-            // TODO getDecimal
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDecimal());
         } else if(readIf("BOOLEAN")) {
             return valueFactory.createValue(value.getBoolean());
         } else if(readIf("NAME")) {
-            // TODO getName
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getString(), PropertyType.NAME);
         } else if(readIf("PATH")) {
-            // TODO getPath
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getString(), PropertyType.PATH);
         } else if(readIf("REFERENCE")) {
-            // TODO getReference
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getString(), PropertyType.REFERENCE);
         } else if(readIf("WEAKREFERENCE")) {
-            // TODO getWeakReference
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getString(), PropertyType.WEAKREFERENCE);
         } else if(readIf("URI")) {
-            // TODO getURI
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getString(), PropertyType.URI);
         } else {
             throw getSyntaxError("data type (STRING|BINARY|...)");
         }
@@ -610,7 +606,7 @@
     }
 
     private boolean isToken(String token) {
-        boolean result = token.equals(currentToken) && !currentTokenQuoted;
+        boolean result = token.equalsIgnoreCase(currentToken) && !currentTokenQuoted;
         if (result) {
             return true;
         }
@@ -619,7 +615,7 @@
     }
 
     private void read(String expected) throws RepositoryException {
-        if (!expected.equals(currentToken) || currentTokenQuoted) {
+        if (!expected.equalsIgnoreCase(currentToken) || currentTokenQuoted) {
             throw getSyntaxError(expected);
         }
         read();
@@ -664,7 +660,6 @@
         int[] types = new int[len];
         len--;
         query.getChars(0, len, command, 0);
-        boolean changed = false;
         command[len] = ' ';
         int startLoop = 0;
         for (int i = 0; i < len; i++) {
@@ -720,8 +715,6 @@
                 break;
             default:
                 if (c >= 'a' && c <= 'z') {
-                    command[i] = (char) (c - ('a' - 'A'));
-                    changed = true;
                     type = CHAR_NAME;
                 } else if (c >= 'A' && c <= 'Z') {
                     type = CHAR_NAME;
@@ -730,11 +723,6 @@
                 } else {
                     if (Character.isJavaIdentifierPart(c)) {
                         type = CHAR_NAME;
-                        char u = Character.toUpperCase(c);
-                        if (u != c) {
-                            command[i] = u;
-                            changed = true;
-                        }
                     }
                 }
             }
@@ -743,9 +731,6 @@
         statementChars = command;
         types[len] = CHAR_END;
         characterTypes = types;
-        if (changed) {
-            statement = new String(command);
-        }
         parseIndex = 0;
     }
 
@@ -825,12 +810,12 @@
                         readDecimal(start, i);
                         break;
                     }
-                    if (c == 'E') {
+                    if (c == 'E' || c == 'e') {
                         readDecimal(start, i);
                         break;
                     }
                     checkLiterals(false);
-                    currentValue = valueFactory.createValue((long) number);
+                    currentValue = valueFactory.createValue(number);
                     currentTokenType = VALUE;
                     currentToken = "0";
                     parseIndex = i;
@@ -868,7 +853,7 @@
             throw getSyntaxError();
         }
     }
-    
+
     private void readString(int i, char end) throws RepositoryException {
         char[] chars = statementChars;
         String result = null;
@@ -911,7 +896,7 @@
             }
             i++;
         }
-        if (chars[i] == 'E') {
+        if (chars[i] == 'E' || chars[i] == 'e') {
             i++;
             if (chars[i] == '+' || chars[i] == '-') {
                 i++;
@@ -932,11 +917,8 @@
             throw new InvalidQueryException("Data conversion error converting " + sub + " to BigDecimal: " + e);
         }
         checkLiterals(false);
-        
-        // TODO createValue(BigDecimal) is not yet implemented
-        // currentValue = valueFactory.createValue(bd);
-        currentValue = valueFactory.createValue(bd.doubleValue());
-        
+
+        currentValue = valueFactory.createValue(bd);
         currentTokenType = VALUE;
     }
 
@@ -957,7 +939,7 @@
 
     private InvalidQueryException getSyntaxError(String expected) {
         int index = Math.min(parseIndex, statement.length() - 1);
-        String query = statement.substring(0, index) + ">*<" + statement.substring(index).trim();
+        String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim();
         if (expected != null) {
             query += "; expected: " + expected;
         }
@@ -973,11 +955,11 @@
         private String propertyName;
         private String columnName;
     }
-    
+
     /**
      * Get the selector name if only one selector exists in the query.
      * If more than one selector exists, an exception is thrown.
-     * 
+     *
      * @return the selector name
      */
     private String getOnlySelectorName() throws RepositoryException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java Wed Jul  8 13:57:13 2009
@@ -345,29 +345,13 @@
 
             StringBuffer propPath = new StringBuffer();
             // only encode if not position function
-            Path relPath = node.getRelativePath();
+            PathQueryNode relPath = node.getRelativePath();
             if (relPath == null) {
                 propPath.append(".");
-            } else if (relPath.getNameElement().getName().equals(XPathQueryBuilder.FN_POSITION_FULL)) {
+            } else if (relPath.getNumOperands() > 0 && relPath.getPathSteps()[0].getNameTest().equals(XPathQueryBuilder.FN_POSITION_FULL)) {
                 propPath.append(resolver.getJCRName(XPathQueryBuilder.FN_POSITION_FULL));
             } else {
-                Path.Element[] elements = relPath.getElements();
-                String slash = "";
-                for (int i = 0; i < elements.length; i++) {
-                    propPath.append(slash);
-                    slash = "/";
-                    if (i == elements.length - 1 && node.getOperation() != OPERATION_SIMILAR) {
-                        propPath.append("@");
-                    }
-                    if (elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
-                        propPath.append("*");
-                    } else {
-                        propPath.append(resolver.getJCRName(encode(elements[i].getName())));
-                    }
-                    if (elements[i].getIndex() != 0) {
-                        propPath.append("[").append(elements[i].getIndex()).append("]");
-                    }
-                }
+                visit(relPath, data);
             }
 
             // surround name with property function

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java Wed Jul  8 13:57:13 2009
@@ -424,7 +424,10 @@
                         if (tmpRelPath == null) {
                             tmpRelPath = new PathBuilder();
                         }
-                        tmpRelPath.addLast(tmp.getRelativePath().getNameElement());
+                        PathQueryNode relPath = tmp.getRelativePath();
+                        LocationStepQueryNode[] steps = relPath.getPathSteps();
+                        
+                        tmpRelPath.addLast(steps[steps.length-1].getNameTest());
                     }
                 }
                 break;
@@ -545,7 +548,11 @@
                 }
                 break;
             case JJTDOTDOT:
-                exceptions.add(new InvalidQueryException("Parent axis is not supported"));
+                if (queryNode instanceof LocationStepQueryNode) {
+                    ((LocationStepQueryNode) queryNode).setNameTest(PATH_FACTORY.getParentElement().getName());
+                } else {
+                    ((RelationQueryNode) queryNode).addPathElement(PATH_FACTORY.getParentElement());
+                }
                 break;
             default:
                 // per default traverse
@@ -943,47 +950,12 @@
                     }
                     if (queryNode.getType() == QueryNode.TYPE_PATH) {
                         PathQueryNode pathNode = (PathQueryNode) queryNode;
-                        DerefQueryNode derefNode = factory.createDerefQueryNode(pathNode, null, false);
-
-                        // assign property name
-                        node.jjtGetChild(1).jjtAccept(this, derefNode);
-                        // check property name
-                        if (derefNode.getRefProperty() == null) {
-                            exceptions.add(new InvalidQueryException("Wrong first argument type for jcr:deref"));
-                        }
-
-                        SimpleNode literal = (SimpleNode) node.jjtGetChild(2).jjtGetChild(0);
-                        if (literal.getId() == JJTSTRINGLITERAL) {
-                            String value = literal.getValue();
-                            // strip quotes
-                            value = value.substring(1, value.length() - 1);
-                            if (!value.equals("*")) {
-                                Name name = null;
-                                try {
-                                    name = decode(resolver.getQName(value));
-                                } catch (NameException e) {
-                                    exceptions.add(new InvalidQueryException("Illegal name: " + value));
-                                }
-                                derefNode.setNameTest(name);
-                            }
-                        } else {
-                            exceptions.add(new InvalidQueryException("Second argument for jcr:deref must be a String"));
-                        }
-
-                        // check if descendant
-                        if (!descendant) {
-                            Node p = node.jjtGetParent();
-                            for (int i = 0; i < p.jjtGetNumChildren(); i++) {
-                                SimpleNode c = (SimpleNode) p.jjtGetChild(i);
-                                if (c == node) {
-                                    break;
-                                }
-                                descendant = (c.getId() == JJTSLASHSLASH
-                                        || c.getId() == JJTROOTDESCENDANTS);
-                            }
-                        }
-                        derefNode.setIncludeDescendants(descendant);
-                        pathNode.addPathStep(derefNode);
+                        
+                        pathNode.addPathStep(createDerefQueryNode(node, descendant, pathNode));
+                    } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
+                        RelationQueryNode relNode = (RelationQueryNode) queryNode;
+                        DerefQueryNode deref = createDerefQueryNode(node, descendant, relNode.getRelativePath());
+                        relNode.getRelativePath().addPathStep(deref);
                     } else {
                         exceptions.add(new InvalidQueryException("Unsupported location for jcr:deref()"));
                     }
@@ -1103,6 +1075,51 @@
         return queryNode;
     }
 
+    private DerefQueryNode createDerefQueryNode(SimpleNode node, boolean descendant, QueryNode pathNode)
+        throws NamespaceException {
+        DerefQueryNode derefNode = factory.createDerefQueryNode(pathNode, null, false);
+
+        // assign property name
+        node.jjtGetChild(1).jjtAccept(this, derefNode);
+        // check property name
+        if (derefNode.getRefProperty() == null) {
+            exceptions.add(new InvalidQueryException("Wrong first argument type for jcr:deref"));
+        }
+
+        SimpleNode literal = (SimpleNode) node.jjtGetChild(2).jjtGetChild(0);
+        if (literal.getId() == JJTSTRINGLITERAL) {
+            String value = literal.getValue();
+            // strip quotes
+            value = value.substring(1, value.length() - 1);
+            if (!value.equals("*")) {
+                Name name = null;
+                try {
+                    name = decode(resolver.getQName(value));
+                } catch (NameException e) {
+                    exceptions.add(new InvalidQueryException("Illegal name: " + value));
+                }
+                derefNode.setNameTest(name);
+            }
+        } else {
+            exceptions.add(new InvalidQueryException("Second argument for jcr:deref must be a String"));
+        }
+
+        // check if descendant
+        if (!descendant) {
+            Node p = node.jjtGetParent();
+            for (int i = 0; i < p.jjtGetNumChildren(); i++) {
+                SimpleNode c = (SimpleNode) p.jjtGetChild(i);
+                if (c == node) {
+                    break;
+                }
+                descendant = (c.getId() == JJTSLASHSLASH
+                        || c.getId() == JJTROOTDESCENDANTS);
+            }
+        }
+        derefNode.setIncludeDescendants(descendant);
+        return derefNode;
+    }
+
     private OrderQueryNode.OrderSpec createOrderSpec(SimpleNode node,
                                                      OrderQueryNode queryNode) {
         SimpleNode child = (SimpleNode) node.jjtGetChild(0);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java Wed Jul  8 13:57:13 2009
@@ -66,13 +66,14 @@
      * @param value
      * @param type
      * @throws IllegalArgumentException if the passed <code>value</code>
-     * is <code>null</code> or if the <code>type</code> is neither STRING nor REFERENCE.
+     * is <code>null</code> or if the <code>type</code> is neither STRING nor
+     * REFERENCE/WEAKREFERENCE.
      */
     protected AbstractQValue(String value, int type) {
         if (value == null) {
             throw new IllegalArgumentException("null value");
         }
-        if (!(type == PropertyType.STRING || type == PropertyType.REFERENCE)) {
+        if (!(type == PropertyType.STRING || type == PropertyType.REFERENCE || type == PropertyType.WEAKREFERENCE)) {
             throw new IllegalArgumentException();
         }
         val = value;
@@ -209,7 +210,7 @@
             return cal;
         } else if (type == PropertyType.LONG) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
-            cal.setTimeInMillis(((Long) val).longValue());
+            cal.setTimeInMillis((Long) val);
             return cal;
         } else if (type == PropertyType.DECIMAL) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
@@ -231,6 +232,12 @@
     public BigDecimal getDecimal() throws RepositoryException {
         if (type == PropertyType.DECIMAL) {
             return (BigDecimal) val;
+        } else if (type == PropertyType.DOUBLE) {
+            return new BigDecimal((Double) val);
+        } else if (type == PropertyType.LONG) {
+            return new BigDecimal((Long) val);
+        } else if (type == PropertyType.DATE) {
+            return new BigDecimal(((Calendar) val).getTimeInMillis());
         } else {
             try {
                 return new BigDecimal(getString());
@@ -260,7 +267,9 @@
      */
     public double getDouble() throws RepositoryException {
         if (type == PropertyType.DOUBLE) {
-            return ((Double) val).doubleValue();
+            return (Double) val;
+        } else if (type == PropertyType.LONG) {
+            return ((Long) val).doubleValue();
         } else if (type == PropertyType.DATE) {
             return ((Calendar) val).getTimeInMillis();
         } else if (type == PropertyType.DECIMAL) {
@@ -279,7 +288,7 @@
      */
     public long getLong() throws RepositoryException {
         if (type == PropertyType.LONG) {
-            return ((Long) val).longValue();
+            return (Long) val;
         } else if (type == PropertyType.DOUBLE) {
             return ((Double) val).longValue();
         } else if (type == PropertyType.DECIMAL) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java Wed Jul  8 13:57:13 2009
@@ -61,7 +61,7 @@
         Name nodeType = propertyDefinition.getDeclaringNodeType();
         Name name = propertyDefinition.getName();
 
-        if (NameConstants.NT_HIERARCHYNODE.equals(nodeType) && NameConstants.JCR_CREATED.equals(name)) {
+        if ((NameConstants.NT_HIERARCHYNODE.equals(nodeType) || NameConstants.MIX_CREATED.equals(nodeType))&& NameConstants.JCR_CREATED.equals(name)) {
             return new QValue[] { create(Calendar.getInstance()) };
         } else if (NameConstants.NT_RESOURCE.equals(nodeType) && NameConstants.JCR_LASTMODIFIED.equals(name)) {
             return new QValue[] { create(Calendar.getInstance()) };

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java Wed Jul  8 13:57:13 2009
@@ -26,6 +26,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
+import javax.jcr.Binary;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -39,6 +40,7 @@
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
+import java.io.RandomAccessFile;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.math.BigDecimal;
@@ -85,12 +87,17 @@
                     return new QValueImpl(Double.valueOf(value));
                 case PropertyType.LONG:
                     return new QValueImpl(Long.valueOf(value));
+                case PropertyType.DECIMAL:
+                    return new QValueImpl(new BigDecimal(value));
+                case PropertyType.URI:
+                    return new QValueImpl(URI.create(value));
                 case PropertyType.PATH:
                     return new QValueImpl(PATH_FACTORY.create(value));
                 case PropertyType.NAME:
                     return new QValueImpl(NAME_FACTORY.create(value));
                 case PropertyType.STRING:
                 case PropertyType.REFERENCE:
+                case PropertyType.WEAKREFERENCE:
                     return new QValueImpl(value, type);
                 case PropertyType.BINARY:
                     return new BinaryQValue(value.getBytes(DEFAULT_ENCODING));
@@ -164,6 +171,26 @@
     }
 
     /**
+     * @see QValueFactory#create(URI)
+     */
+    public QValue create(URI value) {
+        if (value == null) {
+            throw new IllegalArgumentException("Cannot create QValue from null value.");
+        }
+        return new QValueImpl(value);
+    }
+
+    /**
+     * @see QValueFactory#create(URI)
+     */
+    public QValue create(BigDecimal value) {
+        if (value == null) {
+            throw new IllegalArgumentException("Cannot create QValue from null value.");
+        }
+        return new QValueImpl(value);
+    }
+
+    /**
      * @see QValueFactory#create(byte[])
      */
     public QValue create(byte[] value) {
@@ -222,6 +249,10 @@
             super(value);
         }
 
+        private QValueImpl(BigDecimal value) {
+            super(value);
+        }
+
         private QValueImpl(Boolean value) {
             super(value);
         }
@@ -234,6 +265,10 @@
             super(value);
         }
 
+        private QValueImpl(URI value) {
+            super(value);
+        }
+
         //---------------------------------------------------------< QValue >---
         /**
          * @see QValue#getString()
@@ -243,6 +278,36 @@
         }
 
         /**
+         * @see QValue#getBinary()
+         */
+        public Binary getBinary() throws RepositoryException {
+            // TODO FIXME consolidate Binary implementations
+            return new Binary() {
+                public InputStream getStream() throws RepositoryException {
+                    return QValueImpl.this.getStream();
+                }
+
+                public int read(byte[] b, long position) throws IOException, RepositoryException {
+                    InputStream in = getStream();
+                    try {
+                        in.skip(position);
+                        return in.read(b);
+                    } finally {
+                        in.close();
+                    }
+                }
+
+                public long getSize() throws RepositoryException {
+                    return getLength();
+                }
+
+                public void dispose() {
+                }
+
+            };
+        }
+
+        /**
          * @see QValue#getStream()
          */
         public InputStream getStream() throws RepositoryException {
@@ -310,7 +375,7 @@
      * state, i.e. the <code>getStream()</code> method always returns a fresh
      * <code>InputStream</code> instance.
      */
-    private static class BinaryQValue implements QValue, Serializable {
+    private static class BinaryQValue implements QValue, Binary, Serializable {
         /**
          * empty array
          */
@@ -575,7 +640,7 @@
          * @see QValue#getBoolean()
          */
         public boolean getBoolean() throws RepositoryException {
-            return Boolean.valueOf(getString()).booleanValue();
+            return Boolean.valueOf(getString());
         }
 
         /**
@@ -608,6 +673,13 @@
         }
 
         /**
+         * @see QValue#getBinary()
+         */
+        public Binary getBinary() throws RepositoryException {
+            return this;
+        }
+
+        /**
          * Frees temporarily allocated resources such as temporary file, buffer, etc.
          * If this <code>BinaryQValue</code> is backed by a persistent resource
          * calling this method will have no effect.
@@ -628,6 +700,10 @@
             }
         }
 
+        public void dispose() {
+            discard();
+        }
+
         //-----------------------------------------------< java.lang.Object >---
         /**
          * Returns a string representation of this <code>BinaryQValue</code>
@@ -712,6 +788,35 @@
             }
         }
 
+        //-----------------------------< javx.jcr.Binary >----------------------
+        /**
+         * {@inheritDoc}
+         */
+        public int read(byte[] b, long position) throws IOException, RepositoryException {
+            if (file != null) {
+                // this instance is backed by a temp file
+                RandomAccessFile raf = new RandomAccessFile(file, "r");
+                raf.seek(position);
+                return raf.read(b);
+            } else {
+                // this instance is backed by an in-memory buffer
+                int length = Math.min(b.length, buffer.length - (int) position);
+                if (length > 0) {
+                    System.arraycopy(buffer, (int) position, b, 0, length);
+                    return length;
+                } else {
+                    return -1;
+                }
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public long getSize() throws RepositoryException {
+            return getLength();
+        }
+
         //-----------------------------< Serializable >-------------------------
 
         private void writeObject(ObjectOutputStream out)

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Wed Jul  8 13:57:13 2009
@@ -94,16 +94,24 @@
      * @see javax.jcr.Value#getDecimal()
      */
     public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        setValueConsumed();
+        switch (getType()) {
+            case PropertyType.DECIMAL:
+            case PropertyType.DOUBLE:
+            case PropertyType.LONG:
+            case PropertyType.DATE:
+            case PropertyType.STRING:
+                return qvalue.getDecimal();
+            default:
+                throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType()));
+        }
     }
 
     /**
      * @see javax.jcr.Value#getBinary()
      */
     public Binary getBinary() throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2056");
+        return qvalue.getBinary();
     }
 
     /**
@@ -170,7 +178,7 @@
     }
 
     /**
-     * @see javax.jcr.Value#getType() 
+     * @see javax.jcr.Value#getType()
      */
     public int getType() {
         return qvalue.getType();
@@ -189,7 +197,7 @@
     }
 
     /**
-     * @see Object#hashCode() 
+     * @see Object#hashCode()
      */
     public int hashCode() {
         return qvalue.hashCode();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java Wed Jul  8 13:57:13 2009
@@ -165,8 +165,7 @@
      * {@inheritDoc}
      */
     public Value createValue(Node value) throws RepositoryException {
-        QValue qvalue = qfactory.create(value.getUUID(), PropertyType.REFERENCE);
-        return new QValueValue(qvalue, resolver);
+        return createValue(value, false);
     }
 
     /**
@@ -201,22 +200,37 @@
     }
 
     public Binary createBinary(InputStream stream) throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2056");
+        // TODO review/optimize/refactor
+        try {
+            QValue qvalue = qfactory.create(stream);
+            return qvalue.getBinary();
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        } catch (RepositoryException ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
     public Value createValue(Binary value) {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2056");
+        // TODO review/optimize/refactor
+        try {
+            return createValue(value.getStream());
+        } catch (RepositoryException ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
     public Value createValue(BigDecimal value) {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        try {
+            QValue qvalue = qfactory.create(value);
+            return new QValueValue(qvalue, resolver);
+        } catch (RepositoryException ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
     public Value createValue(Node value, boolean weak) throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        QValue qvalue = qfactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE);
+        return new QValueValue(qvalue, resolver);
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,9 @@
         } else if (jcrValue instanceof QValueValue) {
             return ((QValueValue)jcrValue).getQValue();
         } else if (jcrValue.getType() == PropertyType.BINARY) {
+            // TODO: jsr 283 binary property conversion
             try {
+                //return factory.create(jcrValue.getBinary());
                 return factory.create(jcrValue.getStream());
             } catch (IOException e) {
                 throw new RepositoryException(e);
@@ -61,6 +63,8 @@
             return factory.create(jcrValue.getDouble());
         } else if (jcrValue.getType() == PropertyType.LONG) {
             return factory.create(jcrValue.getLong());
+        } else if (jcrValue.getType() == PropertyType.DECIMAL) {
+            return factory.create(jcrValue.getDecimal());
         } else {
             return getQValue(jcrValue.getString(), jcrValue.getType(), resolver, factory);
         }
@@ -107,8 +111,11 @@
             case PropertyType.BOOLEAN:
             case PropertyType.DOUBLE:
             case PropertyType.LONG:
+            case PropertyType.DECIMAL:
             case PropertyType.DATE:
             case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+            case PropertyType.URI:
                 qValue = factory.create(jcrValue, propertyType);
                 break;
             case PropertyType.BINARY:
@@ -129,47 +136,52 @@
     }
 
     /**
-     * @param qualifiedValue
+     * @param value
      * @param resolver
      * @param factory
-     * @return the JCR value created from the given <code>qualifiedValue</code>.
+     * @return the JCR value created from the given <code>QValue</code>.
      * @throws RepositoryException
      */
-    public static Value getJCRValue(QValue qualifiedValue,
+    public static Value getJCRValue(QValue value,
                                     NamePathResolver resolver,
                                     ValueFactory factory) throws RepositoryException {
         if (factory instanceof ValueFactoryQImpl) {
-            return ((ValueFactoryQImpl)factory).createValue(qualifiedValue);
+            return ((ValueFactoryQImpl)factory).createValue(value);
         } else {
             Value jcrValue;
-            int propertyType = qualifiedValue.getType();
+            int propertyType = value.getType();
             switch (propertyType) {
                 case PropertyType.STRING:
                 case PropertyType.REFERENCE:
-                    jcrValue = factory.createValue(qualifiedValue.getString(), propertyType);
+                case PropertyType.WEAKREFERENCE:
+                case PropertyType.URI:
+                    jcrValue = factory.createValue(value.getString(), propertyType);
                     break;
                 case PropertyType.PATH:
-                    Path qPath = qualifiedValue.getPath();
+                    Path qPath = value.getPath();
                     jcrValue = factory.createValue(resolver.getJCRPath(qPath), propertyType);
                     break;
                 case PropertyType.NAME:
-                    Name qName = qualifiedValue.getName();
+                    Name qName = value.getName();
                     jcrValue = factory.createValue(resolver.getJCRName(qName), propertyType);
                     break;
                 case PropertyType.BOOLEAN:
-                    jcrValue = factory.createValue(qualifiedValue.getBoolean());
+                    jcrValue = factory.createValue(value.getBoolean());
                     break;
                 case PropertyType.BINARY:
-                    jcrValue = factory.createValue(qualifiedValue.getStream());
+                    jcrValue = factory.createValue(value.getBinary());
                     break;
                 case PropertyType.DATE:
-                    jcrValue = factory.createValue(qualifiedValue.getCalendar());
+                    jcrValue = factory.createValue(value.getCalendar());
                     break;
                 case PropertyType.DOUBLE:
-                    jcrValue = factory.createValue(qualifiedValue.getDouble());
+                    jcrValue = factory.createValue(value.getDouble());
                     break;
                 case PropertyType.LONG:
-                    jcrValue = factory.createValue(qualifiedValue.getLong());
+                    jcrValue = factory.createValue(value.getLong());
+                    break;
+                case PropertyType.DECIMAL:
+                    jcrValue = factory.createValue(value.getDecimal());
                     break;
                 default:
                     throw new RepositoryException("illegal internal value type");
@@ -177,4 +189,46 @@
             return jcrValue;
         }
     }
+
+    /**
+     * Returns the JCR string representation of the given <code>QValue</code>.
+     * This method is a shortcut for
+     * {@link #getJCRValue(QValue, NamePathResolver, ValueFactory)} followed by
+     * {@link Value#getString()}.
+     *
+     * @param value
+     * @param resolver
+     * @return the JCR String representation for the given <code>QValue</code>.
+     * @throws RepositoryException
+     */
+    public static String getJCRString(QValue value,
+                                      NamePathResolver resolver) throws RepositoryException {
+        String jcrString;
+        int propertyType = value.getType();
+        switch (propertyType) {
+            case PropertyType.STRING:
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+            case PropertyType.URI:
+            case PropertyType.BOOLEAN:
+            case PropertyType.DATE:
+            case PropertyType.DOUBLE:
+            case PropertyType.LONG:
+            case PropertyType.DECIMAL:
+            case PropertyType.BINARY:
+                jcrString = value.getString();
+                break;
+            case PropertyType.PATH:
+                Path qPath = value.getPath();
+                jcrString = resolver.getJCRPath(qPath);
+                break;
+            case PropertyType.NAME:
+                Name qName = value.getName();
+                jcrString = resolver.getJCRName(qName);
+                break;
+            default:
+                throw new RepositoryException("illegal internal value type");
+        }
+        return jcrString;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/resources/META-INF/services/org.apache.jackrabbit.spi.commons.query.QueryTreeBuilder
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/resources/META-INF/services/org.apache.jackrabbit.spi.commons.query.QueryTreeBuilder?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/resources/META-INF/services/org.apache.jackrabbit.spi.commons.query.QueryTreeBuilder (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/resources/META-INF/services/org.apache.jackrabbit.spi.commons.query.QueryTreeBuilder Wed Jul  8 13:57:13 2009
@@ -15,7 +15,7 @@
 
 #
 # This file lists all available query language implementations that are shipped
-# with Jackrabbit.
+# with Jackrabbit and are based on the proprietary QueryTree.
 #
 
 org.apache.jackrabbit.spi.commons.query.xpath.QueryBuilder

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrName.java Wed Jul  8 13:57:13 2009
@@ -39,6 +39,17 @@
         list.add(new JcrName("...", "", "..."));
         list.add(new JcrName(".a.", "", ".a."));
 
+        // valid names since jcr 2.0
+        list.add(new JcrName("a'", "", "a'"));                   // single quote
+        list.add(new JcrName("'a", "", "'a"));
+        list.add(new JcrName("ab'c", "", "ab'c"));
+        list.add(new JcrName("prefix:ab'c", "prefix", "ab'c"));
+
+        list.add(new JcrName("a\"", "", "a\""));                 // double quote
+        list.add(new JcrName("\"a", "", "\"a"));
+        list.add(new JcrName("ab\"c", "", "ab\"c"));
+        list.add(new JcrName("prefix:ab\"c", "prefix", "ab\"c"));       
+
         // expanded names
         list.add(new JcrName("{}a", "", "a"));
         list.add(new JcrName("{}name", "", "name"));
@@ -60,11 +71,22 @@
         list.add(new JcrName("prefix:name "));
         list.add(new JcrName("pre fix:name"));
         list.add(new JcrName("prefix :name"));
+
         list.add(new JcrName("name/name"));
+
         list.add(new JcrName("name[name"));
         list.add(new JcrName("name]name"));
+        list.add(new JcrName("name[]"));
+        list.add(new JcrName("name[123]"));
+
         list.add(new JcrName("name*name"));
+
         list.add(new JcrName("prefix:name:name"));
+
+        list.add(new JcrName("name|name"));
+        list.add(new JcrName("|name"));
+        list.add(new JcrName("name|"));
+        list.add(new JcrName("prefix:name|name"));
     }
 
     private static JcrName[] tests = (JcrName[]) list.toArray(new JcrName[list.size()]);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrPath.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrPath.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrPath.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/JcrPath.java Wed Jul  8 13:57:13 2009
@@ -46,6 +46,10 @@
         list.add(new JcrPath("/a/..../", "/a/....", NOR|VAL));
         list.add(new JcrPath("/a/b:.a./", "/a/b:.a.", NOR|VAL));
 
+        // ... containing special characters allowed since JCR 2.0
+        list.add(new JcrPath("/name's[2]/'name[2]", NOR|VAL));
+        list.add(new JcrPath("/\"name\"[2]/name[2]", NOR|VAL));
+
         // relative paths
         list.add(new JcrPath("a/b/c/", "a/b/c", NOR|VAL));
         list.add(new JcrPath("a/b/c", NOR|VAL));
@@ -74,6 +78,16 @@
         list.add(new JcrPath("/..", "/..", 0));
         list.add(new JcrPath("/a/b/../../..", "/a/b/../../..", 0));
 
+        list.add(new JcrPath("/prefix:*name"));
+        list.add(new JcrPath("/prefix:n*ame"));
+        list.add(new JcrPath("/prefix:|name"));
+        list.add(new JcrPath("/prefix:n|ame"));
+
+        list.add(new JcrPath("/name[2]\""));
+        list.add(new JcrPath("/name[2]\"/name"));
+        list.add(new JcrPath("/name[2]'"));
+        list.add(new JcrPath("/name[2]'/name"));
+
         // normalized, relative paths
         list.add(new JcrPath(".", ".", NOR|VAL));
         list.add(new JcrPath("..", "..", NOR|VAL));



Mime
View raw message