jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r590014 [6/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/lucene/AggregateRuleImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java Tue Oct 30 03:02:41 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.name.PathBuilder;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.MalformedPathException;
+import org.apache.jackrabbit.conversion.NameResolver;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -34,6 +34,7 @@
 import org.w3c.dom.CharacterData;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Arrays;
@@ -48,14 +49,14 @@
 class AggregateRuleImpl implements AggregateRule {
 
     /**
-     * A namespace resolver for parsing QNames in the configuration.
+     * A name resolver for parsing QNames in the configuration.
      */
-    private final NamespaceResolver nsResolver;
+    private final NameResolver resolver;
 
     /**
      * The node type of the root node of the indexing aggregate.
      */
-    private final QName nodeTypeName;
+    private final Name nodeTypeName;
 
     /**
      * The rules that define this indexing aggregate.
@@ -76,23 +77,22 @@
      * Creates a new indexing aggregate using the given <code>config</code>.
      *
      * @param config     the configuration for this indexing aggregate.
-     * @param nsResolver the namespace resolver for parsing QNames within the
-     *                   config.
+     * @param resolver   the name resolver for parsing Names within the config.
      * @param ism        the item state manager of the workspace.
      * @param hmgr       a hierarchy manager for the item state manager.
      * @throws MalformedPathException if a path in the configuration is
      *                                malformed.
      * @throws IllegalNameException   if a node type name contains illegal
      *                                characters.
-     * @throws UnknownPrefixException if a node type contains an unknown
+     * @throws NamespaceException if a node type contains an unknown
      *                                prefix.
      */
     AggregateRuleImpl(Node config,
-                      NamespaceResolver nsResolver,
+                      NameResolver resolver,
                       ItemStateManager ism,
                       HierarchyManager hmgr)
-            throws MalformedPathException, IllegalNameException, UnknownPrefixException {
-        this.nsResolver = nsResolver;
+            throws MalformedPathException, IllegalNameException, NamespaceException {
+        this.resolver = resolver;
         this.nodeTypeName = getNodeTypeName(config);
         this.rules = getRules(config);
         this.ism = ism;
@@ -155,13 +155,13 @@
      * @return the name of the node type.
      * @throws IllegalNameException   if the node type name contains illegal
      *                                characters.
-     * @throws UnknownPrefixException if the node type contains an unknown
+     * @throws NamespaceException if the node type contains an unknown
      *                                prefix.
      */
-    private QName getNodeTypeName(Node config)
-            throws IllegalNameException, UnknownPrefixException {
+    private Name getNodeTypeName(Node config)
+            throws IllegalNameException, NamespaceException {
         String ntString = config.getAttributes().getNamedItem("primaryType").getNodeValue();
-        return NameFormat.parse(ntString, nsResolver);
+        return resolver.getQName(ntString);
     }
 
     /**
@@ -173,28 +173,28 @@
      *                                malformed.
      * @throws IllegalNameException   if the node type name contains illegal
      *                                characters.
-     * @throws UnknownPrefixException if the node type contains an unknown
+     * @throws NamespaceException if the node type contains an unknown
      *                                prefix.
      */
     private Rule[] getRules(Node config)
-            throws MalformedPathException, IllegalNameException, UnknownPrefixException {
+            throws MalformedPathException, IllegalNameException, NamespaceException {
         List rules = new ArrayList();
         NodeList childNodes = config.getChildNodes();
         for (int i = 0; i < childNodes.getLength(); i++) {
             Node n = childNodes.item(i);
             if (n.getNodeName().equals("include")) {
-                QName ntName = null;
+                Name ntName = null;
                 Node ntAttr = n.getAttributes().getNamedItem("primaryType");
                 if (ntAttr != null) {
-                    ntName = NameFormat.parse(ntAttr.getNodeValue(), nsResolver);
+                    ntName = resolver.getQName(ntAttr.getNodeValue());
                 }
                 String[] elements = Text.explode(getTextContent(n), '/');
-                Path.PathBuilder builder = new Path.PathBuilder();
+                PathBuilder builder = new PathBuilder();
                 for (int j = 0; j < elements.length; j++) {
                     if (elements[j].equals("*")) {
-                        builder.addLast(new QName("", "*"));
+                        builder.addLast(NameConstants.ANY_NAME);
                     } else {
-                        builder.addLast(NameFormat.parse(elements[j], nsResolver));
+                        builder.addLast(resolver.getQName(elements[j]));
                     }
                 }
                 rules.add(new Rule(builder.getPath(), ntName));
@@ -226,7 +226,7 @@
         /**
          * Optional node type name.
          */
-        private final QName nodeTypeName;
+        private final Name nodeTypeName;
 
         /**
          * A relative path pattern.
@@ -241,7 +241,7 @@
          *                     types are allowed.
          * @param pattern      a relative path pattern.
          */
-        private Rule(Path pattern, QName nodeTypeName) {
+        private Rule(Path pattern, Name nodeTypeName) {
             this.nodeTypeName = nodeTypeName;
             this.pattern = pattern;
         }
@@ -261,7 +261,7 @@
             if (nodeTypeName == null ||
                     nodeState.getNodeTypeName().equals(nodeTypeName)) {
                 // check pattern
-                Path.PathElement[] elements = pattern.getElements();
+                Path.Element[] elements = pattern.getElements();
                 for (int e = elements.length - 1; e >= 0; e--) {
                     NodeId parentId = nodeState.getParentId();
                     if (parentId == null) {
@@ -274,7 +274,7 @@
                         nodeState = parent;
                     } else {
                         // check name
-                        QName name = hmgr.getName(nodeState.getId());
+                        Name name = hmgr.getName(nodeState.getId());
                         if (elements[e].getName().equals(name)) {
                             nodeState = parent;
                         } else {
@@ -317,7 +317,7 @@
          */
         private void resolve(NodeState nodeState, List collector, int offset)
                 throws ItemStateException {
-            QName currentName = pattern.getElement(offset).getName();
+            Name currentName = pattern.getElements()[offset].getName();
             List cne;
             if (currentName.getLocalName().equals("*")) {
                 // matches all

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java Tue Oct 30 03:02:41 2007
@@ -25,7 +25,7 @@
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -389,7 +389,7 @@
                                 return false;
                             } else {
                                 // only use the last one
-                                QName name = entry.getName();
+                                Name name = entry.getName();
                                 List childNodes = state.getChildNodeEntries(name);
                                 if (childNodes.size() == 0
                                         || !((NodeState.ChildNodeEntry) childNodes.get(childNodes.size() - 1))

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocOrderNodeIteratorImpl.java Tue Oct 30 03:02:41 2007
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -192,8 +192,8 @@
                                 invalidIDs.add(n2.getNodeId());
                                 throw new SortFailedException();
                             }
-                            Path.PathElement[] path1 = node1.getPrimaryPath().getElements();
-                            Path.PathElement[] path2 = node2.getPrimaryPath().getElements();
+                            Path.Element[] path1 = node1.getPrimaryPath().getElements();
+                            Path.Element[] path2 = node2.getPrimaryPath().getElements();
 
                             // find nearest common ancestor
                             int commonDepth = 0; // root

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ExcerptProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ExcerptProvider.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ExcerptProvider.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ExcerptProvider.java Tue Oct 30 03:02:41 2007
@@ -17,7 +17,8 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.apache.lucene.search.Query;
 
 import java.io.IOException;
@@ -29,9 +30,9 @@
 public interface ExcerptProvider {
 
     /**
-     * QName of the rep:excerpt function.
+     * Name of the rep:excerpt function.
      */
-    public final QName REP_EXCERPT = new QName(QName.NS_REP_URI, "excerpt(.)");
+    public final Name REP_EXCERPT = NameFactoryImpl.getInstance().create(Name.NS_REP_URI, "excerpt(.)");
 
     /**
      * Initializes this excerpt provider.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FileBasedNamespaceMappings.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FileBasedNamespaceMappings.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FileBasedNamespaceMappings.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FileBasedNamespaceMappings.java Tue Oct 30 03:02:41 2007
@@ -16,13 +16,10 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.name.AbstractNamespaceResolver;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.namespace.AbstractNamespaceResolver;
+import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +61,11 @@
     private final File storage;
 
     /**
+     * The name resolver used to translate the qualified name to JCR name
+     */
+    private final NameResolver nameResolver;
+
+    /**
      * Map of uris indexed by prefixes
      */
     private Map prefixToURI = new HashMap();
@@ -89,6 +91,7 @@
     public FileBasedNamespaceMappings(File file) throws IOException {
         storage = file;
         load();
+        nameResolver = NamePathResolverImpl.create(this);
     }
 
     /**
@@ -142,16 +145,14 @@
      * Translates a property name from a session local namespace mapping
      * into a search index private namespace mapping.
      *
-     * @param name     the property name to translate
-     * @param resolver the <code>NamespaceResolver</code> of the local session.
+     * @param qName     the property name to translate
      * @return the translated property name
      */
-    public String translatePropertyName(String name, NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException {
-        QName qName = NameFormat.parse(name, resolver);
+    public String translatePropertyName(Name qName)
+            throws IllegalNameException {
         try {
-            return NameFormat.format(qName, this);
-        } catch (NoPrefixDeclaredException e) {
+            return nameResolver.getJCRName(qName);
+        } catch (NamespaceException e) {
             // should never happen actually, because we create yet unknown
             // uri mappings on the fly.
             throw new IllegalNameException("Internal error.", e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfiguration.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfiguration.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfiguration.java Tue Oct 30 03:02:41 2007
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.query.QueryHandlerContext;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.lucene.analysis.Analyzer;
 import org.w3c.dom.Element;
 
@@ -62,7 +62,7 @@
      * @return <code>true</code> if the property is indexed; <code>false</code>
      *         otherwise.
      */
-    boolean isIndexed(NodeState state, QName propertyName);
+    boolean isIndexed(NodeState state, Name propertyName);
 
     /**
      * Returns <code>true</code> if the property with the given name should be
@@ -74,7 +74,7 @@
      * @return <code>true</code> if the property should be included in the node
      *         scope fulltext index.
      */
-    boolean isIncludedInNodeScopeIndex(NodeState state, QName propertyName);
+    boolean isIncludedInNodeScopeIndex(NodeState state, Name propertyName);
 
     /**
      * Returns the boost value for the given property name. If there is no
@@ -85,7 +85,7 @@
      * @param propertyName the name of a property.
      * @return the boost value for the property.
      */
-    float getPropertyBoost(NodeState state, QName propertyName);
+    float getPropertyBoost(NodeState state, Name propertyName);
 
     /**
      * Returns the boost for the node scope fulltext index field.
@@ -97,13 +97,13 @@
     
     /**
      * Returns the analyzer configured for the property with this fieldName 
-     * (the string representation ,JCR-style name, of the given <code>QName</code> 
+     * (the string representation ,JCR-style name, of the given <code>Name</code>
      * prefixed with <code>FieldNames.FULLTEXT_PREFIX</code>), 
      * and <code>null</code> if none is configured, or the configured analyzer
      * cannot be found. If <code>null</code> is returned, the default Analyzer
      * is used.
      * 
-     * @param fieldName the string representation ,JCR-style name, of the given <code>QName</code>, 
+     * @param fieldName the string representation ,JCR-style name, of the given <code>Name</code>,
      * prefixed with <code>FieldNames.FULLTEXT_PREFIX</code>)
      * @return the <code>analyzer</code> to use for indexing this property 
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java Tue Oct 30 03:02:41 2007
@@ -16,16 +16,12 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NameResolver;
-import org.apache.jackrabbit.name.ParsingNameResolver;
-import org.apache.jackrabbit.name.PathResolver;
-import org.apache.jackrabbit.name.ParsingPathResolver;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.MalformedPathException;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.ParsingNameResolver;
+import org.apache.jackrabbit.conversion.PathResolver;
+import org.apache.jackrabbit.conversion.ParsingPathResolver;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -37,7 +33,11 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.query.QueryHandlerContext;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.name.NameFactoryImpl;
+import org.apache.jackrabbit.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
 import org.slf4j.Logger;
@@ -50,6 +50,7 @@
 import org.w3c.dom.Element;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Iterator;
@@ -73,12 +74,7 @@
     /**
      * A namespace resolver for parsing QNames in the configuration.
      */
-    private NamespaceResolver nsResolver;
-
-    /**
-     * The node type registry.
-     */
-    private NodeTypeRegistry ntReg;
+    private NameResolver resolver;
 
     /**
      * The item state manager to retrieve additional item states.
@@ -109,15 +105,18 @@
      * {@inheritDoc}
      */
     public void init(Element config, QueryHandlerContext context, NamespaceMappings nsMappings) throws Exception {
-        ntReg = context.getNodeTypeRegistry();
         ism = context.getItemStateManager();
-        NameResolver nameResolver = new ParsingNameResolver(
+        NameResolver nameResolver = new ParsingNameResolver(NameFactoryImpl.getInstance(),
                 context.getNamespaceRegistry());
-        PathResolver pathResolver = new ParsingPathResolver(nameResolver);
+        PathResolver pathResolver = new ParsingPathResolver(PathFactoryImpl.getInstance(),
+                nameResolver);
         hmgr = new HierarchyManagerImpl(context.getRootId(), ism, pathResolver);
-        nsResolver = new AdditionalNamespaceResolver(getNamespaces(config));
+        
+        NamespaceResolver nsResolver = new AdditionalNamespaceResolver(getNamespaces(config));
+        resolver = new ParsingNameResolver(NameFactoryImpl.getInstance(), nsResolver);
 
-        QName[] ntNames = ntReg.getRegisteredNodeTypes();
+        NodeTypeRegistry ntReg = context.getNodeTypeRegistry();
+        Name[] ntNames = ntReg.getRegisteredNodeTypes();
         List idxAggregates = new ArrayList();
         NodeList indexingConfigs = config.getChildNodes();
         for (int i = 0; i < indexingConfigs.getLength(); i++) {
@@ -138,7 +137,7 @@
                 }
             } else if (configNode.getNodeName().equals("aggregate")) {
                 idxAggregates.add(new AggregateRuleImpl(
-                        configNode, nsResolver, ism, hmgr));
+                        configNode, resolver, ism, hmgr));
             } else if (configNode.getNodeName().equals("analyzers")) {
                 NodeList childNodes = configNode.getChildNodes();
                 for (int j = 0; j < childNodes.getLength(); j++) {
@@ -158,8 +157,8 @@
                                     Node propertyNode = propertyChildNodes.item(k);
                                     if (propertyNode.getNodeName().equals("property")) {
                                         // get property name
-                                        QName propName = NameFormat.parse(getTextContent(propertyNode), nsResolver);
-                                        String fieldName = NameFormat.format(propName, nsMappings);
+                                        Name propName = resolver.getQName(getTextContent(propertyNode));
+                                        String fieldName = nsMappings.translatePropertyName(propName);
                                         // set analyzer for the fulltext property fieldname
                                         int idx = fieldName.indexOf(':');
                                         fieldName = fieldName.substring(0, idx + 1)
@@ -206,7 +205,7 @@
      * @return <code>true</code> if the property is fulltext indexed;
      *         <code>false</code> otherwise.
      */
-    public boolean isIndexed(NodeState state, QName propertyName) {
+    public boolean isIndexed(NodeState state, Name propertyName) {
         IndexingRule rule = getApplicableIndexingRule(state);
         if (rule != null) {
             return rule.isIndexed(propertyName);
@@ -224,7 +223,7 @@
      * @param propertyName the name of a property.
      * @return the boost value for the property.
      */
-    public float getPropertyBoost(NodeState state, QName propertyName) {
+    public float getPropertyBoost(NodeState state, Name propertyName) {
         IndexingRule rule = getApplicableIndexingRule(state);
         if (rule != null) {
             return rule.getBoost(propertyName);
@@ -257,7 +256,7 @@
      *         scope fulltext index.
      */
     public boolean isIncludedInNodeScopeIndex(NodeState state,
-                                              QName propertyName) {
+                                              Name propertyName) {
         IndexingRule rule = getApplicableIndexingRule(state);
         if (rule != null) {
             return rule.isIncludedInNodeScopeIndex(propertyName);
@@ -269,13 +268,13 @@
     
     /**
      * Returns the analyzer configured for the property with this fieldName 
-     * (the string representation ,JCR-style name, of the given <code>QName</code>
+     * (the string representation ,JCR-style name, of the given <code>Name</code>
      * prefixed with <code>FieldNames.FULLTEXT_PREFIX</code>)), 
      * and <code>null</code> if none is configured, or the configured analyzer
      * cannot be found. If <code>null</code> is returned, the default Analyzer
      * is used.
      * 
-     * @param fieldName the string representation ,JCR-style name, of the given <code>QName</code>
+     * @param fieldName the string representation ,JCR-style name, of the given <code>Name</code>
      * prefixed with <code>FieldNames.FULLTEXT_PREFIX</code>))
      * @return the <code>analyzer</code> to use for indexing this property 
      */
@@ -351,11 +350,11 @@
      * @return the property configurations defined in the <code>config</code>.
      * @throws IllegalNameException   if the node type name contains illegal
      *                                characters.
-     * @throws UnknownPrefixException if the node type contains an unknown
+     * @throws NamespaceException if the node type contains an unknown
      *                                prefix.
      */
     private Map getPropertyConfigs(Node config)
-            throws IllegalNameException, UnknownPrefixException {
+            throws IllegalNameException, NamespaceException {
         Map configs = new HashMap();
         NodeList childNodes = config.getChildNodes();
         for (int i = 0; i < childNodes.getLength(); i++) {
@@ -382,7 +381,7 @@
                 }
 
                 // get property name
-                QName propName = NameFormat.parse(getTextContent(n), nsResolver);
+                Name propName = resolver.getQName(getTextContent(n));
 
                 configs.put(propName, new PropertyConfig(boost, nodeScopeIndex));
             }
@@ -398,10 +397,10 @@
      *         condition set on the <code>config</code>.
      * @throws MalformedPathException if the condition string is malformed.
      * @throws IllegalNameException   if a name contains illegal characters.
-     * @throws UnknownPrefixException if a name contains an unknown prefix.
+     * @throws NamespaceException if a name contains an unknown prefix.
      */
     private PathExpression getCondition(Node config)
-            throws MalformedPathException, IllegalNameException, UnknownPrefixException {
+            throws MalformedPathException, IllegalNameException, NamespaceException {
         Node conditionAttr = config.getAttributes().getNamedItem("condition");
         if (conditionAttr == null) {
             return null;
@@ -409,9 +408,9 @@
         String conditionString = conditionAttr.getNodeValue();
         int idx;
         int axis;
-        QName elementTest = null;
-        QName nameTest = null;
-        QName propertyName;
+        Name elementTest = null;
+        Name nameTest = null;
+        Name propertyName;
         String propertyValue;
 
         // parse axis
@@ -436,11 +435,11 @@
                 String name = conditionString.substring(
                         idx + "element(".length(), colon).trim();
                 if (!name.equals("*")) {
-                    nameTest = NameFormat.parse(ISO9075.decode(name), nsResolver);
+                    nameTest = resolver.getQName(ISO9075.decode(name));
                 }
                 idx = conditionString.indexOf(")/@", colon);
                 String type = conditionString.substring(colon + 1, idx).trim();
-                elementTest = NameFormat.parse(ISO9075.decode(type), nsResolver);
+                elementTest = resolver.getQName(ISO9075.decode(type));
                 idx += ")/@".length();
             } else {
                 if (axis == PathExpression.ANCESTOR ||
@@ -450,7 +449,7 @@
                     String name = conditionString.substring(idx,
                             conditionString.indexOf('/', idx));
                     if (!name.equals("*")) {
-                        nameTest = NameFormat.parse(ISO9075.decode(name), nsResolver);
+                        nameTest = resolver.getQName(ISO9075.decode(name));
                     }
                     idx += name.length() + "/@".length();
                 }
@@ -459,7 +458,7 @@
             // parse property name
             int eq = conditionString.indexOf('=', idx);
             String name = conditionString.substring(idx, eq).trim();
-            propertyName = NameFormat.parse(ISO9075.decode(name), nsResolver);
+            propertyName = resolver.getQName(ISO9075.decode(name));
 
             // parse string value
             int quote = conditionString.indexOf('\'', eq) + 1;
@@ -494,10 +493,10 @@
         /**
          * The node type of this fulltext indexing rule.
          */
-        private final QName nodeTypeName;
+        private final Name nodeTypeName;
 
         /**
-         * Map of {@link PropertyConfig}. Key=QName of property.
+         * Map of {@link PropertyConfig}. Key=Name of property.
          */
         private final Map propConfigs;
 
@@ -516,10 +515,10 @@
          * @param config the configuration for this rule.
          * @throws MalformedPathException if the condition expression is malformed.
          * @throws IllegalNameException   if a name contains illegal characters.
-         * @throws UnknownPrefixException if a name contains an unknown prefix.
+         * @throws NamespaceException if a name contains an unknown prefix.
          */
         IndexingRule(Node config)
-                throws MalformedPathException, IllegalNameException, UnknownPrefixException {
+                throws MalformedPathException, IllegalNameException, NamespaceException {
             this.nodeTypeName = getNodeTypeName(config);
             this.propConfigs = getPropertyConfigs(config);
             this.condition = getCondition(config);
@@ -531,7 +530,7 @@
          *
          * @return name of the node type.
          */
-        public QName getNodeTypeName() {
+        public Name getNodeTypeName() {
             return nodeTypeName;
         }
 
@@ -550,7 +549,7 @@
          * @return <code>true</code> if the property is indexed;
          *         <code>false</code> otherwise.
          */
-        public boolean isIndexed(QName propertyName) {
+        public boolean isIndexed(Name propertyName) {
             return propConfigs.containsKey(propertyName);
         }
 
@@ -562,7 +561,7 @@
          * @param propertyName the name of a property.
          * @return the boost value for the property.
          */
-        public float getBoost(QName propertyName) {
+        public float getBoost(Name propertyName) {
             PropertyConfig config = (PropertyConfig) propConfigs.get(propertyName);
             if (config != null) {
                 return config.boost;
@@ -580,7 +579,7 @@
          * @return <code>true</code> if the property should be included in the
          *         node scope fulltext index.
          */
-        public boolean isIncludedInNodeScopeIndex(QName propertyName) {
+        public boolean isIncludedInNodeScopeIndex(Name propertyName) {
             PropertyConfig config = (PropertyConfig) propConfigs.get(propertyName);
             if (config != null) {
                 return config.nodeScopeIndex;
@@ -617,13 +616,13 @@
          * @return the name of the node type.
          * @throws IllegalNameException   if the node type name contains illegal
          *                                characters.
-         * @throws UnknownPrefixException if the node type contains an unknown
+         * @throws NamespaceException if the node type contains an unknown
          *                                prefix.
          */
-        private QName getNodeTypeName(Node config)
-                throws IllegalNameException, UnknownPrefixException {
+        private Name getNodeTypeName(Node config)
+                throws IllegalNameException, NamespaceException {
             String ntString = config.getAttributes().getNamedItem("nodeType").getNodeValue();
-            return NameFormat.parse(ntString, nsResolver);
+            return resolver.getQName(ntString);
         }
 
         /**
@@ -680,16 +679,16 @@
 
         private final int axis;
 
-        private final QName elementTest;
+        private final Name elementTest;
 
-        private final QName nameTest;
+        private final Name nameTest;
 
-        private final QName propertyName;
+        private final Name propertyName;
 
         private final String propertyValue;
 
-        PathExpression(int axis, QName elementTest, QName nameTest,
-                       QName propertyName, String propertyValue) {
+        PathExpression(int axis, Name elementTest, Name nameTest,
+                       Name propertyName, String propertyValue) {
             this.axis = axis;
             this.elementTest = elementTest;
             this.nameTest = nameTest;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JQOM2LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JQOM2LuceneQueryBuilder.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JQOM2LuceneQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JQOM2LuceneQueryBuilder.java Tue Oct 30 03:02:41 2007
@@ -57,10 +57,10 @@
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.HierarchyManagerImpl;
 import org.apache.jackrabbit.core.state.ItemStateManager;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.PathFormat;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.BooleanQuery;
@@ -121,6 +121,11 @@
     private final NamespaceMappings nsMappings;
 
     /**
+     * NamePathResolver to map namespace mappings to internal prefixes
+     */
+    private final NamePathResolver npResolver;
+
+    /**
      * The analyzer instance to use for contains function query parsing
      */
     private final Analyzer analyzer;
@@ -142,7 +147,7 @@
 
     /**
      * The selector queries that have already been translated into lucene
-     * queries. Key=QName (selectorName).
+     * queries. Key=Name (selectorName).
      */
     private final Map selectors = new HashMap();
 
@@ -176,6 +181,7 @@
         this.sharedItemMgr = sharedItemMgr;
         this.hmgr = hmgr;
         this.nsMappings = nsMappings;
+        this.npResolver = NamePathResolverImpl.create(nsMappings);
         this.analyzer = analyzer;
         this.propRegistry = propReg;
         this.synonymProvider = synonymProvider;
@@ -292,12 +298,12 @@
                 stringValue = LongField.longToString(v.getLong());
                 break;
             case PropertyType.NAME:
-                stringValue = nsMappings.translatePropertyName(
-                        v.getString(), session.getNamespaceResolver());
+                Name n = session.getQName(v.getString());
+                stringValue = nsMappings.translatePropertyName(n);
                 break;
             case PropertyType.PATH:
-                Path p = PathFormat.parse(v.getString(), session.getNamespaceResolver());
-                stringValue = PathFormat.format(p, nsMappings);
+                Path p = session.getQPath(v.getString());
+                stringValue = npResolver.getJCRPath(p);
                 break;
             case PropertyType.REFERENCE:
                 stringValue = v.getString();
@@ -316,7 +322,7 @@
         return ((DynamicOperandImpl) node.getOperand1()).accept(
                 new DefaultTraversingQOMTreeVisitor() {
             public Object visit(PropertyValueImpl node, Object data) throws Exception {
-                String propName = NameFormat.format(node.getPropertyQName(), nsMappings);
+                String propName = npResolver.getJCRName(node.getPropertyQName());
                 String text = FieldNames.createNamedValue(propName, stringValue);
                 switch (operator) {
                     case QueryObjectModelConstants.OPERATOR_EQUAL_TO:
@@ -446,7 +452,7 @@
             fieldname = FieldNames.FULLTEXT;
         } else {
             // final path element is a property name
-            QName propName = node.getPropertyQName();
+            Name propName = node.getPropertyQName();
             StringBuffer tmp = new StringBuffer();
             tmp.append(nsMappings.getPrefix(propName.getNamespaceURI()));
             tmp.append(":").append(FieldNames.FULLTEXT_PREFIX);
@@ -545,7 +551,7 @@
     }
 
     public Object visit(PropertyExistenceImpl node, Object data) throws Exception {
-        String propName = NameFormat.format(node.getPropertyQName(), nsMappings);
+        String propName = npResolver.getJCRName(node.getPropertyQName());
         return new MatchAllQuery(propName);
     }
 
@@ -580,8 +586,8 @@
 
     public Object visit(SelectorImpl node, Object data) throws Exception {
         List terms = new ArrayList();
-        String mixinTypesField = NameFormat.format(QName.JCR_MIXINTYPES, nsMappings);
-        String primaryTypeField = NameFormat.format(QName.JCR_PRIMARYTYPE, nsMappings);
+        String mixinTypesField = npResolver.getJCRName(NameConstants.JCR_MIXINTYPES);
+        String primaryTypeField = npResolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);
 
         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
         NodeType base = null;
@@ -595,13 +601,13 @@
             // search for nodes where jcr:mixinTypes is set to this mixin
             Term t = new Term(FieldNames.PROPERTIES,
                     FieldNames.createNamedValue(mixinTypesField,
-                            NameFormat.format(node.getNodeTypeQName(), nsMappings)));
+                            npResolver.getJCRName(node.getNodeTypeQName())));
             terms.add(t);
         } else {
             // search for nodes where jcr:primaryType is set to this type
             Term t = new Term(FieldNames.PROPERTIES,
                     FieldNames.createNamedValue(primaryTypeField,
-                            NameFormat.format(node.getNodeTypeQName(), nsMappings)));
+                            npResolver.getJCRName(node.getNodeTypeQName())));
             terms.add(t);
         }
 
@@ -612,8 +618,8 @@
                 NodeType nt = allTypes.nextNodeType();
                 NodeType[] superTypes = nt.getSupertypes();
                 if (Arrays.asList(superTypes).contains(base)) {
-                    String ntName = nsMappings.translatePropertyName(nt.getName(),
-                            session.getNamespaceResolver());
+                    Name n = session.getQName(nt.getName());
+                    String ntName = nsMappings.translatePropertyName(n);
                     Term t;
                     if (nt.isMixin()) {
                         // search on jcr:mixinTypes

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java Tue Oct 30 03:02:41 2007
@@ -44,13 +44,13 @@
 import org.apache.jackrabbit.core.query.lucene.fulltext.QueryParser;
 import org.apache.jackrabbit.core.query.lucene.fulltext.ParseException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.name.PathBuilder;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.MalformedPathException;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.util.XMLChar;
 import org.apache.jackrabbit.util.ISO9075;
@@ -115,6 +115,11 @@
     private NamespaceMappings nsMappings;
 
     /**
+     * Name and Path resolver
+     */
+    private NamePathResolver resolver;
+
+    /**
      * The analyzer instance to use for contains function query parsing
      */
     private Analyzer analyzer;
@@ -173,6 +178,8 @@
         this.propRegistry = propReg;
         this.synonymProvider = synonymProvider;
         this.indexFormatVersion = indexFormatVersion;
+
+        this.resolver = NamePathResolverImpl.create(nsMappings);
     }
 
     /**
@@ -285,9 +292,9 @@
         String field = "";
         String value = "";
         try {
-            field = NameFormat.format(node.getPropertyName(), nsMappings);
-            value = NameFormat.format(node.getValue(), nsMappings);
-        } catch (NoPrefixDeclaredException e) {
+            field = resolver.getJCRName(node.getPropertyName());
+            value = resolver.getJCRName(node.getValue());
+        } catch (NamespaceException e) {
             // will never happen, prefixes are created when unknown
         }
         return new TermQuery(new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(field, value)));
@@ -297,8 +304,8 @@
 
         List terms = new ArrayList();
         try {
-            String mixinTypesField = NameFormat.format(QName.JCR_MIXINTYPES, nsMappings);
-            String primaryTypeField = NameFormat.format(QName.JCR_PRIMARYTYPE, nsMappings);
+            String mixinTypesField = resolver.getJCRName(NameConstants.JCR_MIXINTYPES);
+            String primaryTypeField = resolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);
 
             NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
             NodeType base = ntMgr.getNodeType(session.getJCRName(node.getValue()));
@@ -307,13 +314,13 @@
                 // search for nodes where jcr:mixinTypes is set to this mixin
                 Term t = new Term(FieldNames.PROPERTIES,
                         FieldNames.createNamedValue(mixinTypesField,
-                                NameFormat.format(node.getValue(), nsMappings)));
+                                resolver.getJCRName(node.getValue())));
                 terms.add(t);
             } else {
                 // search for nodes where jcr:primaryType is set to this type
                 Term t = new Term(FieldNames.PROPERTIES,
                         FieldNames.createNamedValue(primaryTypeField,
-                                NameFormat.format(node.getValue(), nsMappings)));
+                                resolver.getJCRName(node.getValue())));
                 terms.add(t);
             }
 
@@ -323,8 +330,8 @@
                 NodeType nt = allTypes.nextNodeType();
                 NodeType[] superTypes = nt.getSupertypes();
                 if (Arrays.asList(superTypes).contains(base)) {
-                    String ntName = nsMappings.translatePropertyName(nt.getName(),
-                            session.getNamespaceResolver());
+                    Name n = session.getQName(nt.getName());
+                    String ntName = nsMappings.translatePropertyName(n);
                     Term t;
                     if (nt.isMixin()) {
                         // search on jcr:mixinTypes
@@ -366,7 +373,7 @@
                 fieldname = FieldNames.FULLTEXT;
             } else {
                 // final path element is a property name
-                QName propName = relPath.getNameElement().getName();
+                Name propName = relPath.getNameElement().getName();
                 StringBuffer tmp = new StringBuffer();
                 tmp.append(nsMappings.getPrefix(propName.getNamespaceURI()));
                 tmp.append(":").append(FieldNames.FULLTEXT_PREFIX);
@@ -408,11 +415,11 @@
             Query context = parser.parse(query.toString());
             if (relPath != null && (!node.getReferencesProperty() || relPath.getLength() > 1)) {
                 // text search on some child axis
-                Path.PathElement[] elements = relPath.getElements();
+                Path.Element[] elements = relPath.getElements();
                 for (int i = elements.length - 1; i >= 0; i--) {
                     String name = null;
                     if (!elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
-                        name = NameFormat.format(elements[i].getName(), nsMappings);;
+                        name = resolver.getJCRName(elements[i].getName());
                     }
                     // join text search with name test
                     // if path references property that's elements.length - 2
@@ -439,8 +446,6 @@
             exceptions.add(e);
         } catch (ParseException e) {
             exceptions.add(e);
-        } catch (NoPrefixDeclaredException e) {
-            exceptions.add(e);
         }
         return null;
     }
@@ -451,7 +456,7 @@
         if (steps.length > 0) {
             if (node.isAbsolute() && !steps[0].getIncludeDescendants()) {
                 // eat up first step
-                QName nameTest = steps[0].getNameTest();
+                Name nameTest = steps[0].getNameTest();
                 if (nameTest == null) {
                     // this is equivalent to the root node
                     context = new TermQuery(new Term(FieldNames.PARENT, ""));
@@ -463,8 +468,8 @@
                     // will never match anything!
                     String name = "";
                     try {
-                        name = NameFormat.format(nameTest, nsMappings);
-                    } catch (NoPrefixDeclaredException e) {
+                        name = resolver.getJCRName(nameTest);
+                    } catch (NamespaceException e) {
                         exceptions.add(e);
                     }
                     BooleanQuery and = new BooleanQuery();
@@ -525,9 +530,9 @@
         TermQuery nameTest = null;
         if (node.getNameTest() != null) {
             try {
-                String internalName = NameFormat.format(node.getNameTest(), nsMappings);
+                String internalName = resolver.getJCRName(node.getNameTest());
                 nameTest = new TermQuery(new Term(FieldNames.LABEL, internalName));
-            } catch (NoPrefixDeclaredException e) {
+            } catch (NamespaceException e) {
                 // should never happen
                 exceptions.add(e);
             }
@@ -554,8 +559,8 @@
                     // todo this will traverse the whole index, optimize!
                     Query subQuery = null;
                     try {
-                        subQuery = createMatchAllQuery(NameFormat.format(QName.JCR_PRIMARYTYPE, nsMappings));
-                    } catch (NoPrefixDeclaredException e) {
+                        subQuery = createMatchAllQuery(resolver.getJCRName(NameConstants.JCR_PRIMARYTYPE));
+                    } catch (NamespaceException e) {
                         // will never happen, prefixes are created when unknown
                     }
                     // only use descendant axis if path is not //*
@@ -588,10 +593,10 @@
         }
 
         try {
-            String refProperty = NameFormat.format(node.getRefProperty(), nsMappings);
+            String refProperty = resolver.getJCRName(node.getRefProperty());
             String nameTest = null;
             if (node.getNameTest() != null) {
-                nameTest = NameFormat.format(node.getNameTest(), nsMappings);
+                nameTest = resolver.getJCRName(node.getNameTest());
             }
 
             if (node.getIncludeDescendants()) {
@@ -612,7 +617,7 @@
                 context = andQuery;
             }
 
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             // should never happen
             exceptions.add(e);
         }
@@ -642,7 +647,7 @@
                         || node.getOperation() == QueryConstants.OPERATION_NE_GENERAL
                         || node.getOperation() == QueryConstants.OPERATION_NE_VALUE) {
                     // only use coercing on non-range operations
-                    QName propertyName = node.getRelativePath().getNameElement().getName();
+                    Name propertyName = node.getRelativePath().getNameElement().getName();
                     stringValues = getStringValues(propertyName, node.getStringValue());
                 } else {
                     stringValues[0] = node.getStringValue();
@@ -682,13 +687,13 @@
             // add the name of a dummy property because relPath actually
             // references a property. whereas the relPath of the similar
             // operation references a node
-            Path.PathBuilder builder;
+            PathBuilder builder;
             if (relPath == null) {
-                builder = new Path.PathBuilder();
+                builder = new PathBuilder();
             } else {
-                builder = new Path.PathBuilder(relPath);
+                builder = new PathBuilder(relPath);
             }
-            builder.addLast(QName.JCR_PRIMARYTYPE);
+            builder.addLast(NameConstants.JCR_PRIMARYTYPE);
             try {
                 relPath = builder.getPath();
             } catch (MalformedPathException e) {
@@ -697,14 +702,14 @@
         }
         String field = "";
         try {
-            field = NameFormat.format(relPath.getNameElement().getName(), nsMappings);
-        } catch (NoPrefixDeclaredException e) {
+            field = resolver.getJCRName(relPath.getNameElement().getName());
+        } catch (NamespaceException e) {
             // should never happen
             exceptions.add(e);
         }
 
         // support for fn:name()
-        QName propName = relPath.getNameElement().getName();
+        Name propName = relPath.getNameElement().getName();
         if (propName.getNamespaceURI().equals(SearchManager.NS_FN_URI) &&
                 propName.getLocalName().equals("name()")) {
             if (node.getValueType() != QueryConstants.TYPE_STRING) {
@@ -718,18 +723,20 @@
                         "only be used in conjunction with an equals operator"));
                 return data;
             }
-            // check if string literal is a valid XML QName
+            // check if string literal is a valid XML Name
             if (XMLChar.isValidName(node.getStringValue())) {
-                // parse string literal as JCR QName
+                // parse string literal as JCR Name
                 try {
-                    String translatedQName = nsMappings.translatePropertyName(
-                            ISO9075.decode(node.getStringValue()),
-                            session.getNamespaceResolver());
+                    Name n = session.getQName(ISO9075.decode(node.getStringValue()));
+                    String translatedQName = nsMappings.translatePropertyName(n);
                     Term t = new Term(FieldNames.LABEL, translatedQName);
                     query = new TermQuery(t);
                 } catch (NameException e) {
                     exceptions.add(e);
                     return data;
+                } catch (NamespaceException e) {
+                    exceptions.add(e);
+                    return data;
                 }
             } else {
                 // will never match -> create dummy query
@@ -900,13 +907,13 @@
         if (relPath.getLength() > 1) {
             try {
                 // child axis in relation
-                Path.PathElement[] elements = relPath.getElements();
+                Path.Element[] elements = relPath.getElements();
                 // elements.length - 1 = property name
                 // elements.length - 2 = last child axis name test
                 for (int i = elements.length - 2; i >= 0; i--) {
                     String name = null;
                     if (!elements[i].getName().equals(RelationQueryNode.STAR_NAME_TEST)) {
-                        name = NameFormat.format(elements[i].getName(), nsMappings);
+                        name = resolver.getJCRName(elements[i].getName());
                     }
                     if (i == elements.length - 2) {
                         // join name test with property query if there is one
@@ -923,7 +930,7 @@
                         query = new ParentAxisQuery(query, name);
                     }
                 }
-            } catch (NoPrefixDeclaredException e) {
+            } catch (NamespaceException e) {
                 // should never happen
                 exceptions.add(e);
             }
@@ -980,7 +987,7 @@
      * @param literal      the String literal in the relation.
      * @return the String values to use as term for the query.
      */
-    private String[] getStringValues(QName propertyName, String literal) {
+    private String[] getStringValues(Name propertyName, String literal) {
         PropertyTypeRegistry.TypeMapping[] types = propRegistry.getPropertyTypes(propertyName);
         List values = new ArrayList();
         for (int i = 0; i < types.length; i++) {
@@ -988,17 +995,20 @@
                 case PropertyType.NAME:
                     // try to translate name
                     try {
-                        values.add(nsMappings.translatePropertyName(literal, session.getNamespaceResolver()));
+                        Name n = session.getQName(literal);
+                        values.add(nsMappings.translatePropertyName(n));
                         log.debug("Coerced " + literal + " into NAME.");
                     } catch (NameException e) {
                         log.warn("Unable to coerce '" + literal + "' into a NAME: " + e.toString());
+                    } catch (NamespaceException e) {
+                        log.warn("Unable to coerce '" + literal + "' into a NAME: " + e.toString());
                     }
                     break;
                 case PropertyType.PATH:
                     // try to translate path
                     try {
                         Path p = session.getQPath(literal);
-                        values.add(PathFormat.format(p, nsMappings));
+                        values.add(resolver.getJCRPath(p));
                         log.debug("Coerced " + literal + " into PATH.");
                     } catch (NameException e) {
                         log.warn("Unable to coerce '" + literal + "' into a PATH: " + e.toString());
@@ -1050,8 +1060,7 @@
             if (literal.indexOf('/') > -1) {
                 // might be a path
                 try {
-                    values.add(PathFormat.format(
-                            session.getQPath(literal), nsMappings));
+                    values.add(resolver.getJCRPath(session.getQPath(literal)));
                     log.debug("Coerced " + literal + " into PATH.");
                 } catch (Exception e) {
                     // not a path
@@ -1060,7 +1069,8 @@
             if (XMLChar.isValidName(literal)) {
                 // might be a name
                 try {
-                    values.add(nsMappings.translatePropertyName(literal, session.getNamespaceResolver()));
+                    Name n = session.getQName(literal);
+                    values.add(nsMappings.translatePropertyName(n));
                     log.debug("Coerced " + literal + " into NAME.");
                 } catch (Exception e) {
                     // not a name

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NSRegistryBasedNamespaceMappings.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NSRegistryBasedNamespaceMappings.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NSRegistryBasedNamespaceMappings.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NSRegistryBasedNamespaceMappings.java Tue Oct 30 03:02:41 2007
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.name.AbstractNamespaceResolver;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.NameResolver;
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
+import org.apache.jackrabbit.namespace.AbstractNamespaceResolver;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.NamespaceException;
 
@@ -40,6 +37,11 @@
      */
     private final NamespaceRegistryImpl nsReg;
 
+        /**
+     * The name resolver used to translate the qualified name to JCR name
+     */
+    private final NameResolver nameResolver;
+
     /**
      * Creates a new <code>NSRegistryBasedNamespaceMappings</code>.
      *
@@ -47,6 +49,7 @@
      */
     NSRegistryBasedNamespaceMappings(NamespaceRegistryImpl nsReg) {
         this.nsReg = nsReg;
+        this.nameResolver = NamePathResolverImpl.create(this);
     }
 
     //-------------------------------< NamespaceResolver >----------------------
@@ -75,13 +78,11 @@
     /**
      * {@inheritDoc}
      */
-    public String translatePropertyName(String name,
-                                        NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException {
-        QName qName = NameFormat.parse(name, resolver);
+    public String translatePropertyName(Name qName)
+            throws IllegalNameException {
         try {
-            return NameFormat.format(qName, this);
-        } catch (NoPrefixDeclaredException e) {
+            return nameResolver.getJCRName(qName);
+        } catch (NamespaceException e) {
             // should never happen actually, there is always a stable index
             // prefix for a known namespace uri
             throw new IllegalNameException("Internal error.", e);

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java?rev=590014&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java Tue Oct 30 03:02:41 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.query.lucene;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.NameParser;
+import org.apache.jackrabbit.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.conversion.ParsingPathResolver;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.PathResolver;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
+import org.apache.jackrabbit.name.NameFactoryImpl;
+import org.apache.jackrabbit.name.PathFactoryImpl;
+
+import javax.jcr.NamespaceException;
+
+/**
+ * <code>NamePathResolverImpl</code>...
+ */
+public class NamePathResolverImpl extends DefaultNamePathResolver {
+
+    private static Logger log = LoggerFactory.getLogger(NamePathResolverImpl.class);
+
+    private static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
+    private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
+
+    private NamePathResolverImpl(NameResolver nResolver, PathResolver pResolver) {
+        super(nResolver, pResolver);
+    }
+
+    public static NamePathResolver create(NamespaceMappings nsMappings) {
+        NameResolver nResolver = new NameResolverImpl(nsMappings);
+        PathResolver pResolver = new ParsingPathResolver(PATH_FACTORY, nResolver);
+        return new NamePathResolverImpl(nResolver, pResolver);
+    }
+
+
+    //--------------------------------------------------------< inner class >---
+    /**
+     * Query specific NameResolver that does not assume an empty prefix for the
+     * default namespace URI. Instead the prefix is always retrieved from the
+     * NamespaceResolver.
+     */
+    private static class NameResolverImpl implements NameResolver {
+
+        /**
+         * Namespace resolver.
+         */
+        private final NamespaceResolver resolver;
+
+        /**
+         * Creates a parsing name resolver.
+         *
+         * @param resolver namespace resolver
+         */
+        public NameResolverImpl(NamespaceResolver resolver) {
+            this.resolver = resolver;
+        }
+
+        //-------------------------------------------------------< NameResolver >---
+        /**
+         * Parses the prefixed JCR name and returns the resolved qualified name.
+         *
+         * @param name prefixed JCR name
+         * @return qualified name
+         * @throws IllegalNameException if the JCR name format is invalid
+         * @throws NamespaceException if the namespace prefix can not be resolved
+         */
+        public Name getQName(String name) throws IllegalNameException, NamespaceException {
+            return NameParser.parse(name, resolver, NAME_FACTORY);
+        }
+
+        /**
+         * Returns the prefixed JCR name for the given qualified name.
+         * Note, that the JCR prefix is always retrieved from the NamespaceResolver
+         * even if the name is in the defaut namespace. This is a special treatement
+         * for query specific implementation, which defines a prefix for all namespace
+         * URIs including the default namespace.
+         *
+         * @param name qualified name
+         * @return prefixed JCR name
+         * @throws NamespaceException if the namespace URI can not be resolved
+         */
+        public String getJCRName(Name name) throws NamespaceException {
+            String uri = name.getNamespaceURI();
+            if (resolver.getPrefix(uri).length() == 0) {
+                return name.getLocalName();
+            } else {
+                return resolver.getPrefix(uri) + ":" + name.getLocalName();
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamePathResolverImpl.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamespaceMappings.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamespaceMappings.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamespaceMappings.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NamespaceMappings.java Tue Oct 30 03:02:41 2007
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.Name;
 
 /**
  * The class <code>NamespaceMappings</code> holds a namespace mapping that is
@@ -31,11 +31,8 @@
      * Translates a property name from a session local namespace mapping into a
      * search index private namespace mapping.
      *
-     * @param name     the property name to translate
-     * @param resolver the <code>NamespaceResolver</code> of the local session.
-     * @return the translated property name
+     * @param qName     the property name to translate
+     * @return the translated JCR property name
      */
-    public String translatePropertyName(String name,
-                                        NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException;
+    public String translatePropertyName(Name qName) throws IllegalNameException;
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java Tue Oct 30 03:02:41 2007
@@ -26,11 +26,10 @@
 import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.extractor.TextExtractor;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.PathFormat;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,6 +79,11 @@
     protected final NamespaceMappings mappings;
 
     /**
+     * Name and Path resolver.
+     */
+    protected final NamePathResolver resolver;
+
+    /**
      * Content extractor.
      */
     protected final TextExtractor extractor;
@@ -115,6 +119,7 @@
         this.node = node;
         this.stateProvider = stateProvider;
         this.mappings = mappings;
+        this.resolver = NamePathResolverImpl.create(mappings);
         this.extractor = extractor;
     }
 
@@ -185,21 +190,21 @@
                     throw new RepositoryException("Missing child node entry " +
                             "for node with id: " + node.getNodeId());
                 }
-                String name = NameFormat.format(child.getName(), mappings);
+                String name = resolver.getJCRName(child.getName());
                 doc.add(new Field(FieldNames.LABEL, name, Field.Store.NO, Field.Index.NO_NORMS, Field.TermVector.NO));
             }
         } catch (NoSuchItemStateException e) {
             throwRepositoryException(e);
         } catch (ItemStateException e) {
             throwRepositoryException(e);
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             // will never happen, because this.mappings will dynamically add
             // unknown uri<->prefix mappings
         }
 
         Set props = node.getPropertyNames();
         for (Iterator it = props.iterator(); it.hasNext();) {
-            QName propName = (QName) it.next();
+            Name propName = (Name) it.next();
             PropertyId id = new PropertyId(node.getNodeId(), propName);
             try {
                 PropertyState propState = (PropertyState) stateProvider.getItemState(id);
@@ -248,11 +253,11 @@
      * @param doc  the lucene document.
      * @param name the name of the multi-value property.
      */
-    private void addMVPName(Document doc, QName name) {
+    private void addMVPName(Document doc, Name name) {
         try {
-            String propName = NameFormat.format(name, mappings);
+            String propName = resolver.getJCRName(name);
             doc.add(new Field(FieldNames.MVP, propName, Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NamespaceException e) {
             // will never happen, prefixes are created dynamically
         }
     }
@@ -264,11 +269,11 @@
      * @param value the internal jackrabbit value.
      * @param name  the name of the property.
      */
-    private void addValue(Document doc, InternalValue value, QName name) {
+    private void addValue(Document doc, InternalValue value, Name name) {
         String fieldName = name.getLocalName();
         try {
-            fieldName = NameFormat.format(name, mappings);
-        } catch (NoPrefixDeclaredException e) {
+            fieldName = resolver.getJCRName(name);
+        } catch (NamespaceException e) {
             // will never happen
         }
         switch (value.getType()) {
@@ -310,7 +315,7 @@
             case PropertyType.STRING:
                 if (isIndexed(name)) {
                     // never fulltext index jcr:uuid String
-                    if (name.equals(QName.JCR_UUID)) {
+                    if (name.equals(NameConstants.JCR_UUID)) {
                         addStringValue(doc, fieldName, value.getString(),
                                 false, false, DEFAULT_BOOST);
                     } else {
@@ -324,8 +329,8 @@
                 // jcr:primaryType and jcr:mixinTypes are required for correct
                 // node type resolution in queries
                 if (isIndexed(name) ||
-                        name.equals(QName.JCR_PRIMARYTYPE) ||
-                        name.equals(QName.JCR_MIXINTYPES)) {
+                        name.equals(NameConstants.JCR_PRIMARYTYPE) ||
+                        name.equals(NameConstants.JCR_MIXINTYPES)) {
                     addNameValue(doc, fieldName, value.getQName());
                 }
                 break;
@@ -340,11 +345,11 @@
      * @param doc  the document.
      * @param name the name of the property.
      */
-    private void addPropertyName(Document doc, QName name) {
+    private void addPropertyName(Document doc, Name name) {
         String fieldName = name.getLocalName();
         try {
-            fieldName = NameFormat.format(name, mappings);
-        } catch (NoPrefixDeclaredException e) {
+            fieldName = resolver.getJCRName(name);
+        } catch (NamespaceException e) {
             // will never happen
         }
         doc.add(new Field(FieldNames.PROPERTIES_SET, fieldName, Field.Store.NO, Field.Index.NO_NORMS));
@@ -366,19 +371,19 @@
                                   Object internalValue) {
         // 'check' if node is of type nt:resource
         try {
-            String jcrData = mappings.getPrefix(QName.NS_JCR_URI) + ":data";
+            String jcrData = mappings.getPrefix(Name.NS_JCR_URI) + ":data";
             if (!jcrData.equals(fieldName)) {
                 // don't know how to index
                 return;
             }
 
-            InternalValue typeValue = getValue(QName.JCR_MIMETYPE);
+            InternalValue typeValue = getValue(NameConstants.JCR_MIMETYPE);
             if (typeValue != null) {
                 String type = typeValue.getString();
 
                 // jcr:encoding is not mandatory
                 String encoding = null;
-                InternalValue encodingValue = getValue(QName.JCR_ENCODING);
+                InternalValue encodingValue = getValue(NameConstants.JCR_ENCODING);
                 if (encodingValue != null) {
                     encoding = encodingValue.getString();
                 }
@@ -404,7 +409,7 @@
      * @return value of the named property, or <code>null</code>
      * @throws ItemStateException if the property can not be accessed
      */
-    protected InternalValue getValue(QName name) throws ItemStateException {
+    protected InternalValue getValue(Name name) throws ItemStateException {
         try {
             PropertyId id = new PropertyId(node.getNodeId(), name);
             PropertyState property =
@@ -524,8 +529,8 @@
         Path path = (Path) internalValue;
         String pathString = path.toString();
         try {
-            pathString = PathFormat.format(path, mappings);
-        } catch (NoPrefixDeclaredException e) {
+            pathString = resolver.getJCRPath(path);
+        } catch (NamespaceException e) {
             // will never happen
         }
         doc.add(createFieldWithoutNorms(fieldName, pathString, false));
@@ -617,7 +622,7 @@
      * @param internalValue The value for the field to add to the document.
      */
     protected void addNameValue(Document doc, String fieldName, Object internalValue) {
-        QName qualiName = (QName) internalValue;
+        Name qualiName = (Name) internalValue;
         String normValue = qualiName.toString();
         try {
             normValue = mappings.getPrefix(qualiName.getNamespaceURI())
@@ -692,7 +697,7 @@
      * @return <code>true</code> if the property should be fulltext indexed;
      *         <code>false</code> otherwise.
      */
-    protected boolean isIndexed(QName propertyName) {
+    protected boolean isIndexed(Name propertyName) {
         if (indexingConfig == null) {
             return true;
         } else {
@@ -708,7 +713,7 @@
      * @return <code>true</code> if it should be added to the node scope index;
      *         <code>false</code> otherwise.
      */
-    protected boolean isIncludedInNodeIndex(QName propertyName) {
+    protected boolean isIncludedInNodeIndex(Name propertyName) {
         if (indexingConfig == null) {
             return true;
         } else {
@@ -722,7 +727,7 @@
      * @param propertyName the name of a property.
      * @return the boost value for the given property name.
      */
-    protected float getPropertyBoost(QName propertyName) {
+    protected float getPropertyBoost(Name propertyName) {
         if (indexingConfig == null) {
             return DEFAULT_BOOST;
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PreparedQueryImpl.java Tue Oct 30 03:02:41 2007
@@ -26,7 +26,7 @@
 import org.apache.jackrabbit.core.query.qom.OrderingImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.ItemManager;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.lucene.search.Query;
 
 import javax.jcr.Value;
@@ -50,12 +50,12 @@
     private final QueryObjectModelTree qomTree;
 
     /**
-     * Set&lt;QName>, where QName is a variable name in the QOM tree.
+     * Set&lt;Name>, where Name is a variable name in the QOM tree.
      */
     private final Set variableNames = new HashSet();
 
     /**
-     * Binding of variable name to value. Maps {@link QName} to {@link Value}.
+     * Binding of variable name to value. Maps {@link Name} to {@link Value}.
      */
     private final Map bindValues = new HashMap();
 
@@ -108,19 +108,19 @@
                 propReg, index.getSynonymProvider(), bindValues);
 
         ColumnImpl[] columns = qomTree.getColumns();
-        QName[] selectProps = new QName[columns.length];
+        Name[] selectProps = new Name[columns.length];
         for (int i = 0; i < columns.length; i++) {
             selectProps[i] = columns[i].getPropertyQName();
         }
         OrderingImpl[] orderings = qomTree.getOrderings();
         // TODO: there are many kinds of DynamicOperand that can be ordered by
-        QName[] orderProps = new QName[orderings.length];
+        Name[] orderProps = new Name[orderings.length];
         boolean[] orderSpecs = new boolean[orderings.length];
         for (int i = 0; i < orderings.length; i++) {
             orderSpecs[i] = orderings[i].getOrder() == QueryObjectModelConstants.ORDER_ASCENDING;
         }
         return new QueryResultImpl(index, itemMgr,
-                session.getNamespaceResolver(), session.getAccessManager(),
+                session.getNamePathResolver(), session.getAccessManager(),
                 // TODO: spell suggestion missing
                 this, query, null, selectProps, orderProps, orderSpecs,
                 getRespectDocumentOrder(), offset, limit);
@@ -138,7 +138,7 @@
      *                                  variable in this query.
      * @throws RepositoryException      if an error occurs.
      */
-    public void bindValue(QName varName, Value value)
+    public void bindValue(Name varName, Value value)
             throws IllegalArgumentException, RepositoryException {
         if (!variableNames.contains(varName)) {
             throw new IllegalArgumentException("not a valid variable in this query");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=590014&r1=590013&r2=590014&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java Tue Oct 30 03:02:41 2007
@@ -31,7 +31,8 @@
 import org.apache.jackrabbit.core.query.QueryRootNode;
 import org.apache.jackrabbit.core.query.AndQueryNode;
 import org.apache.jackrabbit.core.query.QueryNodeFactory;
-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;
 import org.apache.lucene.search.Query;
@@ -88,7 +89,7 @@
         // parse query according to language
         // build query tree using the passed factory
         this.root = QueryParser.parse(statement, language,
-                session.getNamespaceResolver(), factory);
+                session.getNamePathResolver(), factory);
         allNodesQueryNode = createMatchAllNodesQuery(factory);
     }
     
@@ -108,8 +109,8 @@
         // check for special query
         if (allNodesQueryNode.equals(root)) {
             return new WorkspaceTraversalResult(session,
-                    new QName[] { QName.JCR_PRIMARYTYPE, QName.JCR_PATH, QName.JCR_SCORE },
-                    session.getNamespaceResolver());
+                    new Name[] { NameConstants.JCR_PRIMARYTYPE, NameConstants.JCR_PATH, NameConstants.JCR_SCORE },
+                    session.getNamePathResolver());
         }
 
         // build lucene query
@@ -127,7 +128,7 @@
         } else {
             orderSpecs = new OrderQueryNode.OrderSpec[0];
         }
-        QName[] orderProperties = new QName[orderSpecs.length];
+        Name[] orderProperties = new Name[orderSpecs.length];
         boolean[] ascSpecs = new boolean[orderSpecs.length];
         for (int i = 0; i < orderSpecs.length; i++) {
             orderProperties[i] = orderSpecs[i].getProperty();
@@ -135,7 +136,7 @@
         }
 
         return new QueryResultImpl(index, itemMgr,
-                session.getNamespaceResolver(), session.getAccessManager(),
+                session.getNamePathResolver(), session.getAccessManager(),
                 this, query, new SpellSuggestion(index.getSpellChecker(), root),
                 getSelectProperties(), orderProperties, ascSpecs,
                 getRespectDocumentOrder(), offset, limit);
@@ -147,14 +148,14 @@
      * @return array of select property names.
      * @throws RepositoryException if an error occurs.
      */
-    protected QName[] getSelectProperties() throws RepositoryException {
+    protected Name[] getSelectProperties() throws RepositoryException {
         // get select properties
         List selectProps = new ArrayList();
         selectProps.addAll(Arrays.asList(root.getSelectProperties()));
         if (selectProps.size() == 0) {
             // use node type constraint
             LocationStepQueryNode[] steps = root.getLocationNode().getPathSteps();
-            final QName[] ntName = new QName[1];
+            final Name[] ntName = new Name[1];
             steps[steps.length - 1].acceptOperands(new DefaultQueryNodeVisitor() {
 
                 public Object visit(AndQueryNode node, Object data) {
@@ -167,7 +168,7 @@
                 }
             }, null);
             if (ntName[0] == null) {
-                ntName[0] = QName.NT_BASE;
+                ntName[0] = NameConstants.NT_BASE;
             }
             NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
             PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
@@ -180,14 +181,14 @@
         }
 
         // add jcr:path and jcr:score if not selected already
-        if (!selectProps.contains(QName.JCR_PATH)) {
-            selectProps.add(QName.JCR_PATH);
+        if (!selectProps.contains(NameConstants.JCR_PATH)) {
+            selectProps.add(NameConstants.JCR_PATH);
         }
-        if (!selectProps.contains(QName.JCR_SCORE)) {
-            selectProps.add(QName.JCR_SCORE);
+        if (!selectProps.contains(NameConstants.JCR_SCORE)) {
+            selectProps.add(NameConstants.JCR_SCORE);
         }
 
-        return (QName[]) selectProps.toArray(new QName[selectProps.size()]);
+        return (Name[]) selectProps.toArray(new Name[selectProps.size()]);
     }
     
     /**



Mime
View raw message