jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r295040 - in /incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/ java/org/apache/jackrabbit/core/nodetype/ java/org/apache/jackrabbit/core/nodetype/virtual/ java/org/apache/jackrabbit/core/nodetype/xml/ java/org/apache/jackrab...
Date Wed, 05 Oct 2005 17:11:34 GMT
Author: jukka
Date: Wed Oct  5 10:11:17 2005
New Revision: 295040

URL: http://svn.apache.org/viewcvs?rev=295040&view=rev
Log:
Moved QName.WILDCARD back to ItemDef.ANY_NAME
Replaced QName.EMPTY with local QName constants in classes that need it.
Added a special LocationStepQueryNode constructor for matching the root node.
Fixed a problem with QueryResult.getRows() and residual item definitions.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/LocationStepQueryNode.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/sql/JCRSQLQueryBuilder.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/name/QName.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/nodetype/xml/TestAll.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
Wed Oct  5 10:11:17 2005
@@ -40,6 +40,12 @@
 
     private static Logger log = Logger.getLogger(HierarchyManagerImpl.class);
 
+    /**
+     * The parent name returned for orphaned or root nodes.
+     * TODO: Is it proper to use an invalid QName for this.
+     */
+    private static final QName EMPTY_NAME = new QName("", "");
+
     protected final NodeId rootNodeId;
     protected final ItemStateManager provider;
     // used for outputting user-friendly paths and names
@@ -378,7 +384,7 @@
                 if (parentUUID == null) {
                     // this is the root or an orphaned node
                     // FIXME
-                    return QName.EMPTY;
+                    return EMPTY_NAME;
                 }
                 parentState = (NodeState) getItemState(new NodeId(parentUUID));
             } catch (NoSuchItemStateException nsis) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java Wed
Oct  5 10:11:17 2005
@@ -30,6 +30,11 @@
     public static final ItemDef[] EMPTY_ARRAY = new ItemDef[0];
 
     /**
+     * The special wildcard name used as the name of residual item definitions.
+     */
+    public static final QName ANY_NAME = new QName("", "*");
+
+    /**
      * Gets the name of the child item.
      *
      * @return the name of the child item.

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
Wed Oct  5 10:11:17 2005
@@ -30,7 +30,7 @@
     /**
      * The name of the child item.
      */
-    private QName name = QName.WILDCARD;
+    private QName name = ItemDef.ANY_NAME;
 
     /**
      * The name of the declaring node type.
@@ -179,7 +179,7 @@
      * {@inheritDoc}
      */
     public boolean definesResidual() {
-        return name.equals(QName.WILDCARD);
+        return name.equals(ItemDef.ANY_NAME);
     }
 
     //-------------------------------------------< java.lang.Object overrides >

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java
Wed Oct  5 10:11:17 2005
@@ -73,7 +73,17 @@
     }
 
     /**
-     * Gets the <code>QName</code> of the child item.
+     * Checks whether this is a residual item definition.
+     *
+     * @return <code>true</code> if this is a residual item definition  
+     */
+    public boolean definesResidual() {
+        return itemDef.definesResidual();
+    }
+
+    /**
+     * Gets the <code>QName</code> of the child item. It is an error to
+     * call this method if this is a residual item definition.
      *
      * @return the <code>QName</code> of the child item.
      * @see #getName()

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Wed Oct  5 10:11:17 2005
@@ -53,6 +53,13 @@
 
     private static Logger log = Logger.getLogger(NodeTypeRegistry.class);
 
+    /**
+     * The empty name used as the name of the declaring node type of the
+     * root node definion.
+     * TODO: Is it proper to use an invalid QName for this.
+     */
+    private static final QName EMPTY_NAME = new QName("", "");
+
     private static final String BUILTIN_NODETYPES_RESOURCE_PATH =
             "org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml";
     private static final String CUSTOM_NODETYPES_RESOURCE_NAME =
@@ -204,7 +211,7 @@
         NodeDefImpl def = new NodeDefImpl();
 
         // FIXME need a fake declaring node type
-        def.setDeclaringNodeType(QName.EMPTY);
+        def.setDeclaringNodeType(EMPTY_NAME);
         def.setRequiredPrimaryTypes(new QName[] { QName.REP_ROOT });
         def.setDefaultPrimaryType(QName.REP_ROOT);
         def.setMandatory(true);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Wed Oct  5 10:11:17 2005
