jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r590014 [8/11] - in /jackrabbit/trunk: jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jou...
Date Tue, 30 Oct 2007 10:02:57 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/sql/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/sql/QueryFormat.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/sql/QueryFormat.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/sql/QueryFormat.java Tue Oct 30 03:02:41 2007
@@ -32,14 +32,14 @@
 import org.apache.jackrabbit.core.query.RelationQueryNode;
 import org.apache.jackrabbit.core.query.TextsearchQueryNode;
 import org.apache.jackrabbit.core.query.PropertyFunctionQueryNode;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.util.ISO8601;
+import org.apache.jackrabbit.conversion.NameResolver;
 
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.NamespaceException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Iterator;
@@ -54,7 +54,7 @@
     /**
      * Will be used to resolve QNames
      */
-    private final NamespaceResolver resolver;
+    private final NameResolver resolver;
 
     /**
      * The String representation of the query node tree
@@ -71,7 +71,7 @@
      */
     private List nodeTypes = new ArrayList();
 
-    private QueryFormat(QueryRootNode root, NamespaceResolver resolver)
+    private QueryFormat(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
@@ -91,7 +91,7 @@
      * @throws InvalidQueryException the query node tree cannot be represented
      *                               as a SQL <code>String</code>.
      */
-    public static String toString(QueryRootNode root, NamespaceResolver resolver)
+    public static String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         return new QueryFormat(root, resolver).toString();
     }