@@ -199,7 +199,7 @@
         String uuid = calculateStableUUID(ntDef.getName().toString() + "/" + QName.JCR_PROPERTYDEFINITION.toString()
+ "/" + n);
         VirtualNodeState pState = createNodeState(parent, QName.JCR_PROPERTYDEFINITION, uuid,
QName.NT_PROPERTYDEFINITION);
         // add properties
-        if (!propDef.getName().equals(QName.WILDCARD)) {
+        if (!propDef.getName().equals(ItemDef.ANY_NAME)) {
             pState.setPropertyValue(QName.JCR_NAME, InternalValue.create(propDef.getName()));
         }
         pState.setPropertyValue(QName.JCR_AUTOCREATED, InternalValue.create(propDef.isAutoCreated()));
@@ -234,7 +234,7 @@
         String uuid = calculateStableUUID(ntDef.getName().toString() + "/" + QName.JCR_CHILDNODEDEFINITION.toString()
+ "/" + n);
         VirtualNodeState pState = createNodeState(parent, QName.JCR_CHILDNODEDEFINITION,
uuid, QName.NT_CHILDNODEDEFINITION);
         // add properties
-        if (!cnDef.getName().equals(QName.WILDCARD)) {
+        if (!cnDef.getName().equals(ItemDef.ANY_NAME)) {
             pState.setPropertyValue(QName.JCR_NAME, InternalValue.create(cnDef.getName()));
         }
         pState.setPropertyValue(QName.JCR_AUTOCREATED, InternalValue.create(cnDef.isAutoCreated()));

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
Wed Oct  5 10:11:17 2005
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.core.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+import org.apache.jackrabbit.core.nodetype.ItemDef;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeDefImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
@@ -202,7 +203,7 @@
         PropDefImpl def = new PropDefImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
-            def.setName(QName.WILDCARD);
+            def.setName(ItemDef.ANY_NAME);
         } else {
             def.setName(QName.fromJCRName(name, resolver));
         }
@@ -281,7 +282,7 @@
         NodeDefImpl def = new NodeDefImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
-            def.setName(QName.WILDCARD);
+            def.setName(ItemDef.ANY_NAME);
         } else {
             def.setName(QName.fromJCRName(name, resolver));
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/LocationStepQueryNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/LocationStepQueryNode.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/LocationStepQueryNode.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/LocationStepQueryNode.java
Wed Oct  5 10:11:17 2005
@@ -25,7 +25,8 @@
  * /foo  -> descendants = false, nameTest = foo<br>
  * //foo -> descendants = true, nameTest = foo<br>
  * //*   -> descendants = true, nameTest = null<br>
- * /*    -> descendants = false, nameTest = null
+ * /*    -> descendants = false, nameTest = null<br>
+ * /     -> descendants = false, nameTest = ""
  * </code>
  */
 public class LocationStepQueryNode extends NAryQueryNode {
@@ -36,6 +37,13 @@
     /** Constant value to indicate no position index */
     public static final int NONE = Integer.MIN_VALUE + 1;
 
+    /**
+     * The empty name used in matching the root node. This is an implementation
+     * specific constant as the empty name is not a valid JCR name.
+     * TODO: The root location step should be refactored somehow
+     */
+    public static final QName EMPTY_NAME = new QName("", "");
+
     /** Empty <code>QueryNode</code> array for us as return value */
     private static final QueryNode[] EMPTY = new QueryNode[0];
 
@@ -69,6 +77,17 @@
         super(parent);
         this.nameTest = nameTest;
         this.includeDescendants = descendants;
+    }
+
+    /**
+     * Creates a new <code>LocationStepQueryNode</code> that matches only
+     * the empty name (the repository root). The created location step
+     * uses only the child axis.
+     */
+    public LocationStepQueryNode(QueryNode parent) {
+        super(parent);
+        this.nameTest = EMPTY_NAME;
+        this.includeDescendants = false;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
Wed Oct  5 10:11:17 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.query;
 
+import org.apache.jackrabbit.core.nodetype.ItemDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistryListener;
@@ -91,7 +92,7 @@
                 for (int i = 0; i < propDefs.length; i++) {
                     QName name = propDefs[i].getName();
                     int type = propDefs[i].getRequiredType();
-                    if (!QName.WILDCARD.equals(name) && type != PropertyType.UNDEFINED)
{
+                    if (!ItemDef.ANY_NAME.equals(name) && type != PropertyType.UNDEFINED)
{
                         // only remember defined property types
                         TypeMapping[] types = (TypeMapping[]) typeMapping.get(name);
                         if (types == null) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
Wed Oct  5 10:11:17 2005
@@ -216,8 +216,9 @@
             NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
             PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
             for (int i = 0; i < propDefs.length; i++) {
-                if (!propDefs[i].isMultiple()) {
-                    selectProps.add(((PropertyDefinitionImpl) propDefs[i]).getQName());
+                PropertyDefinitionImpl propDef = (PropertyDefinitionImpl) propDefs[i];
+                if (!propDef.definesResidual() && !propDef.isMultiple()) {
+                    selectProps.add(propDef.getQName());
                 }
             }
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/sql/JCRSQLQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/sql/JCRSQLQueryBuilder.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/sql/JCRSQLQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/sql/JCRSQLQueryBuilder.java
Wed Oct  5 10:11:17 2005
@@ -528,7 +528,7 @@
         pathNode.setAbsolute(true);
 
         if (path.equals("/")) {
-            pathNode.addPathStep(new LocationStepQueryNode(pathNode, QName.EMPTY, false));
+            pathNode.addPathStep(new LocationStepQueryNode(pathNode));
             pathConstraints.add(pathNode);
             return;
         }
@@ -539,13 +539,13 @@
             if (names[i].length() == 0) {
                 if (i == 0) {
                     // root
-                    pathNode.addPathStep(new LocationStepQueryNode(pathNode, QName.EMPTY,
false));
+                    pathNode.addPathStep(new LocationStepQueryNode(pathNode));
                 } else {
                     // descendant '//' -> invalid path
                     // todo throw or ignore?
                     // we currently do not throw and add location step for an
                     // empty name (which is basically the root node)
-                    pathNode.addPathStep(new LocationStepQueryNode(pathNode, QName.EMPTY,
false));
+                    pathNode.addPathStep(new LocationStepQueryNode(pathNode));
                 }
             } else {
                 int idx = names[i].indexOf('[');

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
Wed Oct  5 10:11:17 2005
@@ -503,7 +503,7 @@
                     if (queryNode.getType() == QueryNode.TYPE_LOCATION) {
                         QName name = ISO9075.decode(QName.fromJCRName(child.getValue(), resolver));
                         if (name.equals(JCR_ROOT)) {
-                            name = QName.EMPTY;
+                            name = LocationStepQueryNode.EMPTY_NAME;
                         }
                         ((LocationStepQueryNode) queryNode).setNameTest(name);
                     } else if (queryNode.getType() == QueryNode.TYPE_DEREF) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/name/QName.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/name/QName.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/name/QName.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/name/QName.java Wed Oct  5 10:11:17
2005
@@ -107,16 +107,6 @@
     //------------------------------------------< general item name constants >
 
     /**
-     * Empty name
-     */
-    public static final QName EMPTY = new QName(NS_DEFAULT_URI, "");
-
-    /**
-     * Wildcard name
-     */
-    public static final QName WILDCARD = new QName(NS_DEFAULT_URI, "*");
-
-    /**
      * jcr:system
      */
     public static final QName JCR_SYSTEM = new QName(NS_JCR_URI, "system");

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/nodetype/xml/TestAll.java?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
Wed Oct  5 10:11:17 2005
@@ -19,6 +19,7 @@
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+import org.apache.jackrabbit.core.nodetype.ItemDef;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.PropDef;
@@ -200,7 +201,7 @@
                 10, def.getPropertyDefs().length);
         PropDef[] defs = def.getPropertyDefs();
         assertEquals("itemNodeType wildcard property",
-                QName.WILDCARD, defs[0].getName());
+                ItemDef.ANY_NAME, defs[0].getName());
     }
 
     /** Test for the empty item definition. */



Mime
View raw message