@@ -112,7 +112,7 @@
         try {
             sb.append("SELECT");
 
-            QName[] selectProps = node.getSelectProperties();
+            Name[] selectProps = node.getSelectProperties();
             if (selectProps.length == 0) {
                 sb.append(" *");
             } else {
@@ -151,7 +151,7 @@
             String comma = "";
             int ntCount = 0;
             for (Iterator it = nodeTypes.iterator(); it.hasNext(); ntCount++) {
-                QName nt = (QName) it.next();
+                Name nt = (Name) it.next();
                 sb.append(comma).append(" ");
                 appendName(nt, resolver, sb);
                 comma = ",";
@@ -159,7 +159,7 @@
 
             if (ntCount == 0) {
                 sb.append(" ");
-                sb.append(NameFormat.format(QName.NT_BASE, resolver));
+                sb.append(resolver.getJCRName(NameConstants.NT_BASE));
             }
 
             // append WHERE clause
@@ -181,7 +181,7 @@
                 }
                 node.getLocationNode().accept(this, sb);
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
 
@@ -259,7 +259,7 @@
         StringBuffer sb = (StringBuffer) data;
         try {
             appendName(node.getPropertyName(), resolver, sb);
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         sb.append("='").append(node.getValue()).append("'");
@@ -285,7 +285,7 @@
             } else {
                 try {
                     appendName(node.getRelativePath().getNameElement().getName(), resolver, sb);
-                } catch (NoPrefixDeclaredException e) {
+                } catch (NamespaceException e) {
                     exceptions.add(e);
                 }
             }
@@ -300,7 +300,7 @@
         try {
             if (containsDescendantOrSelf(node)) {
                 sb.append("(");
-                sb.append(NameFormat.format(QName.JCR_PATH, resolver));
+                sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 LocationStepQueryNode[] steps = node.getPathSteps();
                 for (int i = 0; i < steps.length; i++) {
@@ -315,7 +315,7 @@
                 }
                 sb.append('\'');
                 sb.append(" OR ");
-                sb.append(NameFormat.format(QName.JCR_PATH, resolver));
+                sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 for (int i = 0; i < steps.length; i++) {
                     if (steps[i].getNameTest() == null
@@ -328,7 +328,7 @@
                 }
                 sb.append("')");
             } else if (containsAllChildrenMatch(node)) {
-                sb.append(NameFormat.format(QName.JCR_PATH, resolver));
+                sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 StringBuffer path = new StringBuffer();
                 LocationStepQueryNode[] steps = node.getPathSteps();
@@ -342,12 +342,12 @@
                 sb.append(path);
                 sb.append('\'');
                 sb.append(" AND NOT ");
-                sb.append(NameFormat.format(QName.JCR_PATH, resolver));
+                sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 sb.append(path).append("/%").append('\'');
             } else {
                 // just do a best effort
-                sb.append(NameFormat.format(QName.JCR_PATH, resolver));
+                sb.append(resolver.getJCRName(NameConstants.JCR_PATH));
                 sb.append(" LIKE '");
                 LocationStepQueryNode[] steps = node.getPathSteps();
                 for (int i = 0; i < steps.length; i++) {
@@ -359,7 +359,7 @@
                 }
                 sb.append('\'');
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -372,8 +372,8 @@
         } else {
             if (node.getNameTest().getLocalName().length() > 0) {
                 try {
-                    sb.append(NameFormat.format(node.getNameTest(), resolver));
-                } catch (NoPrefixDeclaredException e) {
+                    sb.append(resolver.getJCRName(node.getNameTest()));
+                } catch (NamespaceException e) {
                     exceptions.add(e);
                 }
                 if (node.getIndex() == LocationStepQueryNode.NONE) {
@@ -462,7 +462,7 @@
             if (node.getOperation() == OPERATION_LIKE && node.getStringValue().indexOf('\\') > -1) {
                 sb.append(" ESCAPE '\\'");
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -483,7 +483,7 @@
                     }
                     comma = ",";
                 }
-            } catch (NoPrefixDeclaredException e) {
+            } catch (NamespaceException e) {
                 exceptions.add(e);
             }
         } else {
@@ -513,21 +513,21 @@
      * <code>resolver</code>. The <code>name</code> is put in double quotes
      * if the local part of <code>name</code> contains a space character.
      *
-     * @param name     the <code>QName</code> to print.
+     * @param name     the <code>Name</code> to print.
      * @param resolver to resolve <code>name</code>.
      * @param b        where to output the <code>name</code>.
-     * @throws NoPrefixDeclaredException if <code>name</code> contains a uri
+     * @throws NamespaceException if <code>name</code> contains a uri
      *                                   that is not declared in <code>resolver</code>.
      */
-    private static void appendName(QName name,
-                                   NamespaceResolver resolver,
+    private static void appendName(Name name,
+                                   NameResolver resolver,
                                    StringBuffer b)
-            throws NoPrefixDeclaredException {
+            throws NamespaceException {
         boolean quote = name.getLocalName().indexOf(' ') > -1;
         if (quote) {
             b.append('"');
         }
-        b.append(NameFormat.format(name, resolver));
+        b.append(resolver.getJCRName(name));
         if (quote) {
             b.append('"');
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java Tue Oct 30 03:02:41 2007
@@ -19,7 +19,7 @@
 import org.apache.jackrabbit.core.query.QueryTreeBuilder;
 import org.apache.jackrabbit.core.query.QueryRootNode;
 import org.apache.jackrabbit.core.query.QueryNodeFactory;
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.conversion.NameResolver;
 
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
@@ -33,7 +33,7 @@
      * @inheritDoc
      */
     public QueryRootNode createQueryTree(String statement,
-                                         NamespaceResolver resolver,
+                                         NameResolver resolver,
                                          QueryNodeFactory factory)
             throws InvalidQueryException {
         return XPathQueryBuilder.createQuery(statement, resolver, factory);
@@ -57,7 +57,7 @@
     /**
      * @inheritDoc
      */
-    public String toString(QueryRootNode root, NamespaceResolver resolver)
+    public String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         return XPathQueryBuilder.toString(root, resolver);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryFormat.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryFormat.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryFormat.java Tue Oct 30 03:02:41 2007
@@ -33,15 +33,15 @@
 import org.apache.jackrabbit.core.query.TextsearchQueryNode;
 import org.apache.jackrabbit.core.query.PropertyFunctionQueryNode;
 import org.apache.jackrabbit.core.query.DefaultQueryNodeVisitor;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.name.NameFactoryImpl;
 
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.NamespaceException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
@@ -55,7 +55,7 @@
     /**
      * Will be used to resolve QNames
      */
-    private final NamespaceResolver resolver;
+    private final NameResolver resolver;
 
     /**
      * The String representation of the query node tree
@@ -67,7 +67,7 @@
      */
     private List exceptions = new ArrayList();
 
-    private QueryFormat(QueryRootNode root, NamespaceResolver resolver)
+    private QueryFormat(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         this.resolver = resolver;
         statement = root.accept(this, new StringBuffer()).toString();
@@ -87,7 +87,7 @@
      * @throws InvalidQueryException the query node tree cannot be represented
      *                               as a XPath <code>String</code>.
      */
-    public static String toString(QueryRootNode root, NamespaceResolver resolver)
+    public static String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         return new QueryFormat(root, resolver).toString();
     }
@@ -109,7 +109,7 @@
         if (node.getOrderNode() != null) {
             node.getOrderNode().accept(this, data);
         }
-        QName[] selectProps = node.getSelectProperties();
+        Name[] selectProps = node.getSelectProperties();
         if (selectProps.length > 0) {
             sb.append('/');
             boolean union = selectProps.length > 1;
@@ -121,9 +121,9 @@
                 try {
                     sb.append(pipe);
                     sb.append('@');
-                    NameFormat.format(ISO9075.encode(selectProps[i]), resolver, sb);
+                    sb.append(resolver.getJCRName(encode(selectProps[i])));
                     pipe = "|";
-                } catch (NoPrefixDeclaredException e) {
+                } catch (NamespaceException e) {
                     exceptions.add(e);
                 }
             }
@@ -173,11 +173,11 @@
         QueryNode[] operands = node.getOperands();
         if (operands.length > 0) {
             try {
-                NameFormat.format(XPathQueryBuilder.FN_NOT_10, resolver, sb);
+                sb.append(resolver.getJCRName(XPathQueryBuilder.FN_NOT_10));
                 sb.append("(");
                 operands[0].accept(this, sb);
                 sb.append(")");
-            } catch (NoPrefixDeclaredException e) {
+            } catch (NamespaceException e) {
                 exceptions.add(e);
             }
         }
@@ -188,10 +188,11 @@
         StringBuffer sb = (StringBuffer) data;
         sb.append("@");
         try {
-            NameFormat.format(ISO9075.encode(node.getPropertyName()), resolver, sb);
+            Name name = encode(node.getPropertyName());
+            sb.append(resolver.getJCRName(name));
             sb.append("='");
-            NameFormat.format(node.getValue(), resolver, sb);
-        } catch (NoPrefixDeclaredException e) {
+            sb.append(resolver.getJCRName(node.getValue()));
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         sb.append("'");
@@ -206,13 +207,13 @@
     public Object visit(TextsearchQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         try {
-            NameFormat.format(XPathQueryBuilder.JCR_CONTAINS, resolver, sb);
+            sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_CONTAINS));
             sb.append("(");
             Path relPath = node.getRelativePath();
             if (relPath == null) {
                 sb.append(".");
             } else {
-                Path.PathElement[] elements = relPath.getElements();
+                Path.Element[] elements = relPath.getElements();
                 String slash = "";
                 for (int i = 0; i < elements.length; i++) {
                     sb.append(slash);
@@ -223,7 +224,8 @@
                     if (elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
                         sb.append("*");
                     } else {
-                        NameFormat.format(ISO9075.encode(elements[i].getName()), resolver, sb);
+                        Name n = encode(elements[i].getName());
+                        sb.append(resolver.getJCRName(n));
                     }
                     if (elements[i].getIndex() != 0) {
                         sb.append("[").append(elements[i].getIndex()).append("]");
@@ -233,7 +235,7 @@
             sb.append(", '");
             sb.append(node.getQuery().replaceAll("'", "''"));
             sb.append("')");
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -259,7 +261,7 @@
         if (node.getIncludeDescendants()) {
             sb.append('/');
         }
-        final QName[] nodeType = new QName[1];
+        final Name[] nodeType = new Name[1];
         node.acceptOperands(new DefaultQueryNodeVisitor() {
             public Object visit(NodeTypeQueryNode node, Object data) {
                 nodeType[0] = node.getValue();
@@ -276,11 +278,11 @@
         } else {
             try {
                 if (node.getNameTest().getLocalName().length() == 0) {
-                    NameFormat.format(XPathQueryBuilder.JCR_ROOT, resolver, sb);
+                    sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_ROOT));
                 } else {
-                    NameFormat.format(ISO9075.encode(node.getNameTest()), resolver, sb);
+                    sb.append(resolver.getJCRName(encode(node.getNameTest())));
                 }
-            } catch (NoPrefixDeclaredException e) {
+            } catch (NamespaceException e) {
                 exceptions.add(e);
             }
         }
@@ -288,8 +290,8 @@
         if (nodeType[0] != null) {
             sb.append(", ");
             try {
-                NameFormat.format(ISO9075.encode(nodeType[0]), resolver, sb);
-            } catch (NoPrefixDeclaredException e) {
+                sb.append(resolver.getJCRName(encode(nodeType[0])));
+            } catch (NamespaceException e) {
                 exceptions.add(e);
             }
             sb.append(")");
@@ -314,17 +316,17 @@
     public Object visit(DerefQueryNode node, Object data) {
         StringBuffer sb = (StringBuffer) data;
         try {
-            NameFormat.format(XPathQueryBuilder.JCR_DEREF, resolver, sb);
+            sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_DEREF));
             sb.append("(@");
-            NameFormat.format(ISO9075.encode(node.getRefProperty()), resolver, sb);
+            sb.append(resolver.getJCRName(encode(node.getRefProperty())));
             sb.append(", '");
             if (node.getNameTest() == null) {
                 sb.append("*");
             } else {
-                NameFormat.format(ISO9075.encode(node.getNameTest()), resolver, sb);
+                sb.append(resolver.getJCRName(encode(node.getNameTest())));
             }
             sb.append("')");
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -340,9 +342,9 @@
             if (relPath == null) {
                 propPath.append(".");
             } else if (relPath.getNameElement().getName().equals(XPathQueryBuilder.FN_POSITION_FULL)) {
-                NameFormat.format(XPathQueryBuilder.FN_POSITION_FULL, resolver, propPath);
+                propPath.append(resolver.getJCRName(XPathQueryBuilder.FN_POSITION_FULL));
             } else {
-                Path.PathElement[] elements = relPath.getElements();
+                Path.Element[] elements = relPath.getElements();
                 String slash = "";
                 for (int i = 0; i < elements.length; i++) {
                     propPath.append(slash);
@@ -353,7 +355,7 @@
                     if (elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
                         propPath.append("*");
                     } else {
-                        NameFormat.format(ISO9075.encode(elements[i].getName()), resolver, propPath);
+                        propPath.append(resolver.getJCRName(encode(elements[i].getName())));
                     }
                     if (elements[i].getIndex() != 0) {
                         propPath.append("[").append(elements[i].getIndex()).append("]");
@@ -389,7 +391,7 @@
                 sb.append(propPath).append(" le ");
                 appendValue(node, sb);
             } else if (node.getOperation() == OPERATION_LIKE) {
-                NameFormat.format(XPathQueryBuilder.JCR_LIKE, resolver, sb);
+                sb.append(resolver.getJCRName(XPathQueryBuilder.JCR_LIKE));
                 sb.append("(").append(propPath).append(", ");
                 appendValue(node, sb);
                 sb.append(")");
@@ -406,23 +408,23 @@
                 sb.append(propPath).append(" ne ");
                 appendValue(node, sb);
             } else if (node.getOperation() == OPERATION_NULL) {
-                NameFormat.format(XPathQueryBuilder.FN_NOT, resolver, sb);
+                sb.append(resolver.getJCRName(XPathQueryBuilder.FN_NOT));
                 sb.append("(").append(propPath).append(")");
             } else if (node.getOperation() == OPERATION_NOT_NULL) {
                 sb.append(propPath);
             } else if (node.getOperation() == OPERATION_SIMILAR) {
-                NameFormat.format(XPathQueryBuilder.REP_SIMILAR, resolver, sb);
+                sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SIMILAR));
                 sb.append("(").append(propPath).append(", ");
                 appendValue(node, sb);
             } else if (node.getOperation() == OPERATION_SPELLCHECK) {
-                NameFormat.format(XPathQueryBuilder.REP_SPELLCHECK, resolver, sb);
+                sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SPELLCHECK));
                 sb.append("(");
                 appendValue(node, sb);
                 sb.append(")");
             } else {
                 exceptions.add(new InvalidQueryException("Invalid operation: " + node.getOperation()));
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -436,15 +438,15 @@
         try {
             for (int i = 0; i < specs.length; i++) {
                 sb.append(comma);
-                QName prop = ISO9075.encode(specs[i].getProperty());
+                Name prop = encode(specs[i].getProperty());
                 sb.append(" @");
-                NameFormat.format(prop, resolver, sb);
+                sb.append(resolver.getJCRName(prop));
                 if (!specs[i].isAscending()) {
                     sb.append(" descending");
                 }
                 comma = ",";
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return data;
@@ -455,15 +457,15 @@
         String functionName = node.getFunctionName();
         try {
             if (functionName.equals(PropertyFunctionQueryNode.LOWER_CASE)) {
-                sb.insert(0, NameFormat.format(XPathQueryBuilder.FN_LOWER_CASE, resolver) + "(");
+                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_LOWER_CASE) + "(");
                 sb.append(")");
             } else if (functionName.equals(PropertyFunctionQueryNode.UPPER_CASE)) {
-                sb.insert(0, NameFormat.format(XPathQueryBuilder.FN_UPPER_CASE, resolver) + "(");
+                sb.insert(0, resolver.getJCRName(XPathQueryBuilder.FN_UPPER_CASE) + "(");
                 sb.append(")");
             } else {
                 exceptions.add(new InvalidQueryException("Unsupported function: " + functionName));
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return sb;
@@ -477,11 +479,11 @@
      *
      * @param node the relation node.
      * @param b    where to append the value.
-     * @throws NoPrefixDeclaredException if a prefix declaration is missing for
+     * @throws NamespaceException if a prefix declaration is missing for
      *                                   a namespace URI.
      */
     private void appendValue(RelationQueryNode node, StringBuffer b)
-            throws NoPrefixDeclaredException {
+            throws NamespaceException {
         if (node.getValueType() == TYPE_LONG) {
             b.append(node.getLongValue());
         } else if (node.getValueType() == TYPE_DOUBLE) {
@@ -491,7 +493,7 @@
         } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
             cal.setTime(node.getDateValue());
-            NameFormat.format(XPathQueryBuilder.XS_DATETIME, resolver, b);
+            b.append(resolver.getJCRName(XPathQueryBuilder.XS_DATETIME));
             b.append("('").append(ISO8601.format(cal)).append("')");
         } else if (node.getValueType() == TYPE_POSITION) {
             if (node.getPositionValue() == LocationStepQueryNode.LAST) {
@@ -501,6 +503,15 @@
             }
         } else {
             exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType()));
+        }
+    }
+
+    private static Name encode(Name name) {
+        String encoded = ISO9075.encode(name.getLocalName());
+        if (encoded.equals(name.getLocalName())) {
+            return name;
+        } else {
+            return NameFactoryImpl.getInstance().create(name.getNamespaceURI(), encoded);
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java Tue Oct 30 03:02:41 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.query.xpath;
 
+import org.apache.jackrabbit.conversion.MalformedPathException;
+import org.apache.jackrabbit.conversion.NameResolver;
 import org.apache.jackrabbit.core.query.DerefQueryNode;
 import org.apache.jackrabbit.core.query.LocationStepQueryNode;
 import org.apache.jackrabbit.core.query.NAryQueryNode;
@@ -31,18 +33,22 @@
 import org.apache.jackrabbit.core.query.PropertyFunctionQueryNode;
 import org.apache.jackrabbit.core.query.DefaultQueryNodeVisitor;
 import org.apache.jackrabbit.core.query.QueryNodeFactory;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.name.NameFactoryImpl;
+import org.apache.jackrabbit.name.PathBuilder;
+import org.apache.jackrabbit.name.PathFactoryImpl;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.commons.collections.map.ReferenceMap;
 
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -54,110 +60,113 @@
  */
 public class XPathQueryBuilder implements XPathVisitor, XPathTreeConstants {
 
+    private static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
+    private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
+
     /**
      * Namespace uri for xpath functions. See also class SearchManager
      */
     static final String NS_FN_URI = "http://www.w3.org/2005/xpath-functions";
 
     /**
-     * QName for 'fn:not'
+     * Name for 'fn:not'
      */
-    static final QName FN_NOT = new QName(NS_FN_URI, "not");
+    static final Name FN_NOT = NAME_FACTORY.create(NS_FN_URI, "not");
 
     /**
-     * QName for 'fn:lower-case'
+     * Name for 'fn:lower-case'
      */
-    static final QName FN_LOWER_CASE = new QName(NS_FN_URI, "lower-case");
+    static final Name FN_LOWER_CASE = NAME_FACTORY.create(NS_FN_URI, "lower-case");
 
     /**
-     * QName for 'fn:upper-case'
+     * Name for 'fn:upper-case'
      */
-    static final QName FN_UPPER_CASE = new QName(NS_FN_URI, "upper-case");
+    static final Name FN_UPPER_CASE = NAME_FACTORY.create(NS_FN_URI, "upper-case");
 
     /**
-     * QName for 'not' as defined in XPath 1.0 (no prefix)
+     * Name for 'not' as defined in XPath 1.0 (no prefix)
      */
-    static final QName FN_NOT_10 = new QName("", "not");
+    static final Name FN_NOT_10 = NAME_FACTORY.create("", "not");
 
     /**
-     * QName for true function.
+     * Name for true function.
      */
-    static final QName FN_TRUE = new QName("", "true");
+    static final Name FN_TRUE = NAME_FACTORY.create("", "true");
 
     /**
-     * QName for false function.
+     * Name for false function.
      */
-    static final QName FN_FALSE = new QName("", "false");
+    static final Name FN_FALSE = NAME_FACTORY.create("", "false");
 
     /**
-     * QName for position function.
+     * Name for position function.
      */
-    static final QName FN_POSITION = new QName("", "position");
+    static final Name FN_POSITION = NAME_FACTORY.create("", "position");
 
     /**
-     * QName for element function.
+     * Name for element function.
      */
-    static final QName FN_ELEMENT = new QName("", "element");
+    static final Name FN_ELEMENT = NAME_FACTORY.create("", "element");
 
     /**
-     * QName for the full position function including bracket
+     * Name for the full position function including bracket
      */
-    static final QName FN_POSITION_FULL = new QName("", "position()");
+    static final Name FN_POSITION_FULL = NAME_FACTORY.create("", "position()");
 
     /**
-     * QName for jcr:xmltext
+     * Name for jcr:xmltext
      */
-    static final QName JCR_XMLTEXT = new QName(QName.NS_JCR_URI, "xmltext");
+    static final Name JCR_XMLTEXT = NAME_FACTORY.create(Name.NS_JCR_URI, "xmltext");
 
     /**
-     * QName for last function.
+     * Name for last function.
      */
-    static final QName FN_LAST = new QName("", "last");
+    static final Name FN_LAST = NAME_FACTORY.create("", "last");
 
     /**
-     * QName for first function.
+     * Name for first function.
      */
-    static final QName FN_FIRST = new QName("", "first");
+    static final Name FN_FIRST = NAME_FACTORY.create("", "first");
 
     /**
-     * QName for xs:dateTime
+     * Name for xs:dateTime
      */
-    static final QName XS_DATETIME = new QName("http://www.w3.org/2001/XMLSchema", "dateTime");
+    static final Name XS_DATETIME = NAME_FACTORY.create("http://www.w3.org/2001/XMLSchema", "dateTime");
 
     /**
-     * QName for jcr:like
+     * Name for jcr:like
      */
-    static final QName JCR_LIKE = new QName(QName.NS_JCR_URI, "like");
+    static final Name JCR_LIKE = NAME_FACTORY.create(Name.NS_JCR_URI, "like");
 
     /**
-     * QName for jcr:deref
+     * Name for jcr:deref
      */
-    static final QName JCR_DEREF = new QName(QName.NS_JCR_URI, "deref");
+    static final Name JCR_DEREF = NAME_FACTORY.create(Name.NS_JCR_URI, "deref");
 
     /**
-     * QName for jcr:contains
+     * Name for jcr:contains
      */
-    static final QName JCR_CONTAINS = new QName(QName.NS_JCR_URI, "contains");
+    static final Name JCR_CONTAINS = NAME_FACTORY.create(Name.NS_JCR_URI, "contains");
 
     /**
-     * QName for jcr:root
+     * Name for jcr:root
      */
-    static final QName JCR_ROOT = new QName(QName.NS_JCR_URI, "root");
+    static final Name JCR_ROOT = NAME_FACTORY.create(Name.NS_JCR_URI, "root");
 
     /**
-     * QName for jcr:score
+     * Name for jcr:score
      */
-    static final QName JCR_SCORE = new QName(QName.NS_JCR_URI, "score");
+    static final Name JCR_SCORE = NAME_FACTORY.create(Name.NS_JCR_URI, "score");
 
     /**
-     * QName for rep:similar
+     * Name for rep:similar
      */
-    static final QName REP_SIMILAR = new QName(QName.NS_REP_URI, "similar");
+    static final Name REP_SIMILAR = NAME_FACTORY.create(Name.NS_REP_URI, "similar");
 
     /**
-     * QName for rep:spellcheck
+     * Name for rep:spellcheck
      */
-    static final QName REP_SPELLCHECK = new QName(QName.NS_REP_URI, "spellcheck");
+    static final Name REP_SPELLCHECK = NAME_FACTORY.create(Name.NS_REP_URI, "spellcheck");
 
     /**
      * String constant for operator 'eq'
@@ -230,9 +239,9 @@
     private final QueryRootNode root;
 
     /**
-     * The {@link NamespaceResolver} in use
+     * The {@link NameResolver} in use
      */
-    private final NamespaceResolver resolver;
+    private final NameResolver resolver;
 
     /**
      * List of exceptions that are created while building the query tree
@@ -242,7 +251,7 @@
     /**
      * Temporary relative path
      */
-    private Path.PathBuilder tmpRelPath;
+    private PathBuilder tmpRelPath;
 
     /**
      * The query node factory.
@@ -253,12 +262,12 @@
      * Creates a new <code>XPathQueryBuilder</code> instance.
      *
      * @param statement the XPath statement.
-     * @param resolver  the namespace resolver to use.
+     * @param resolver  the name resolver to use.
      * @param factory   the query node factory.
      * @throws InvalidQueryException if the XPath statement is malformed.
      */
     private XPathQueryBuilder(String statement,
-                              NamespaceResolver resolver,
+                              NameResolver resolver,
                               QueryNodeFactory factory)
             throws InvalidQueryException {
         this.resolver = resolver;
@@ -309,13 +318,13 @@
      * passed query node <code>factory</code>.
      *
      * @param statement the XPath statement.
-     * @param resolver  the namespace resolver to use.
+     * @param resolver  the name resolver to use.
      * @param factory   the query node factory.
      * @return the <code>QueryNode</code> tree for the XPath statement.
      * @throws InvalidQueryException if the XPath statement is malformed.
      */
     public static QueryRootNode createQuery(String statement,
-                                            NamespaceResolver resolver,
+                                            NameResolver resolver,
                                             QueryNodeFactory factory)
             throws InvalidQueryException {
         return new XPathQueryBuilder(statement, resolver, factory).getRootNode();
@@ -325,12 +334,12 @@
      * Creates a String representation of the query node tree in XPath syntax.
      *
      * @param root     the root of the query node tree.
-     * @param resolver to resolve QNames.
+     * @param resolver to resolve <code>Name</code>s.
      * @return a String representation of the query node tree.
      * @throws InvalidQueryException if the query node tree cannot be converted
      *                               into a String representation due to restrictions in XPath.
      */
-    public static String toString(QueryRootNode root, NamespaceResolver resolver)
+    public static String toString(QueryRootNode root, NameResolver resolver)
             throws InvalidQueryException {
         return QueryFormat.toString(root, resolver);
     }
@@ -411,7 +420,7 @@
                                 null, RelationQueryNode.OPERATION_NOT_NULL);
                         node.childrenAccept(this, tmp);
                         if (tmpRelPath == null) {
-                            tmpRelPath = new Path.PathBuilder();
+                            tmpRelPath = new PathBuilder();
                         }
                         tmpRelPath.addLast(tmp.getRelativePath().getNameElement());
                     }
@@ -450,11 +459,13 @@
                     LocationStepQueryNode loc = (LocationStepQueryNode) queryNode;
                     String ntName = ((SimpleNode) node.jjtGetChild(0)).getValue();
                     try {
-                        QName nt = NameFormat.parse(ntName, resolver);
+                        Name nt = resolver.getQName(ntName);
                         NodeTypeQueryNode nodeType = factory.createNodeTypeQueryNode(loc, nt);
                         loc.addPredicate(nodeType);
                     } catch (NameException e) {
                         exceptions.add(new InvalidQueryException("Not a valid name: " + ntName));
+                    } catch (NamespaceException e) {
+                        exceptions.add(new InvalidQueryException("Not a valid name: " + ntName));
                     }
                 }
                 break;
@@ -554,7 +565,7 @@
             try {
                 Path relPath = tmpRelPath.getPath();
                 for (int i = 0; i < relPath.getLength(); i++) {
-                    node.addPathElement(relPath.getElement(i));
+                    node.addPathElement(relPath.getElements()[i]);
                 }
             } catch (MalformedPathException e) {
                 // should never happen
@@ -594,7 +605,7 @@
     }
 
     /**
-     * Assigns a QName to one of the follwing QueryNodes:
+     * Assigns a Name to one of the follwing QueryNodes:
      * {@link RelationQueryNode}, {@link DerefQueryNode}, {@link RelationQueryNode},
      * {@link PathQueryNode}, {@link OrderQueryNode}, {@link TextsearchQueryNode}.
      *
@@ -606,7 +617,7 @@
             SimpleNode child = (SimpleNode) node.jjtGetChild(0);
             if (child.getId() == JJTQNAME || child.getId() == JJTQNAMEFORITEMTYPE) {
                 try {
-                    QName name = ISO9075.decode(NameFormat.parse(child.getValue(), resolver));
+                    Name name = decode(resolver.getQName(child.getValue()));
                     if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
                         if (name.equals(JCR_ROOT)) {
                             name = LocationStepQueryNode.EMPTY_NAME;
@@ -615,7 +626,7 @@
                     } else if (queryNode.getType() == QueryNode.TYPE_DEREF) {
                         ((DerefQueryNode) queryNode).setRefProperty(name);
                     } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
-                        Path.PathElement element = Path.PathElement.create(name);
+                        Path.Element element = PATH_FACTORY.createElement(name);
                         ((RelationQueryNode) queryNode).addPathElement(element);
                     } else if (queryNode.getType() == QueryNode.TYPE_PATH) {
                         root.addSelectProperty(name);
@@ -623,12 +634,12 @@
                         root.getOrderNode().addOrderSpec(name, true);
                     } else if (queryNode.getType() == QueryNode.TYPE_TEXTSEARCH) {
                         TextsearchQueryNode ts = (TextsearchQueryNode) queryNode;
-                        ts.addPathElement(Path.PathElement.create(name));
+                        ts.addPathElement(PATH_FACTORY.createElement(name));
                         if (isAttributeNameTest(node)) {
                             ts.setReferencesProperty(true);
                         }
                     }
-                } catch (NameException e) {
+                } catch (RepositoryException e) {
                     exceptions.add(new InvalidQueryException("Illegal name: " + child.getValue()));
                 }
             } else if (child.getId() == JJTSTAR) {
@@ -636,10 +647,10 @@
                     ((LocationStepQueryNode) queryNode).setNameTest(null);
                 } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     ((RelationQueryNode) queryNode).addPathElement(
-                            Path.PathElement.create(RelationQueryNode.STAR_NAME_TEST));
+                            PATH_FACTORY.createElement(RelationQueryNode.STAR_NAME_TEST));
                 } else if (queryNode.getType() == QueryNode.TYPE_TEXTSEARCH) {
                     ((TextsearchQueryNode) queryNode).addPathElement(
-                            Path.PathElement.create(RelationQueryNode.STAR_NAME_TEST));
+                            PATH_FACTORY.createElement(RelationQueryNode.STAR_NAME_TEST));
                 }
             } else {
                 exceptions.add(new InvalidQueryException("Unsupported location for name test: " + child));
@@ -762,8 +773,8 @@
         String fName = ((SimpleNode) node.jjtGetChild(0)).getValue();
         fName = fName.substring(0, fName.length() - 1);
         try {
-            if (NameFormat.format(FN_NOT, resolver).equals(fName)
-                    || NameFormat.format(FN_NOT_10, resolver).equals(fName)) {
+            if (resolver.getJCRName(FN_NOT).equals(fName)
+                    || resolver.getJCRName(FN_NOT_10).equals(fName)) {
                 if (queryNode instanceof NAryQueryNode) {
                     QueryNode not = factory.createNotQueryNode(queryNode);
                     ((NAryQueryNode) queryNode).addOperand(not);
@@ -778,7 +789,7 @@
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for function fn:not"));
                 }
-            } else if (NameFormat.format(XS_DATETIME, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(XS_DATETIME).equals(fName)) {
                 // check arguments
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode instanceof RelationQueryNode) {
@@ -804,7 +815,7 @@
                     // wrong number of arguments
                     exceptions.add(new InvalidQueryException("Wrong number of arguments for xs:dateTime"));
                 }
-            } else if (NameFormat.format(JCR_CONTAINS, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(JCR_CONTAINS).equals(fName)) {
                 // check number of arguments
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
@@ -824,7 +835,7 @@
                     // wrong number of arguments
                     exceptions.add(new InvalidQueryException("Wrong number of arguments for jcr:contains"));
                 }
-            } else if (NameFormat.format(JCR_LIKE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(JCR_LIKE).equals(fName)) {
                 // check number of arguments
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
@@ -852,35 +863,35 @@
                     // wrong number of arguments
                     exceptions.add(new InvalidQueryException("Wrong number of arguments for jcr:like"));
                 }
-            } else if (NameFormat.format(FN_TRUE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_TRUE).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     RelationQueryNode rel = (RelationQueryNode) queryNode;
                     rel.setStringValue("true");
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for true()"));
                 }
-            } else if (NameFormat.format(FN_FALSE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_FALSE).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     RelationQueryNode rel = (RelationQueryNode) queryNode;
                     rel.setStringValue("false");
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for false()"));
                 }
-            } else if (NameFormat.format(FN_POSITION, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_POSITION).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     RelationQueryNode rel = (RelationQueryNode) queryNode;
                     if (rel.getOperation() == RelationQueryNode.OPERATION_EQ_GENERAL) {
                         // set dummy value to set type of relation query node
                         // will be overwritten when the tree is furhter parsed.
                         rel.setPositionValue(1);
-                        rel.addPathElement(Path.PathElement.create(FN_POSITION_FULL));
+                        rel.addPathElement(PATH_FACTORY.createElement(FN_POSITION_FULL));
                     } else {
                         exceptions.add(new InvalidQueryException("Unsupported expression with position(). Only = is supported."));
                     }
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for position()"));
                 }
-            } else if (NameFormat.format(FN_FIRST, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_FIRST).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     ((RelationQueryNode) queryNode).setPositionValue(1);
                 } else if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
@@ -888,7 +899,7 @@
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for first()"));
                 }
-            } else if (NameFormat.format(FN_LAST, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_LAST).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                     ((RelationQueryNode) queryNode).setPositionValue(LocationStepQueryNode.LAST);
                 } else if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
@@ -896,7 +907,7 @@
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for last()"));
                 }
-            } else if (NameFormat.format(JCR_DEREF, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(JCR_DEREF).equals(fName)) {
                 // check number of arguments
                 if (node.jjtGetNumChildren() == 3) {
                     boolean descendant = false;
@@ -924,9 +935,9 @@
                             // strip quotes
                             value = value.substring(1, value.length() - 1);
                             if (!value.equals("*")) {
-                                QName name = null;
+                                Name name = null;
                                 try {
-                                    name = ISO9075.decode(NameFormat.parse(value, resolver));
+                                    name = decode(resolver.getQName(value));
                                 } catch (NameException e) {
                                     exceptions.add(new InvalidQueryException("Illegal name: " + value));
                                 }
@@ -954,13 +965,13 @@
                         exceptions.add(new InvalidQueryException("Unsupported location for jcr:deref()"));
                     }
                 }
-            } else if (NameFormat.format(JCR_SCORE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(JCR_SCORE).equals(fName)) {
                 if (queryNode.getType() == QueryNode.TYPE_ORDER) {
                     createOrderSpec(node, (OrderQueryNode) queryNode);
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for jcr:score()"));
                 }
-            } else if (NameFormat.format(FN_LOWER_CASE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_LOWER_CASE).equals(fName)) {
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                         RelationQueryNode relNode = (RelationQueryNode) queryNode;
@@ -974,7 +985,7 @@
                 } else {
                     exceptions.add(new InvalidQueryException("Wrong number of argument for fn:lower-case()"));
                 }
-            } else if (NameFormat.format(FN_UPPER_CASE, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(FN_UPPER_CASE).equals(fName)) {
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                         RelationQueryNode relNode = (RelationQueryNode) queryNode;
@@ -988,7 +999,7 @@
                 } else {
                     exceptions.add(new InvalidQueryException("Unsupported location for fn:upper-case()"));
                 }
-            } else if (NameFormat.format(REP_SIMILAR, resolver).equals(fName)) {
+            } else if (resolver.getJCRName(REP_SIMILAR).equals(fName)) {
                 if (node.jjtGetNumChildren() == 3) {
                     if (queryNode instanceof NAryQueryNode) {
                         NAryQueryNode parent = (NAryQueryNode) queryNode;
@@ -1013,7 +1024,7 @@
                     exceptions.add(new InvalidQueryException(
                             "Wrong number of arguments for rep:similar()"));
                 }
-            } else if (NameFormat.format(REP_SPELLCHECK, resolver).equals(fName)
+            } else if (resolver.getJCRName(REP_SPELLCHECK).equals(fName)
                     && queryNode.getType() != QueryNode.TYPE_PATH) {
                 if (node.jjtGetNumChildren() == 2) {
                     if (queryNode instanceof NAryQueryNode) {
@@ -1031,7 +1042,7 @@
                         }
 
                         // set a dummy property name
-                        rel.addPathElement(Path.PathElement.create(QName.JCR_PRIMARYTYPE));
+                        rel.addPathElement(PATH_FACTORY.createElement(NameConstants.JCR_PRIMARYTYPE));
                     } else {
                         exceptions.add(new InvalidQueryException(
                                 "Unsupported location for rep:spellcheck()"));
@@ -1043,8 +1054,8 @@
             } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                 // use function name as name of a pseudo property in a relation
                 try {
-                    QName name = NameFormat.parse(fName + "()", resolver);
-                    Path.PathElement element = Path.PathElement.create(name);
+                    Name name = resolver.getQName(fName + "()");
+                    Path.Element element = PATH_FACTORY.createElement(name);
                     RelationQueryNode relNode = (RelationQueryNode) queryNode;
                     relNode.addPathElement(element);
                 } catch (NameException e) {
@@ -1053,7 +1064,7 @@
             } else if (queryNode.getType() == QueryNode.TYPE_PATH) {
                 // use function name as name of a pseudo property in select clause
                 try {
-                    QName name = NameFormat.parse(fName + "()", resolver);
+                    Name name = resolver.getQName(fName + "()");
                     root.addSelectProperty(name);
                 } catch (NameException e) {
                     exceptions.add(e);
@@ -1061,7 +1072,7 @@
             } else {
                 exceptions.add(new InvalidQueryException("Unsupported function: " + fName));
             }
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             exceptions.add(e);
         }
         return queryNode;
@@ -1078,11 +1089,13 @@
                 // cut off left parenthesis at end
                 propName = propName.substring(0, propName.length() - 1);
             }
-            QName name = ISO9075.decode(NameFormat.parse(propName, resolver));
+            Name name = decode(resolver.getQName(propName));
             spec = new OrderQueryNode.OrderSpec(name, true);
             queryNode.addOrderSpec(spec);
         } catch (NameException e) {
             exceptions.add(new InvalidQueryException("Illegal name: " + child.getValue()));
+        } catch (NamespaceException e) {
+            exceptions.add(new InvalidQueryException("Illegal name: " + child.getValue()));
         }
         return spec;
     }
@@ -1112,7 +1125,7 @@
      *     At @
      *     NodeTest
      *         NameTest
-     *             QName foo
+     *             Name foo
      * </pre>
      * @param node a node with type {@link #JJTNAMETEST}.
      * @return <code>true</code> if the name test <code>node</code> is on the
@@ -1152,5 +1165,14 @@
             value = value.replaceAll("''", "'");
         }
         return value;
+    }
+
+    private static Name decode(Name name) {
+        String decodedLN = ISO9075.decode(name.getLocalName());
+        if (decodedLN.equals(name.getLocalName())) {
+            return name;
+        } else {
+            return NAME_FACTORY.create(name.getNamespaceURI(), decodedLN);
+        }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AMContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AMContext.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AMContext.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AMContext.java Tue Oct 30 03:02:41 2007
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.fs.FileSystem;
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
 
 import javax.security.auth.Subject;
 import java.io.File;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java Tue Oct 30 03:02:41 2007
@@ -20,7 +20,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.ReferentialIntegrityException;
 
@@ -227,7 +227,7 @@
     /**
      * {@inheritDoc}
      */
-    public NodeState createNew(NodeId id, QName nodeTypeName,
+    public NodeState createNew(NodeId id, Name nodeTypeName,
                                NodeId parentId)
             throws IllegalStateException {
         if (!editMode) {
@@ -244,7 +244,7 @@
     /**
      * {@inheritDoc}
      */
-    public PropertyState createNew(QName propName, NodeId parentId)
+    public PropertyState createNew(Name propName, NodeId parentId)
             throws IllegalStateException {
         if (!editMode) {
             throw new IllegalStateException("Not in edit mode");
@@ -488,7 +488,7 @@
      * Optimization: shared state manager we're listening to does not deliver node state changes, therefore the state
      * concerned must be a local state.
      */
-    public void nodeAdded(NodeState state, QName name, int index, NodeId id) {
+    public void nodeAdded(NodeState state, Name name, int index, NodeId id) {
         dispatcher.notifyNodeAdded(state, name, index, id);
     }
 
@@ -518,7 +518,7 @@
      * Optimization: shared state manager we're listening to does not deliver node state changes, therefore the state
      * concerned must be a local state.
      */
-    public void nodeRemoved(NodeState state, QName name, int index, NodeId id) {
+    public void nodeRemoved(NodeState state, Name name, int index, NodeId id) {
         dispatcher.notifyNodeRemoved(state, name, index, id);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java Tue Oct 30 03:02:41 2007
@@ -22,7 +22,8 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameFactoryImpl;
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -51,7 +52,7 @@
     /**
      * the name of this node's primary type
      */
-    private QName nodeTypeName;
+    private Name nodeTypeName;
 
     /**
      * the names of this node's mixin types
@@ -86,7 +87,7 @@
     private boolean sharedChildNodeEntries = false;
 
     /**
-     * set of property names (QName objects)
+     * set of property names (Name objects)
      */
     private HashSet propertyNames = new HashSet();
 
@@ -124,7 +125,7 @@
      * @param initialStatus the initial status of the node state object
      * @param isTransient   flag indicating whether this state is transient or not
      */
-    public NodeState(NodeId id, QName nodeTypeName, NodeId parentId,
+    public NodeState(NodeId id, Name nodeTypeName, NodeId parentId,
                      int initialStatus, boolean isTransient) {
         super(initialStatus, isTransient);
         this.id = id;
@@ -202,7 +203,7 @@
      *
      * @return the name of this node's node type.
      */
-    public QName getNodeTypeName() {
+    public Name getNodeTypeName() {
         return nodeTypeName;
     }
 
@@ -260,11 +261,11 @@
      * Determines if there is a <code>ChildNodeEntry</code> with the
      * specified <code>name</code>.
      *
-     * @param name <code>QName</code> object specifying a node name
+     * @param name <code>Name</code> object specifying a node name
      * @return <code>true</code> if there is a <code>ChildNodeEntry</code> with
      *         the specified <code>name</code>.
      */
-    public synchronized boolean hasChildNodeEntry(QName name) {
+    public synchronized boolean hasChildNodeEntry(Name name) {
         return !childNodeEntries.get(name).isEmpty();
     }
 
@@ -284,24 +285,24 @@
      * Determines if there is a <code>ChildNodeEntry</code> with the
      * specified <code>name</code> and <code>index</code>.
      *
-     * @param name  <code>QName</code> object specifying a node name
+     * @param name  <code>Name</code> object specifying a node name
      * @param index 1-based index if there are same-name child node entries
      * @return <code>true</code> if there is a <code>ChildNodeEntry</code> with
      *         the specified <code>name</code> and <code>index</code>.
      */
-    public synchronized boolean hasChildNodeEntry(QName name, int index) {
+    public synchronized boolean hasChildNodeEntry(Name name, int index) {
         return childNodeEntries.get(name, index) != null;
     }
 
     /**
      * Determines if there is a property entry with the specified
-     * <code>QName</code>.
+     * <code>Name</code>.
      *
-     * @param propName <code>QName</code> object specifying a property name
+     * @param propName <code>Name</code> object specifying a property name
      * @return <code>true</code> if there is a property entry with the specified
-     *         <code>QName</code>.
+     *         <code>Name</code>.
      */
-    public synchronized boolean hasPropertyName(QName propName) {
+    public synchronized boolean hasPropertyName(Name propName) {
         return propertyNames.contains(propName);
     }
 
@@ -309,12 +310,12 @@
      * Returns the <code>ChildNodeEntry</code> with the specified name and index
      * or <code>null</code> if there's no matching entry.
      *
-     * @param nodeName <code>QName</code> object specifying a node name
+     * @param nodeName <code>Name</code> object specifying a node name
      * @param index    1-based index if there are same-name child node entries
      * @return the <code>ChildNodeEntry</code> with the specified name and index
      *         or <code>null</code> if there's no matching entry.
      */
-    public synchronized ChildNodeEntry getChildNodeEntry(QName nodeName, int index) {
+    public synchronized ChildNodeEntry getChildNodeEntry(Name nodeName, int index) {
         return childNodeEntries.get(nodeName, index);
     }
 
@@ -352,18 +353,18 @@
      * @see #addChildNodeEntry
      * @see #removeChildNodeEntry
      */
-    public synchronized List getChildNodeEntries(QName nodeName) {
+    public synchronized List getChildNodeEntries(Name nodeName) {
         return childNodeEntries.get(nodeName);
     }
 
     /**
      * Adds a new <code>ChildNodeEntry</code>.
      *
-     * @param nodeName <code>QName</code> object specifying the name of the new entry.
+     * @param nodeName <code>Name</code> object specifying the name of the new entry.
      * @param id the id the new entry is refering to.
      * @return the newly added <code>ChildNodeEntry</code>
      */
-    public synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
+    public synchronized ChildNodeEntry addChildNodeEntry(Name nodeName,
                                                          NodeId id) {
         if (sharedChildNodeEntries) {
             childNodeEntries = (ChildNodeEntries) childNodeEntries.clone();
@@ -377,14 +378,14 @@
     /**
      * Renames a new <code>ChildNodeEntry</code>.
      *
-     * @param oldName <code>QName</code> object specifying the entry's old name
+     * @param oldName <code>Name</code> object specifying the entry's old name
      * @param index   1-based index if there are same-name child node entries
-     * @param newName <code>QName</code> object specifying the entry's new name
+     * @param newName <code>Name</code> object specifying the entry's new name
      * @return <code>true</code> if the entry was sucessfully renamed;
      *         otherwise <code>false</code>
      */
-    public synchronized boolean renameChildNodeEntry(QName oldName, int index,
-                                                     QName newName) {
+    public synchronized boolean renameChildNodeEntry(Name oldName, int index,
+                                                     Name newName) {
         if (sharedChildNodeEntries) {
             childNodeEntries = (ChildNodeEntries) childNodeEntries.clone();
             sharedChildNodeEntries = false;
@@ -408,7 +409,7 @@
      * @return <code>true</code> if the specified child node entry was found
      *         in the list of child node entries and could be removed.
      */
-    public synchronized boolean removeChildNodeEntry(QName nodeName, int index) {
+    public synchronized boolean removeChildNodeEntry(Name nodeName, int index) {
         if (sharedChildNodeEntries) {
             childNodeEntries = (ChildNodeEntries) childNodeEntries.clone();
             sharedChildNodeEntries = false;
@@ -488,9 +489,9 @@
     /**
      * Adds a property name entry.
      *
-     * @param propName <code>QName</code> object specifying the property name
+     * @param propName <code>Name</code> object specifying the property name
      */
-    public synchronized void addPropertyName(QName propName) {
+    public synchronized void addPropertyName(Name propName) {
         if (sharedPropertyNames) {
             propertyNames = (HashSet) propertyNames.clone();
             sharedPropertyNames = false;
@@ -501,11 +502,11 @@
     /**
      * Removes a property name entry.
      *
-     * @param propName <code>QName</code> object specifying the property name
+     * @param propName <code>Name</code> object specifying the property name
      * @return <code>true</code> if the specified property name was found
      *         in the list of property name entries and could be removed.
      */
-    public synchronized boolean removePropertyName(QName propName) {
+    public synchronized boolean removePropertyName(Name propName) {
         if (sharedPropertyNames) {
             propertyNames = (HashSet) propertyNames.clone();
             sharedPropertyNames = false;
@@ -526,7 +527,7 @@
     }
 
     /**
-     * Sets the set of <code>QName</code> objects denoting the
+     * Sets the set of <code>Name</code> objects denoting the
      * properties of this node.
      */
     public synchronized void setPropertyNames(Set propNames) {
@@ -551,17 +552,17 @@
      *
      * @param nodeTypeName node type name
      */
-    public synchronized void setNodeTypeName(QName nodeTypeName) {
+    public synchronized void setNodeTypeName(Name nodeTypeName) {
         this.nodeTypeName = nodeTypeName;
     }
 
     //---------------------------------------------------------< diff methods >
     /**
-     * Returns a set of <code>QName</code>s denoting those properties that
+     * Returns a set of <code>Name</code>s denoting those properties that
      * do not exist in the overlayed node state but have been added to
      * <i>this</i> node state.
      *
-     * @return set of <code>QName</code>s denoting the properties that have
+     * @return set of <code>Name</code>s denoting the properties that have
      *         been added.
      */
     public synchronized Set getAddedPropertyNames() {
@@ -591,11 +592,11 @@
     }
 
     /**
-     * Returns a set of <code>QName</code>s denoting those properties that
+     * Returns a set of <code>Name</code>s denoting those properties that
      * exist in the overlayed node state but have been removed from
      * <i>this</i> node state.
      *
-     * @return set of <code>QName</code>s denoting the properties that have
+     * @return set of <code>Name</code>s denoting the properties that have
      *         been removed.
      */
     public synchronized Set getRemovedPropertyNames() {
@@ -792,7 +793,7 @@
      */
     public long calculateMemoryFootprint() {
         /*
-        private QName nodeTypeName;
+        private Name nodeTypeName;
         private Set mixinTypeNames = Collections.EMPTY_SET;
         private NodeId id;
         private NodeId parentId;
@@ -802,9 +803,9 @@
         private HashSet propertyNames = new HashSet();
         private boolean sharedPropertyNames = false;
 
-        we assume an average QName localname of 30 chars.
+        we assume an average Name localname of 30 chars.
         NodeId = 8 + UUID(24) + hashcode(4) = 36
-        QName = 8 + hash(4) + string(38+2*len) + namespace(4) + localName(38+2*len) ~ 250
+        Name = 8 + hash(4) + string(38+2*len) + namespace(4) + localName(38+2*len) ~ 250
         NodeDefId = 8 + id(4) = 12
         ChildNodeEntries = 8 + n * (name(256) + index(4) + id(36) + hashentry(16)) ~ n*300
         PropNames = 8 + n * ( name(250))
@@ -878,7 +879,7 @@
             return (ChildNodeEntry) entries.get(id);
         }
 
-        List get(QName nodeName) {
+        List get(Name nodeName) {
             Object obj = nameMap.get(nodeName);
             if (obj == null) {
                 return Collections.EMPTY_LIST;
@@ -892,7 +893,7 @@
             }
         }
 
-        ChildNodeEntry get(QName nodeName, int index) {
+        ChildNodeEntry get(Name nodeName, int index) {
             if (index < 1) {
                 throw new IllegalArgumentException("index is 1-based");
             }
@@ -916,7 +917,7 @@
             return null;
         }
 
-        ChildNodeEntry add(QName nodeName, NodeId id) {
+        ChildNodeEntry add(Name nodeName, NodeId id) {
             List siblings = null;
             int index = 0;
             Object obj = nameMap.get(nodeName);
@@ -951,12 +952,12 @@
             Iterator iter = entriesList.iterator();
             while (iter.hasNext()) {
                 ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-                // delegate to add(QName, String) to maintain consistency
+                // delegate to add(Name, String) to maintain consistency
                 add(entry.getName(), entry.getId());
             }
         }
 
-        public ChildNodeEntry remove(QName nodeName, int index) {
+        public ChildNodeEntry remove(Name nodeName, int index) {
             if (index < 1) {
                 throw new IllegalArgumentException("index is 1-based");
             }
@@ -1271,7 +1272,7 @@
             // written in writeObject(ObjectOutputStream)
             short count = in.readShort();   // count
             for (int i = 0; i < count; i++) {
-                QName name = QName.valueOf(in.readUTF());    // name
+                Name name = NameFactoryImpl.getInstance().create(in.readUTF());    // name
                 String s = in.readUTF();   // id
                 add(name, NodeId.valueOf(s));
             }
@@ -1359,11 +1360,11 @@
 
         private int hash = 0;
 
-        private final QName name;
+        private final Name name;
         private final int index; // 1-based index for same-name siblings
         private final NodeId id;
 
-        private ChildNodeEntry(QName name, NodeId id, int index) {
+        private ChildNodeEntry(Name name, NodeId id, int index) {
             if (name == null) {
                 throw new IllegalArgumentException("name can not be null");
             }
@@ -1384,7 +1385,7 @@
             return id;
         }
 
-        public QName getName() {
+        public Name getName() {
             return name;
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateListener.java Tue Oct 30 03:02:41 2007
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.core.state;
 
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.core.NodeId;
 
 /**
@@ -34,7 +34,7 @@
      * @param id    id of new node
      */
     void nodeAdded(NodeState state,
-                   QName name, int index, NodeId id);
+                   Name name, int index, NodeId id);
 
     /**
      * Called when a node has been modified, typically as a result of removal
@@ -63,5 +63,5 @@
      * @param index index of removed node
      * @param id    id of removed node
      */
-    void nodeRemoved(NodeState state, QName name, int index, NodeId id);
+    void nodeRemoved(NodeState state, Name name, int index, NodeId id);
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java Tue Oct 30 03:02:41 2007
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -157,7 +157,7 @@
 
             for (Iterator iter = state.getAddedPropertyNames().iterator();
                  iter.hasNext();) {
-                QName name = (QName) iter.next();
+                Name name = (Name) iter.next();
                 PropertyId propId =
                         new PropertyId(state.getNodeId(), name);
                 if (context.isAdded(propId)) {
@@ -174,7 +174,7 @@
             }
             for (Iterator iter = state.getRemovedPropertyNames().iterator();
                  iter.hasNext();) {
-                QName name = (QName) iter.next();
+                Name name = (Name) iter.next();
                 PropertyId propId =
                         new PropertyId(state.getNodeId(), name);
                 if (context.isDeleted(propId)) {
@@ -187,11 +187,11 @@
             // re-apply changes made on this state
             state.setPropertyNames(overlayedState.getPropertyNames());
             for (Iterator iter = added.iterator(); iter.hasNext();) {
-                QName name = (QName) iter.next();
+                Name name = (Name) iter.next();
                 state.addPropertyName(name);
             }
             for (Iterator iter = removed.iterator(); iter.hasNext();) {
-                QName name = (QName) iter.next();
+                Name name = (Name) iter.next();
                 state.removePropertyName(name);
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java Tue Oct 30 03:02:41 2007
@@ -22,7 +22,7 @@
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -148,7 +148,7 @@
      *
      * @return the name of this property.
      */
-    public QName getName() {
+    public Name getName() {
         return id.getName();
     }
 
@@ -237,7 +237,7 @@
         private boolean multiValued;
         private PropDefId defId;
 
-        we assume an average QName localname of 30 chars.
+        we assume an average Name localname of 30 chars.
         PropertyId = 8 + nodeId(36) * name(250) + hash(4) ~ 300;
         NodeDefId = 8 + id(4) = 12
         InternalValue = 8 + n * (values) ~ 8 + n*100;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Tue Oct 30 03:02:41 2007
@@ -24,8 +24,8 @@
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.ZombieHierarchyManager;
 import org.apache.jackrabbit.core.util.Dumpable;
-import org.apache.jackrabbit.name.PathResolver;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.conversion.PathResolver;
+import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -234,14 +234,14 @@
     /**
      * {@inheritDoc}
      */
-    public NodeState createNew(NodeId id, QName nodeTypeName,
+    public NodeState createNew(NodeId id, Name nodeTypeName,
                                NodeId parentId)
             throws IllegalStateException {
         return stateMgr.createNew(id, nodeTypeName, parentId);
     }
 
     /**
-     * Customized variant of {@link #createNew(NodeId, QName, NodeId)} that
+     * Customized variant of {@link #createNew(NodeId, Name, NodeId)} that
      * connects the newly created persistent state with the transient state.
      */
     public NodeState createNew(NodeState transientState)
@@ -257,13 +257,13 @@
     /**
      * {@inheritDoc}
      */
-    public PropertyState createNew(QName propName, NodeId parentId)
+    public PropertyState createNew(Name propName, NodeId parentId)
             throws IllegalStateException {
         return stateMgr.createNew(propName, parentId);
     }
 
     /**
-     * Customized variant of {@link #createNew(QName, NodeId)} that
+     * Customized variant of {@link #createNew(Name, NodeId)} that
      * connects the newly created persistent state with the transient state.
      */
     public PropertyState createNew(PropertyState transientState)
@@ -553,7 +553,7 @@
      * @return
      * @throws ItemStateException
      */
-    public NodeState createTransientNodeState(NodeId id, QName nodeTypeName, NodeId parentId, int initialStatus)
+    public NodeState createTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus)
             throws ItemStateException {
 
         // check map; synchronized to ensure an entry is not created twice.
@@ -607,7 +607,7 @@
      * @return
      * @throws ItemStateException
      */
-    public PropertyState createTransientPropertyState(NodeId parentId, QName propName, int initialStatus)
+    public PropertyState createTransientPropertyState(NodeId parentId, Name propName, int initialStatus)
             throws ItemStateException {
 
         PropertyId id = new PropertyId(parentId, propName);
@@ -875,7 +875,7 @@
      * Pass notification to listeners if a transient state was modified
      * or if the local state is not overlayed.
      */
-    public void nodeAdded(NodeState state, QName name, int index, NodeId id) {
+    public void nodeAdded(NodeState state, Name name, int index, NodeId id) {
         if (state.getContainer() == this || !transientStore.contains(state.getId())) {
             dispatcher.notifyNodeAdded(state, name, index, id);
         }
@@ -911,7 +911,7 @@
      * Pass notification to listeners if a transient state was modified
      * or if the local state is not overlayed.
      */
-    public void nodeRemoved(NodeState state, QName name, int index, NodeId id) {
+    public void nodeRemoved(NodeState state, Name name, int index, NodeId id) {
         if (state.getContainer() == this || !transientStore.contains(state.getId())) {
             dispatcher.notifyNodeRemoved(state, name, index, id);
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Tue Oct 30 03:02:41 2007
@@ -34,7 +34,8 @@
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -976,7 +977,7 @@
      * @param parentId   parent UUID
      * @return new node state instance
      */
-    private NodeState createInstance(NodeId id, QName nodeTypeName,
+    private NodeState createInstance(NodeId id, Name nodeTypeName,
                                      NodeId parentId) {
 
         NodeState state = persistMgr.createNew(id);
@@ -1000,8 +1001,8 @@
                                           NodeTypeRegistry ntReg)
             throws ItemStateException {
 
-        NodeState rootState = createInstance(rootNodeId, QName.REP_ROOT, null);
-        NodeState jcrSystemState = createInstance(RepositoryImpl.SYSTEM_ROOT_NODE_ID, QName.REP_SYSTEM, rootNodeId);
+        NodeState rootState = createInstance(rootNodeId, NameConstants.REP_ROOT, null);
+        NodeState jcrSystemState = createInstance(RepositoryImpl.SYSTEM_ROOT_NODE_ID, NameConstants.REP_SYSTEM, rootNodeId);
 
         // FIXME need to manually setup root node by creating mandatory jcr:primaryType property
         // @todo delegate setup of root node to NodeTypeInstanceHandler
@@ -1014,10 +1015,10 @@
         NodeDefId jcrSystemDefId;
         try {
             nodeDefId = ntReg.getRootNodeDef().getId();
-            EffectiveNodeType ent = ntReg.getEffectiveNodeType(QName.REP_ROOT);
-            propDef = ent.getApplicablePropertyDef(QName.JCR_PRIMARYTYPE,
+            EffectiveNodeType ent = ntReg.getEffectiveNodeType(NameConstants.REP_ROOT);
+            propDef = ent.getApplicablePropertyDef(NameConstants.JCR_PRIMARYTYPE,
                     PropertyType.NAME, false);
-            jcrSystemDefId = ent.getApplicableChildNodeDef(QName.JCR_SYSTEM, QName.REP_SYSTEM, ntReg).getId();
+            jcrSystemDefId = ent.getApplicableChildNodeDef(NameConstants.JCR_SYSTEM, NameConstants.REP_SYSTEM, ntReg).getId();
         } catch (NoSuchNodeTypeException nsnte) {
             String msg = "internal error: failed to create root node";
             log.error(msg, nsnte);
@@ -1034,7 +1035,7 @@
         rootState.addPropertyName(propDef.getName());
 
         PropertyState prop = createInstance(propDef.getName(), rootNodeId);
-        prop.setValues(new InternalValue[]{InternalValue.create(QName.REP_ROOT)});
+        prop.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ROOT)});
         prop.setType(propDef.getRequiredType());
         prop.setMultiValued(propDef.isMultiple());
         prop.setDefinitionId(propDef.getId());
@@ -1043,19 +1044,19 @@
         jcrSystemState.addPropertyName(propDef.getName());
 
         PropertyState primaryTypeProp = createInstance(propDef.getName(), jcrSystemState.getNodeId());
-        primaryTypeProp.setValues(new InternalValue[]{InternalValue.create(QName.REP_SYSTEM)});
+        primaryTypeProp.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_SYSTEM)});
         primaryTypeProp.setType(propDef.getRequiredType());
         primaryTypeProp.setMultiValued(propDef.isMultiple());
         primaryTypeProp.setDefinitionId(propDef.getId());
 
         // add child node entry for jcr:system node
-        rootState.addChildNodeEntry(QName.JCR_SYSTEM, RepositoryImpl.SYSTEM_ROOT_NODE_ID);
+        rootState.addChildNodeEntry(NameConstants.JCR_SYSTEM, RepositoryImpl.SYSTEM_ROOT_NODE_ID);
 
         // add child node entry for virtual jcr:versionStorage
-        jcrSystemState.addChildNodeEntry(QName.JCR_VERSIONSTORAGE, RepositoryImpl.VERSION_STORAGE_NODE_ID);
+        jcrSystemState.addChildNodeEntry(NameConstants.JCR_VERSIONSTORAGE, RepositoryImpl.VERSION_STORAGE_NODE_ID);
 
         // add child node entry for virtual jcr:nodeTypes
-        jcrSystemState.addChildNodeEntry(QName.JCR_NODETYPES, RepositoryImpl.NODETYPES_NODE_ID);
+        jcrSystemState.addChildNodeEntry(NameConstants.JCR_NODETYPES, RepositoryImpl.NODETYPES_NODE_ID);
 
 
         ChangeLog changeLog = new ChangeLog();
@@ -1136,7 +1137,7 @@
      * @param parentId parent Id
      * @return new property state instance
      */
-    private PropertyState createInstance(QName propName, NodeId parentId) {
+    private PropertyState createInstance(Name propName, NodeId parentId) {
         PropertyState state = persistMgr.createNew(new PropertyId(parentId, propName));
         state.setStatus(ItemState.STATUS_NEW);
         state.setContainer(this);
@@ -1173,20 +1174,20 @@
      */
     private boolean isReferenceable(NodeState state) throws ItemStateException {
         // shortcut: check some wellknown built-in types first
-        QName primary = state.getNodeTypeName();
+        Name primary = state.getNodeTypeName();
         Set mixins = state.getMixinTypeNames();
-        if (mixins.contains(QName.MIX_REFERENCEABLE)
-                || mixins.contains(QName.MIX_VERSIONABLE)
-                || primary.equals(QName.NT_RESOURCE)) {
+        if (mixins.contains(NameConstants.MIX_REFERENCEABLE)
+                || mixins.contains(NameConstants.MIX_VERSIONABLE)
+                || primary.equals(NameConstants.NT_RESOURCE)) {
             return true;
         }
         // build effective node type
-        QName[] types = new QName[mixins.size() + 1];
+        Name[] types = new Name[mixins.size() + 1];
         mixins.toArray(types);
         // primary type
         types[types.length - 1] = primary;
         try {
-            return ntReg.getEffectiveNodeType(types).includesNodeType(QName.MIX_REFERENCEABLE);
+            return ntReg.getEffectiveNodeType(types).includesNodeType(NameConstants.MIX_REFERENCEABLE);
         } catch (NodeTypeConflictException ntce) {
             String msg = "internal error: failed to build effective node type for node "
                     + state.getNodeId();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java Tue Oct 30 03:02:41 2007
@@ -18,7 +18,7 @@
 
 import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList;
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 
 import java.util.Collection;
 import java.util.Iterator;
@@ -115,7 +115,7 @@
      * @param index index of new node
      * @param id    id of new node
      */
-    public void notifyNodeAdded(NodeState state, QName name, int index, NodeId id) {
+    public void notifyNodeAdded(NodeState state, Name name, int index, NodeId id) {
         Iterator iter = nsListeners.iterator();
         while (iter.hasNext()) {
             ((NodeStateListener) iter.next()).nodeAdded(state, name, index, id);
@@ -151,7 +151,7 @@
      * @param index index of new node
      * @param id    id of new node
      */
-    public void notifyNodeRemoved(NodeState state, QName name, int index, NodeId id) {
+    public void notifyNodeRemoved(NodeState state, Name name, int index, NodeId id) {
         Iterator iter = nsListeners.iterator();
         while (iter.hasNext()) {
             ((NodeStateListener) iter.next()).nodeRemoved(state, name, index, id);



Mime
View raw message