jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r161308 [1/2] - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ./ nodetype/ nodetype/xml/ state/ version/ version/persistence/ virtual/ xml/
Date Thu, 14 Apr 2005 15:39:50 GMT
Author: tripod
Date: Thu Apr 14 08:39:43 2005
New Revision: 161308

URL: http://svn.apache.org/viewcvs?view=rev&rev=161308
Log:
- PropDef and NodeDef adaptions
- adjusting to 0.16.4

Added:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java   (with props)
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java   (with props)
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java   (with props)
Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Constants.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/InternalValue.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDef.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefinitionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDef.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/Constants.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/PropertyState.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryNodeState.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Constants.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Constants.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Constants.java Thu Apr 14 08:39:43 2005
@@ -191,6 +191,11 @@
      */
     public static final QName JCR_ROOTVERSION = new QName(NS_JCR_URI, "rootVersion");
 
+    /**
+     * jcr:versionableUuid
+     */
+    public static final QName JCR_VERSIONABLEUUID = new QName(NS_JCR_URI, "versionableUuid");
+
     //--------------------------------------< node type item name constants >---
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/InternalValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/InternalValue.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/InternalValue.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/InternalValue.java Thu Apr 14 08:39:43 2005
@@ -60,6 +60,8 @@
  */
 public class InternalValue {
 
+    public static final InternalValue[] EMPTY = new InternalValue[0];
+
     private final Object val;
     private final int type;
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java Thu Apr 14 08:39:43 2005
@@ -175,7 +175,7 @@
             NodeState parentState = (NodeState) parent.getItemState();
             NodeState.ChildNodeEntry cne = (NodeState.ChildNodeEntry) parentState.getChildNodeEntries(state.getUUID()).get(0);
             def = parent.getApplicableChildNodeDefinition(cne.getName(), state.getNodeTypeName());
-            state.setDefinitionId(new NodeDefId(def.unwrap()));
+            state.setDefinitionId(def.unwrap().getId());
         }
         return def;
     }
@@ -191,7 +191,7 @@
             NodeId parentId = new NodeId(state.getParentUUID());
             NodeImpl parent = (NodeImpl) getItem(parentId);
             def = parent.getApplicablePropertyDefinition(state.getName(), state.getType(), state.isMultiValued());
-            state.setDefinitionId(new PropDefId(def.unwrap()));
+            state.setDefinitionId(def.unwrap().getId());
         }
         return def;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java Thu Apr 14 08:39:43 2005
@@ -29,7 +29,7 @@
         if (uuid == null) {
             throw new IllegalArgumentException("uuid can not be null");
         }
-        this.uuid = uuid;
+        this.uuid = uuid.intern();
     }
 
     /**
@@ -49,7 +49,7 @@
         }
         if (obj instanceof NodeId) {
             NodeId other = (NodeId) obj;
-            return uuid.equals(other.uuid);
+            return uuid == other.uuid;
         }
         return false;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Thu Apr 14 08:39:43 2005
@@ -26,7 +26,6 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -440,7 +439,7 @@
             propState = stateMgr.createTransientPropertyState(parentUUID, name, ItemState.STATUS_NEW);
             propState.setType(type);
             propState.setMultiValued(def.isMultiple());
-            propState.setDefinitionId(new PropDefId(def.unwrap()));
+            propState.setDefinitionId(def.unwrap().getId());
             // compute system generated values if necessary
             InternalValue[] genValues =
                     computeSystemGeneratedPropertyValues(name, def);
@@ -478,7 +477,7 @@
                 uuid = UUID.randomUUID().toString();	// version 4 uuid
             }
             nodeState = stateMgr.createTransientNodeState(uuid, nodeType.getQName(), parentUUID, ItemState.STATUS_NEW);
-            nodeState.setDefinitionId(new NodeDefId(def.unwrap()));
+            nodeState.setDefinitionId(def.unwrap().getId());
         } catch (ItemStateException ise) {
             String msg = "failed to add child node " + name + " to " + safeGetJCRPath();
             log.debug(msg);
@@ -823,7 +822,7 @@
                                                                   QName nodeTypeName)
             throws ConstraintViolationException, RepositoryException {
         NodeDef cnd = getEffectiveNodeType().getApplicableChildNodeDef(nodeName, nodeTypeName);
-        return session.getNodeTypeManager().getNodeDefinition(new NodeDefId(cnd));
+        return session.getNodeTypeManager().getNodeDefinition(cnd.getId());
     }
 
     /**
@@ -843,7 +842,7 @@
                                                                      boolean multiValued)
             throws ConstraintViolationException, RepositoryException {
         PropDef pd = getEffectiveNodeType().getApplicablePropertyDef(propertyName, type, multiValued);
-        return session.getNodeTypeManager().getPropertyDefinition(new PropDefId(pd));
+        return session.getNodeTypeManager().getPropertyDefinition(pd.getId());
     }
 
     protected void makePersistent() {
@@ -2673,7 +2672,7 @@
         prop.save();
         prop = internalSetProperty(JCR_BASEVERSION, InternalValue.create(new UUID(v.getUUID())));
         prop.save();
-        prop = internalSetProperty(JCR_PREDECESSORS, new InternalValue[0], PropertyType.REFERENCE);
+        prop = internalSetProperty(JCR_PREDECESSORS, InternalValue.EMPTY, PropertyType.REFERENCE);
         prop.save();
         return v;
     }
@@ -2791,7 +2790,7 @@
         checkLock();
 
         // check if 'own' version
-        if (!((VersionImpl) version).getContainingHistory().isSame(getVersionHistory())) {
+        if (!version.getContainingHistory().isSame(getVersionHistory())) {
             throw new VersionException("Unable to restore version. Not same version history.");
         }
 
@@ -3482,7 +3481,7 @@
         internalSetProperty(JCR_BASEVERSION, InternalValue.create(new UUID(version.getId())));
 
         // 4. N's jcr:predecessor property is set to null
-        internalSetProperty(JCR_PREDECESSORS, new InternalValue[0], PropertyType.REFERENCE);
+        internalSetProperty(JCR_PREDECESSORS, InternalValue.EMPTY, PropertyType.REFERENCE);
 
         // also clear mergeFailed
         internalSetProperty(JCR_MERGEFAILED, (InternalValue[]) null);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java Thu Apr 14 08:39:43 2005
@@ -33,7 +33,7 @@
         if (propName == null) {
             throw new IllegalArgumentException("propName can not be null");
         }
-        this.parentUUID = parentUUID;
+        this.parentUUID = parentUUID.intern();
         this.propName = propName;
     }
 
@@ -58,7 +58,7 @@
         }
         if (obj instanceof PropertyId) {
             PropertyId other = (PropertyId) obj;
-            return parentUUID.equals(other.parentUUID)
+            return parentUUID == other.parentUUID
                     && propName.equals(other.propName);
         }
         return false;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java Thu Apr 14 08:39:43 2005
@@ -907,8 +907,8 @@
                 srcName.getIndex() == 0 ? 1 : srcName.getIndex());
         // change definition of target if necessary
         NodeDefinitionImpl oldTargetDef = (NodeDefinitionImpl) targetNode.getDefinition();
-        NodeDefId oldTargetDefId = new NodeDefId(oldTargetDef.unwrap());
-        NodeDefId newTargetDefId = new NodeDefId(newTargetDef.unwrap());
+        NodeDefId oldTargetDefId = oldTargetDef.unwrap().getId();
+        NodeDefId newTargetDefId = newTargetDef.unwrap().getId();
         if (!oldTargetDefId.equals(newTargetDefId)) {
             targetNode.onRedefine(newTargetDefId);
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java Thu Apr 14 08:39:43 2005
@@ -1225,7 +1225,7 @@
             NodeDef newNodeDef =
                     findApplicableNodeDefinition(destName.getName(),
                             srcState.getNodeTypeName(), destParentState);
-            newState.setDefinitionId(new NodeDefId(newNodeDef));
+            newState.setDefinitionId(newNodeDef.getId());
 
             // adjust references that refer to uuid's which have been mapped to
             // newly generated uuid's on copy/clone
@@ -1521,7 +1521,7 @@
             NodeDef newTargetDef =
                     findApplicableNodeDefinition(destName.getName(),
                             targetState.getNodeTypeName(), destParentState);
-            targetState.setDefinitionId(new NodeDefId(newTargetDef));
+            targetState.setDefinitionId(newTargetDef.getId());
 
             // remove from old parent
             if (!renameOnly) {

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?view=diff&r1=161307&r2=161308
==============================================================================
--- 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 Thu Apr 14 08:39:43 2005
@@ -16,107 +16,64 @@
  */
 package org.apache.jackrabbit.core.nodetype;
 
-import org.apache.jackrabbit.core.Constants;
 import org.apache.jackrabbit.core.QName;
-
-import javax.jcr.version.OnParentVersionAction;
+import org.apache.jackrabbit.core.Constants;
 
 /**
- * An <code>ItemDef</code> ...
+ * This interface define the base for item definitions.
  */
-public abstract class ItemDef implements Cloneable {
-
-    // '*' denoting residual child item definition
-    public static final QName ANY_NAME =
-            new QName(Constants.NS_DEFAULT_URI, "*");
-
-    protected QName declaringNodeType = null;
-    private QName name = ANY_NAME;
-    private boolean autoCreated = false;
-    private int onParentVersion = OnParentVersionAction.COPY;
-    private boolean writeProtected = false;
-    private boolean mandatory = false;
-
-    protected Object clone() throws CloneNotSupportedException {
-        // delegate to superclass which does a shallow copy;
-        // but since all fields are either primitives or immutables
-        // this is sufficient
-        return super.clone();
-    }
-
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof ItemDef) {
-            ItemDef other = (ItemDef) obj;
-            return (declaringNodeType == null ? other.declaringNodeType == null : declaringNodeType.equals(other.declaringNodeType))
-                    && (name == null ? other.name == null : name.equals(other.name))
-                    && autoCreated == other.autoCreated
-                    && onParentVersion == other.onParentVersion
-                    && writeProtected == other.writeProtected
-                    && mandatory == other.mandatory;
-        }
-        return false;
-    }
-
-    public void setDeclaringNodeType(QName declaringNodeType) {
-        if (declaringNodeType == null) {
-            throw new IllegalArgumentException("declaringNodeType can not be null");
-        }
-        this.declaringNodeType = declaringNodeType;
-    }
-
-    public void setName(QName name) {
-        if (name == null) {
-            throw new IllegalArgumentException("name can not be null");
-        }
-        this.name = name;
-    }
-
-    public void setAutoCreated(boolean autoCreated) {
-        this.autoCreated = autoCreated;
-    }
-
-    public void setOnParentVersion(int onParentVersion) {
-        this.onParentVersion = onParentVersion;
-    }
-
-    public void setProtected(boolean writeProtected) {
-        this.writeProtected = writeProtected;
-    }
-
-    public void setMandatory(boolean mandatory) {
-        this.mandatory = mandatory;
-    }
-
-    public QName getDeclaringNodeType() {
-        return declaringNodeType;
-    }
-
-    public QName getName() {
-        return name;
-    }
-
-    public boolean isAutoCreated() {
-        return autoCreated;
-    }
-
-    public int getOnParentVersion() {
-        return onParentVersion;
-    }
-
-    public boolean isProtected() {
-        return writeProtected;
-    }
-
-    public boolean isMandatory() {
-        return mandatory;
-    }
-
-    public boolean definesResidual() {
-        return name.equals(ANY_NAME);
-    }
+public interface ItemDef  {
 
-    public abstract boolean definesNode();
+    /**
+     * '*' denoting residual child item definition
+     */
+    public static final QName ANY_NAME = new QName(Constants.NS_DEFAULT_URI, "*");
+
+    /**
+     * Returns the name of this item def.
+     * @return the name of this item def.
+     */
+    public QName getName();
+
+    /**
+     * Returns the name of the declaring node type.
+     * @return the name of the declaring node type.
+     */
+    public QName getDeclaringNodeType();
+
+    /**
+     * Returns the auto created flag.
+     * @return the auto created flag.
+     */
+    public boolean isAutoCreated();
+
+    /**
+     * Returns the on-parent-version attribute.
+     * @return the on-parent-version attribute.
+     */
+    public int getOnParentVersion();
+
+    /**
+     * Returns the protected flag.
+     * @return the protected flag.
+     */
+    public boolean isProtected();
+
+    /**
+     * Returns the mandatory flag.
+     * @return the mandatory flag.
+     */
+    public boolean isMandatory();
+
+    /**
+     * Returns if this is a residual definition.
+     * @return if this is a residual definition.
+     */
+    public boolean definesResidual();
+
+    /**
+     * Returns if this is a node definition.
+     * @return if this is a node definition.
+     */
+    public boolean definesNode();
 }

Added: 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?view=auto&rev=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java (added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java Thu Apr 14 08:39:43 2005
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.nodetype;
+
+import org.apache.jackrabbit.core.QName;
+
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * This class is an abstract imlementation for the ChildItemDef interface and
+ * hold the generic item def attributes.
+ */
+public abstract class ItemDefImpl implements ItemDef {
+
+    /**
+     * the name of this item def
+     */
+    private QName name = ANY_NAME;
+
+    /**
+     * the name of the declaring node type
+     */
+    protected QName declaringNodeType = null;
+
+    /**
+     * 'autocreate' flag
+     */
+    private boolean autoCreated = false;
+
+    /**
+     * on parent version attribute
+     */
+    private int onParentVersion = OnParentVersionAction.COPY;
+
+    /**
+     * write protected flag
+     */
+    private boolean writeProtected = false;
+
+    /**
+     * mandatory flag
+     */
+    private boolean mandatory = false;
+
+    /**
+     * Sets the declaring node type.
+     * @param declaringNodeType
+     */
+    public void setDeclaringNodeType(QName declaringNodeType) {
+        if (declaringNodeType == null) {
+            throw new IllegalArgumentException("declaringNodeType can not be null");
+        }
+        this.declaringNodeType = declaringNodeType;
+    }
+
+    /**
+     * Sets the name
+     * @param name
+     */
+    public void setName(QName name) {
+        if (name == null) {
+            throw new IllegalArgumentException("name can not be null");
+        }
+        this.name = name;
+    }
+
+    /**
+     * Sets the auto create flag
+     * @param autoCreated
+     */
+    public void setAutoCreated(boolean autoCreated) {
+        this.autoCreated = autoCreated;
+    }
+
+    /**
+     * Sets the on parent version
+     * @param onParentVersion
+     */
+    public void setOnParentVersion(int onParentVersion) {
+        this.onParentVersion = onParentVersion;
+    }
+
+    /**
+     * Sets the protected flag
+     * @param writeProtected
+     */
+    public void setProtected(boolean writeProtected) {
+        this.writeProtected = writeProtected;
+    }
+
+    /**
+     * sets the mandatory flag
+     * @param mandatory
+     */
+    public void setMandatory(boolean mandatory) {
+        this.mandatory = mandatory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDeclaringNodeType() {
+        return declaringNodeType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isAutoCreated() {
+        return autoCreated;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isProtected() {
+        return writeProtected;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean definesResidual() {
+        return name.equals(ANY_NAME);
+    }
+
+    /**
+     * checks if this child item def is equal to the given one. two itemdefs
+     * are equal if they are the same object or if all their attributes are
+     * equal.
+     *
+     * @param obj the object to compare to
+     * @return <code>true</code> if this item def is equal to obj;
+     *         <code>false</code> otherwise.
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof ItemDefImpl) {
+            ItemDefImpl other = (ItemDefImpl) obj;
+            return (declaringNodeType == null ? other.declaringNodeType == null : declaringNodeType.equals(other.declaringNodeType))
+                    && (name == null ? other.name == null : name.equals(other.name))
+                    && autoCreated == other.autoCreated
+                    && onParentVersion == other.onParentVersion
+                    && writeProtected == other.writeProtected
+                    && mandatory == other.mandatory;
+        }
+        return false;
+    }
+
+
+}

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ItemDefImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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?view=diff&r1=161307&r2=161308
==============================================================================
--- 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 Thu Apr 14 08:39:43 2005
@@ -21,24 +21,39 @@
 import org.apache.jackrabbit.core.QName;
 import org.apache.log4j.Logger;
 
-import javax.jcr.nodetype.ItemDefinition;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.ItemDefinition;
 
 /**
- * An <code>ItemDefinitionImpl</code> ...
+ * this class implements the ItemDef interface
  */
 abstract class ItemDefinitionImpl implements ItemDefinition {
 
-    private static Logger log = Logger.getLogger(ItemDefinitionImpl.class);
+    /**
+     * the default logger
+     */
+    private static Logger log = Logger.getLogger(ItemDefImpl.class);
 
+    /**
+     * Literal for 'any name'
+     */
     protected static final String ANY_NAME = "*";
 
+    /**
+     * the node type manager of this session
+     */
     protected final NodeTypeManagerImpl ntMgr;
-    // namespace resolver used to translate qualified names to JCR names
+
+    /**
+     * namespace resolver used to translate qualified names to JCR names
+     */
     protected final NamespaceResolver nsResolver;
 
-    private final ItemDef itemDef;
+    /**
+     * the underlaying child item def
+     */
+    protected final ItemDef itemDef;
 
     /**
      * Package private constructor
@@ -47,13 +62,17 @@
      * @param ntMgr      node type manager
      * @param nsResolver namespace resolver
      */
-    ItemDefinitionImpl(ItemDef itemDef, NodeTypeManagerImpl ntMgr,
-                       NamespaceResolver nsResolver) {
+    ItemDefinitionImpl(ItemDef itemDef, NodeTypeManagerImpl ntMgr, NamespaceResolver nsResolver) {
         this.itemDef = itemDef;
         this.ntMgr = ntMgr;
         this.nsResolver = nsResolver;
     }
 
+    /**
+     * Returns the qname of this item def
+     *
+     * @return
+     */
     public QName getQName() {
         return itemDef.getName();
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDef.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDef.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDef.java Thu Apr 14 08:39:43 2005
@@ -16,89 +16,35 @@
  */
 package org.apache.jackrabbit.core.nodetype;
 
-import org.apache.jackrabbit.core.Constants;
 import org.apache.jackrabbit.core.QName;
 
-import java.util.Arrays;
-
 /**
- * A <code>NodeDef</code> ...
+ * This interface define a ChilsNodeDefinition
  */
-public class NodeDef extends ItemDef {
-
-    private QName defaultPrimaryType = null;
-    private QName[] requiredPrimaryTypes = new QName[]{Constants.NT_BASE};
-    private boolean allowsSameNameSiblings = false;
-
-    /**
-     * Default constructor.
-     */
-    public NodeDef() {
-    }
-
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof NodeDef) {
-            NodeDef other = (NodeDef) obj;
-            return super.equals(obj)
-                    && Arrays.equals(requiredPrimaryTypes, other.requiredPrimaryTypes)
-                    && (defaultPrimaryType == null ? other.defaultPrimaryType == null : defaultPrimaryType.equals(other.defaultPrimaryType))
-                    && allowsSameNameSiblings == other.allowsSameNameSiblings;
-        }
-        return false;
-    }
-
-    /**
-     * @param defaultNodeType
-     */
-    public void setDefaultPrimaryType(QName defaultNodeType) {
-        this.defaultPrimaryType = defaultNodeType;
-    }
+public interface NodeDef extends ItemDef {
 
     /**
-     * @param requiredPrimaryTypes
+     * Returns the nodedef id of this node def.
+     * @return the node def id.
      */
-    public void setRequiredPrimaryTypes(QName[] requiredPrimaryTypes) {
-        if (requiredPrimaryTypes == null) {
-            throw new IllegalArgumentException("requiredPrimaryTypes can not be null");
-        }
-        this.requiredPrimaryTypes = requiredPrimaryTypes;
-    }
+    public NodeDefId getId();
 
     /**
-     * @param allowsSameNameSiblings
+     * Returns the name of the default primary type.
+     * @return the name of the default primary type.
      */
-    public void setAllowsSameNameSiblings(boolean allowsSameNameSiblings) {
-        this.allowsSameNameSiblings = allowsSameNameSiblings;
-    }
+    public QName getDefaultPrimaryType();
 
     /**
-     * @return
+     * Returns the array of names of the required primary types.
+     * @return the array of names of the required primary types.
      */
-    public QName getDefaultPrimaryType() {
-        return defaultPrimaryType;
-    }
+    public QName[] getRequiredPrimaryTypes();
 
     /**
-     * @return
+     * Returns the 'allowSameNameSiblings' flag.
+     * @return the 'allowSameNameSiblings' flag.
      */
-    public QName[] getRequiredPrimaryTypes() {
-        return requiredPrimaryTypes;
-    }
+    public boolean allowsSameNameSiblings();
 
-    /**
-     * @return
-     */
-    public boolean allowsSameNameSiblings() {
-        return allowsSameNameSiblings;
-    }
-
-    /**
-     * @return
-     */
-    public boolean definesNode() {
-        return true;
-    }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java Thu Apr 14 08:39:43 2005
@@ -27,11 +27,21 @@
  */
 public class NodeDefId implements Serializable {
 
+    /**
+     * the serial number
+     */
     static final long serialVersionUID = 7020286139887664713L;
 
+    /**
+     * the internal id
+     */
     private final int id;
 
-    public NodeDefId(NodeDef def) {
+    /**
+     * Creates a new NodeDefId from the given NodeDef
+     * @param def
+     */
+    NodeDefId(NodeDefImpl def) {
         if (def == null) {
             throw new IllegalArgumentException("NodeDef argument can not be null");
         }
@@ -57,6 +67,10 @@
         id = sb.toString().hashCode();
     }
 
+    /**
+     * Private constructor that creates an NodeDefId from an internal id
+     * @param id
+     */
     private NodeDefId(int id) {
         this.id = id;
     }
@@ -80,6 +94,9 @@
         return new NodeDefId(Integer.parseInt(s));
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
@@ -91,10 +108,16 @@
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return Integer.toString(id);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         // id is already the computed hash code
         return id;

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java?view=auto&rev=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java (added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java Thu Apr 14 08:39:43 2005
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.nodetype;
+
+import org.apache.jackrabbit.core.Constants;
+import org.apache.jackrabbit.core.QName;
+
+import java.util.Arrays;
+
+/**
+ * This class implements the ChildNodeDef interface. It basically holds the
+ * respective attributes.
+ */
+public class NodeDefImpl extends ItemDefImpl implements NodeDef {
+
+    /**
+     * the name of the default primary type
+     */
+    private QName defaultPrimaryType = null;
+
+    /**
+     * the names of the required primary types
+     */
+    private QName[] requiredPrimaryTypes = new QName[]{Constants.NT_BASE};
+
+    /**
+     * the 'allowSameNameSibs' flag.
+     */
+    private boolean allowsSameNameSiblings = false;
+
+    /**
+     * the node def id. Set after 'compile'
+     */
+    private NodeDefId id;
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDeclaringNodeType(QName declaringNodeType) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setDeclaringNodeType(declaringNodeType);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setName(QName name) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setName(name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setAutoCreate(boolean autoCreated) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setAutoCreated(autoCreated);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setOnParentVersion(int onParentVersion) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setOnParentVersion(onParentVersion);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setProtected(boolean writeProtected) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setProtected(writeProtected);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setMandatory(boolean mandatory) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        super.setMandatory(mandatory);
+    }
+
+    /**
+     * Sets the name of default primary type
+     *
+     * @param defaultNodeType
+     */
+    public void setDefaultPrimaryType(QName defaultNodeType) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        this.defaultPrimaryType = defaultNodeType;
+    }
+
+    /**
+     * Sets the names of the required primary types
+     *
+     * @param requiredPrimaryTypes
+     */
+    public void setRequiredPrimaryTypes(QName[] requiredPrimaryTypes) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        if (requiredPrimaryTypes == null) {
+            throw new IllegalArgumentException("requiredPrimaryTypes can not be null");
+        }
+        this.requiredPrimaryTypes = requiredPrimaryTypes;
+    }
+
+    /**
+     * sets the 'allowsSameNameSiblings' flag
+     *
+     * @param allowsSameNameSiblings
+     */
+    public void setAllowsSameNameSiblings(boolean allowsSameNameSiblings) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. ChildNodeDef already compiled.");
+        }
+        this.allowsSameNameSiblings = allowsSameNameSiblings;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QName[] getRequiredPrimaryTypes() {
+        return requiredPrimaryTypes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeDefId getId() {
+        if (id == null) {
+            id = new NodeDefId(this);
+        }
+        return id;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean definesNode() {
+        return true;
+    }
+
+    /**
+     * checks if this child node def is equal to the given one.
+     * @param obj the other object to compare to.
+     * @return <code>true</code> if equal; <code>false</code> otherwise.
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof NodeDefImpl) {
+            NodeDefImpl other = (NodeDefImpl) obj;
+            return super.equals(obj)
+                    && Arrays.equals(requiredPrimaryTypes, other.requiredPrimaryTypes)
+                    && (defaultPrimaryType == null ? other.defaultPrimaryType == null : defaultPrimaryType.equals(other.defaultPrimaryType))
+                    && allowsSameNameSiblings == other.allowsSameNameSiblings;
+        }
+        return false;
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefinitionImpl.java Thu Apr 14 08:39:43 2005
@@ -22,19 +22,18 @@
 import org.apache.log4j.Logger;
 
 import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeDefinition;
 
 /**
- * A <code>NodeDefinitionImpl</code> ...
+ * This class implements the NodeDef interface.
  */
-public class NodeDefinitionImpl extends ItemDefinitionImpl
-        implements NodeDefinition {
-
-    private static Logger log = Logger.getLogger(NodeDefinitionImpl.class);
-
-    private final NodeDef nodeDef;
+public class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition {
 
+    /**
+     * the default logger
+     */
+    private static Logger log = Logger.getLogger(NodeDefImpl.class);
 
     /**
      * Package private constructor
@@ -44,13 +43,16 @@
      * @param nsResolver namespace resolver
      */
     NodeDefinitionImpl(NodeDef nodeDef, NodeTypeManagerImpl ntMgr,
-                       NamespaceResolver nsResolver) {
+                NamespaceResolver nsResolver) {
         super(nodeDef, ntMgr, nsResolver);
-        this.nodeDef = nodeDef;
     }
 
+    /**
+     * Returns the underlaying item def
+     * @return
+     */
     public NodeDef unwrap() {
-        return nodeDef;
+        return (NodeDef) itemDef;
     }
 
     //--------------------------------------------------------------< NodeDef >
@@ -58,7 +60,7 @@
      * {@inheritDoc}
      */
     public NodeType getDefaultPrimaryType() {
-        QName ntName = nodeDef.getDefaultPrimaryType();
+        QName ntName = ((NodeDef) itemDef).getDefaultPrimaryType();
         if (ntName == null) {
             return null;
         }
@@ -75,7 +77,7 @@
      * {@inheritDoc}
      */
     public NodeType[] getRequiredPrimaryTypes() {
-        QName[] ntNames = nodeDef.getRequiredPrimaryTypes();
+        QName[] ntNames = ((NodeDef) itemDef).getRequiredPrimaryTypes();
         try {
             if (ntNames == null || ntNames.length == 0) {
                 // return "nt:base"
@@ -98,7 +100,7 @@
      * {@inheritDoc}
      */
     public boolean allowsSameNameSiblings() {
-        return nodeDef.allowsSameNameSiblings();
+        return ((NodeDef) itemDef).allowsSameNameSiblings();
     }
 }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefDiff.java Thu Apr 14 08:39:43 2005
@@ -239,13 +239,13 @@
         PropDef[] pda1 = oldDef.getPropertyDefs();
         HashMap defs1 = new HashMap();
         for (int i = 0; i < pda1.length; i++) {
-            defs1.put(new PropDefId(pda1[i]), pda1[i]);
+            defs1.put(pda1[i].getId(), pda1[i]);
         }
 
         PropDef[] pda2 = newDef.getPropertyDefs();
         HashMap defs2 = new HashMap();
         for (int i = 0; i < pda2.length; i++) {
-            defs2.put(new PropDefId(pda2[i]), pda2[i]);
+            defs2.put(pda2[i].getId(), pda2[i]);
         }
 
         /**
@@ -296,13 +296,13 @@
         NodeDef[] cnda1 = oldDef.getChildNodeDefs();
         HashMap defs1 = new HashMap();
         for (int i = 0; i < cnda1.length; i++) {
-            defs1.put(new NodeDefId(cnda1[i]), cnda1[i]);
+            defs1.put(cnda1[i].getId(), cnda1[i]);
         }
 
         NodeDef[] cnda2 = newDef.getChildNodeDefs();
         HashMap defs2 = new HashMap();
         for (int i = 0; i < cnda1.length; i++) {
-            defs2.put(new NodeDefId(cnda2[i]), cnda2[i]);
+            defs2.put(cnda2[i].getId(), cnda2[i]);
         }
 
         /**
@@ -478,7 +478,7 @@
                     }
                     boolean b1 = getOldDef().isMultiple();
                     boolean b2 = getNewDef().isMultiple();
-                    if (b1 != b1) {
+                    if (b1 != b2) {
                         if (b2) {
                             // changed multiple flag to true (MINOR change)
                             type = MINOR;
@@ -518,7 +518,7 @@
 
                 boolean b1 = getOldDef().allowsSameNameSiblings();
                 boolean b2 = getNewDef().allowsSameNameSiblings();
-                if (b1 != b1 && !b2) {
+                if (b1 != b2 && !b2) {
                     // changed sameNameSiblings flag to false (MAJOR change)
                     type = MAJOR;
                 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java Thu Apr 14 08:39:43 2005
@@ -103,8 +103,8 @@
     public NodeDefinitionImpl getApplicableChildNodeDefinition(QName nodeName,
                                                                QName nodeTypeName)
             throws RepositoryException {
-        return new NodeDefinitionImpl(ent.getApplicableChildNodeDef(nodeName, nodeTypeName),
-                ntMgr, nsResolver);
+        return ntMgr.getNodeDefinition(
+                ent.getApplicableChildNodeDef(nodeName, nodeTypeName).getId());
     }
 
     /**
@@ -122,9 +122,8 @@
                                                                   int type,
                                                                   boolean multiValued)
             throws RepositoryException {
-        return new PropertyDefinitionImpl(
-                ent.getApplicablePropertyDef(propertyName, type, multiValued),
-                ntMgr, nsResolver);
+        return ntMgr.getPropertyDefinition(
+                ent.getApplicablePropertyDef(propertyName, type, multiValued).getId());
     }
 
     /**
@@ -168,7 +167,7 @@
         NodeDef[] cnda = ent.getAutoCreateNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = new NodeDefinitionImpl(cnda[i], ntMgr, nsResolver);
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
         }
         return nodeDefs;
     }
@@ -186,7 +185,7 @@
         PropDef[] pda = ent.getAutoCreatePropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = new PropertyDefinitionImpl(pda[i], ntMgr, nsResolver);
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
         }
         return propDefs;
     }
@@ -204,7 +203,7 @@
         PropDef[] pda = ent.getMandatoryPropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = new PropertyDefinitionImpl(pda[i], ntMgr, nsResolver);
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
         }
         return propDefs;
     }
@@ -222,7 +221,7 @@
         NodeDef[] cnda = ent.getMandatoryNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = new NodeDefinitionImpl(cnda[i], ntMgr, nsResolver);
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
         }
         return nodeDefs;
     }
@@ -377,7 +376,7 @@
         NodeDef[] cnda = ent.getAllNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = new NodeDefinitionImpl(cnda[i], ntMgr, nsResolver);
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
         }
         return nodeDefs;
     }
@@ -389,7 +388,7 @@
         PropDef[] pda = ent.getAllPropDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = new PropertyDefinitionImpl(pda[i], ntMgr, nsResolver);
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
         }
         return propDefs;
     }
@@ -419,7 +418,7 @@
         NodeDef[] cnda = ntd.getChildNodeDefs();
         NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
         for (int i = 0; i < cnda.length; i++) {
-            nodeDefs[i] = new NodeDefinitionImpl(cnda[i], ntMgr, nsResolver);
+            nodeDefs[i] = ntMgr.getNodeDefinition(cnda[i].getId());
         }
         return nodeDefs;
     }
@@ -597,7 +596,7 @@
         PropDef[] pda = ntd.getPropertyDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = new PropertyDefinitionImpl(pda[i], ntMgr, nsResolver);
+            propDefs[i] = ntMgr.getPropertyDefinition(pda[i].getId());
         }
         return propDefs;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Thu Apr 14 08:39:43 2005
@@ -35,18 +35,27 @@
 import java.util.Map;
 
 /**
- * A <code>NodeTypeManagerImpl</code> ...
+ * A <code>NodeTypeManagerImpl</code> implements a session dependant
+ * NodeTypeManager.
  */
 public class NodeTypeManagerImpl implements NodeTypeManager,
         NodeTypeRegistryListener {
 
+    /**
+     * the default logger
+     */
     private static Logger log = Logger.getLogger(NodeTypeManagerImpl.class);
 
+    /**
+     * the underlaying node type registry
+     */
     private final NodeTypeRegistry ntReg;
 
     private final NodeDefinitionImpl rootNodeDef;
 
-    // namespace resolver used to translate qualified names to JCR names
+    /**
+     * namespace resolver used to translate qualified names to JCR names
+     */
     private final NamespaceResolver nsResolver;
 
     /**
@@ -55,6 +64,16 @@
     private final Map ntCache;
 
     /**
+     * A cache for <code>PropertyDef</code> instances created by this <code>NodeTypeManager</code>
+     */
+    private final Map pdCache;
+
+    /**
+     * A cache for <code>NodeDef</code> instances created by this <code>NodeTypeManager</code>
+     */
+    private final Map ndCache;
+
+    /**
      * Constructor.
      */
     public NodeTypeManagerImpl(NodeTypeRegistry ntReg, NamespaceResolver nsResolver) {
@@ -64,9 +83,12 @@
 
         // setup item cache with soft references to node type instances
         ntCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+        pdCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+        ndCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
 
         rootNodeDef = new RootNodeDefinition(ntReg.getRootNodeDef(), this,
                 nsResolver);
+        ndCache.put(rootNodeDef.unwrap().getId(), rootNodeDef);
     }
 
     /**
@@ -81,11 +103,17 @@
      * @return
      */
     public NodeDefinitionImpl getNodeDefinition(NodeDefId id) {
-        NodeDef cnd = ntReg.getNodeDef(id);
-        if (cnd == null) {
-            return null;
+        synchronized (ndCache) {
+            NodeDefinitionImpl nd = (NodeDefinitionImpl) ndCache.get(id);
+            if (nd == null) {
+                NodeDef cnd = ntReg.getNodeDef(id);
+                if (cnd != null) {
+                    nd = new NodeDefinitionImpl(cnd, this, nsResolver);
+                    ndCache.put(id, nd);
+                }
+            }
+            return nd;
         }
-        return new NodeDefinitionImpl(cnd, this, nsResolver);
     }
 
     /**
@@ -93,11 +121,17 @@
      * @return
      */
     public PropertyDefinitionImpl getPropertyDefinition(PropDefId id) {
-        PropDef pd = ntReg.getPropDef(id);
-        if (pd == null) {
-            return null;
+        synchronized (pdCache) {
+            PropertyDefinitionImpl pdi = (PropertyDefinitionImpl) pdCache.get(id);
+            if (pdi == null) {
+                PropDef pd = ntReg.getPropDef(id);
+                if (pd != null) {
+                    pdi = new PropertyDefinitionImpl(pd, this, nsResolver);
+                    pdCache.put(id, pdi);
+                }
+            }
+            return pdi;
         }
-        return new PropertyDefinitionImpl(pd, this, nsResolver);
     }
 
     /**
@@ -105,19 +139,17 @@
      * @return
      * @throws NoSuchNodeTypeException
      */
-    public synchronized NodeTypeImpl getNodeType(QName name)
-            throws NoSuchNodeTypeException {
-        NodeTypeImpl nt = (NodeTypeImpl) ntCache.get(name);
-        if (nt != null) {
+    public NodeTypeImpl getNodeType(QName name) throws NoSuchNodeTypeException {
+        synchronized (ntCache) {
+            NodeTypeImpl nt = (NodeTypeImpl) ntCache.get(name);
+            if (nt == null) {
+                EffectiveNodeType ent = ntReg.getEffectiveNodeType(name);
+                NodeTypeDef def = ntReg.getNodeTypeDef(name);
+                nt = new NodeTypeImpl(ent, def, this, nsResolver);
+                ntCache.put(name, nt);
+            }
             return nt;
         }
-
-        EffectiveNodeType ent = ntReg.getEffectiveNodeType(name);
-        NodeTypeDef def = ntReg.getNodeTypeDef(name);
-        nt = new NodeTypeImpl(ent, def, this, nsResolver);
-        ntCache.put(name, nt);
-
-        return nt;
     }
 
     /**
@@ -141,6 +173,9 @@
     public void nodeTypeReRegistered(QName ntName) {
         // flush cache
         ntCache.remove(ntName);
+        // just clear all definitions from cache
+        pdCache.clear();
+        ndCache.clear();
     }
 
     /**
@@ -149,6 +184,9 @@
     public void nodeTypeUnregistered(QName ntName) {
         // sync cache
         ntCache.remove(ntName);
+        // just clear all definitions from cache
+        pdCache.clear();
+        ndCache.clear();
     }
 
     //------------------------------------------------------< NodeTypeManager >

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?view=diff&r1=161307&r2=161308
==============================================================================
--- 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 Thu Apr 14 08:39:43 2005
@@ -153,7 +153,7 @@
 
         // setup definition of root node
         rootNodeDef = createRootNodeDef();
-        nodeDefs.put(new NodeDefId(rootNodeDef), rootNodeDef);
+        nodeDefs.put(rootNodeDef.getId(), rootNodeDef);
 
         // load and register pre-defined (i.e. built-in) node types
         /**
@@ -237,7 +237,7 @@
     }
 
     private static NodeDef createRootNodeDef() {
-        NodeDef def = new NodeDef();
+        NodeDefImpl def = new NodeDefImpl();
 
         // FIXME need a fake declaring node type
         def.setDeclaringNodeType(new QName(NS_DEFAULT_URI, ""));
@@ -328,15 +328,11 @@
         // store property & child node definitions of new node type by id
         PropDef[] pda = ntd.getPropertyDefs();
         for (int i = 0; i < pda.length; i++) {
-            PropDef def = pda[i];
-            PropDefId id = new PropDefId(def);
-            propDefs.put(id, def);
+            propDefs.put(pda[i].getId(), pda[i]);
         }
         NodeDef[] nda = ntd.getChildNodeDefs();
         for (int i = 0; i < nda.length; i++) {
-            NodeDef def = nda[i];
-            NodeDefId id = new NodeDefId(def);
-            nodeDefs.put(id, def);
+            nodeDefs.put(nda[i].getId(), nda[i]);
         }
 
         return ent;
@@ -375,13 +371,11 @@
         // remove property & child node definitions
         PropDef[] pda = ntd.getPropertyDefs();
         for (int i = 0; i < pda.length; i++) {
-            PropDefId id = new PropDefId(pda[i]);
-            propDefs.remove(id);
+            propDefs.remove(pda[i].getId());
         }
         NodeDef[] nda = ntd.getChildNodeDefs();
         for (int i = 0; i < nda.length; i++) {
-            NodeDefId id = new NodeDefId(nda[i]);
-            nodeDefs.remove(id);
+            nodeDefs.remove(nda[i].getId());
         }
     }
 
@@ -1437,18 +1431,7 @@
      * @return
      */
     public NodeDef getNodeDef(NodeDefId id) {
-        NodeDef def = (NodeDef) nodeDefs.get(id);
-        if (def == null) {
-            return null;
-        }
-        // return clone to make sure nobody messes around with the 'real' definition
-        try {
-            return (NodeDef) def.clone();
-        } catch (CloneNotSupportedException e) {
-            // should never get here
-            log.fatal("internal error", e);
-            throw new InternalError(e.getMessage());
-        }
+        return (NodeDef) nodeDefs.get(id);
     }
 
     /**
@@ -1456,18 +1439,7 @@
      * @return
      */
     public PropDef getPropDef(PropDefId id) {
-        PropDef def = (PropDef) propDefs.get(id);
-        if (def == null) {
-            return null;
-        }
-        // return clone to make sure nobody messes around with the 'real' definition
-        try {
-            return (PropDef) def.clone();
-        } catch (CloneNotSupportedException e) {
-            // should never get here
-            log.fatal("internal error", e);
-            throw new InternalError(e.getMessage());
-        }
+        return (PropDef) propDefs.get(id);
     }
 
     //----------------------------------------------------------< diagnostics >
@@ -1497,7 +1469,7 @@
             PropDef[] pd = ntd.getPropertyDefs();
             for (int i = 0; i < pd.length; i++) {
                 ps.print("\tPropertyDefinition");
-                ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") id=" + new PropDefId(pd[i]));
+                ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") id=" + pd[i].getId());
                 ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getName().toString()));
                 String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
                 ps.println("\t\tRequiredType\t" + type);
@@ -1536,7 +1508,7 @@
             NodeDef[] nd = ntd.getChildNodeDefs();
             for (int i = 0; i < nd.length; i++) {
                 ps.print("\tNodeDefinition");
-                ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") id=" + new NodeDefId(nd[i]));
+                ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") id=" + nd[i].getId());
                 ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getName().toString()));
                 QName[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
                 if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java Thu Apr 14 08:39:43 2005
@@ -18,102 +18,39 @@
 
 import org.apache.jackrabbit.core.InternalValue;
 
-import javax.jcr.PropertyType;
-import java.util.Arrays;
-
 /**
- * A <code>PropDef</code> ...
+ * This interface defines the property def.
  */
-public class PropDef extends ItemDef {
-
-    private int requiredType = PropertyType.UNDEFINED;
-    private ValueConstraint[] valueConstraints = new ValueConstraint[0];
-    private InternalValue[] defaultValues = new InternalValue[0];
-    private boolean multiple = false;
-
-    /**
-     * Default constructor.
-     */
-    public PropDef() {
-    }
-
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof PropDef) {
-            PropDef other = (PropDef) obj;
-            return super.equals(obj)
-                    && requiredType == other.requiredType
-                    && Arrays.equals(valueConstraints, other.valueConstraints)
-                    && Arrays.equals(defaultValues, other.defaultValues)
-                    && multiple == other.multiple;
-        }
-        return false;
-    }
-
-    /**
-     * @param requiredType
-     */
-    public void setRequiredType(int requiredType) {
-        this.requiredType = requiredType;
-    }
+public interface PropDef extends ItemDef {
 
     /**
-     * @param valueConstraints
+     * Returns the property definition id.
+     * @return the PropDefId
      */
-    public void setValueConstraints(ValueConstraint valueConstraints[]) {
-        this.valueConstraints =
-                (valueConstraints == null) ? new ValueConstraint[0] : valueConstraints;
-    }
+    public PropDefId getId();
 
     /**
-     * @param defaultValues
+     * Returns the required type
+     * @return the required type
      */
-    public void setDefaultValues(InternalValue[] defaultValues) {
-        this.defaultValues =
-                (defaultValues == null) ? new InternalValue[0] : defaultValues;
-    }
+    public int getRequiredType();
 
     /**
-     * @param multiple
+     * Returns the array of value constraints
+     * @return the array of value constraints
      */
-    public void setMultiple(boolean multiple) {
-        this.multiple = multiple;
-    }
+    public ValueConstraint[] getValueConstraints();
 
     /**
-     * @return
+     * Returns the array of default values
+     * @return the array of default values
      */
-    public int getRequiredType() {
-        return requiredType;
-    }
+    public InternalValue[] getDefaultValues();
 
     /**
-     * @return
+     * Returns the 'multiple' flag.
+     * @return the 'multiple' flag.
      */
-    public ValueConstraint[] getValueConstraints() {
-        return valueConstraints;
-    }
+    public boolean isMultiple();
 
-    /**
-     * @return
-     */
-    public InternalValue[] getDefaultValues() {
-        return defaultValues;
-    }
-
-    /**
-     * @return
-     */
-    public boolean isMultiple() {
-        return multiple;
-    }
-
-    /**
-     * @return
-     */
-    public boolean definesNode() {
-        return false;
-    }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java Thu Apr 14 08:39:43 2005
@@ -24,11 +24,21 @@
  */
 public class PropDefId implements Serializable {
 
+    /**
+     * Serial number
+     */
     static final long serialVersionUID = 3675238890036653593L;
 
+    /**
+     * the internal id
+     */
     private final int id;
 
-    public PropDefId(PropDef def) {
+    /**
+     * Creates a new PropDefId from the given PropDef
+     * @param def
+     */
+    PropDefId(PropDefImpl def) {
         if (def == null) {
             throw new IllegalArgumentException("PropDef argument can not be null");
         }
@@ -50,6 +60,10 @@
         id = sb.toString().hashCode();
     }
 
+    /**
+     * Creates a new PropDefId with the given internal id
+     * @param id
+     */
     private PropDefId(int id) {
         this.id = id;
     }
@@ -73,6 +87,9 @@
         return new PropDefId(Integer.parseInt(s));
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
@@ -84,10 +101,16 @@
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return Integer.toString(id);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         // id is already the computed hash code
         return id;

Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java?view=auto&rev=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java (added)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java Thu Apr 14 08:39:43 2005
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.nodetype;
+
+import org.apache.jackrabbit.core.InternalValue;
+import org.apache.jackrabbit.core.QName;
+
+import javax.jcr.PropertyType;
+import java.util.Arrays;
+
+/**
+ * this class implements the PropDef interface.
+ */
+public class PropDefImpl extends ItemDefImpl implements PropDef {
+
+    /**
+     * The required type
+     */
+    private int requiredType = PropertyType.UNDEFINED;
+
+    /**
+     * The value constrsints.
+     */
+    private ValueConstraint[] valueConstraints = ValueConstraint.EMPTY;
+
+    /**
+     * the default values
+     */
+    private InternalValue[] defaultValues = InternalValue.EMPTY;
+
+    /**
+     * the 'multiple' flag
+     */
+    private boolean multiple = false;
+
+    /**
+     * the id of this property def
+     */
+    private PropDefId id;
+
+    /**
+     * Sets the required type
+     *
+     * @param requiredType
+     */
+    public void setRequiredType(int requiredType) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        this.requiredType = requiredType;
+    }
+
+    /**
+     * Sets the value constraints
+     *
+     * @param valueConstraints
+     */
+    public void setValueConstraints(ValueConstraint valueConstraints[]) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        this.valueConstraints =
+                (valueConstraints == null) ? ValueConstraint.EMPTY : valueConstraints;
+    }
+
+    /**
+     * Sets the default values
+     *
+     * @param defaultValues
+     */
+    public void setDefaultValues(InternalValue[] defaultValues) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        this.defaultValues =
+                (defaultValues == null) ? InternalValue.EMPTY : defaultValues;
+    }
+
+    /**
+     * Sets the 'multiple' flag.
+     *
+     * @param multiple
+     */
+    public void setMultiple(boolean multiple) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        this.multiple = multiple;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDeclaringNodeType(QName declaringNodeType) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setDeclaringNodeType(declaringNodeType);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setName(QName name) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setName(name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setAutoCreated(boolean autoCreated) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setAutoCreated(autoCreated);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setOnParentVersion(int onParentVersion) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setOnParentVersion(onParentVersion);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setProtected(boolean writeProtected) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setProtected(writeProtected);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setMandatory(boolean mandatory) {
+        if (id != null) {
+            throw new IllegalStateException("Unable to set attribute. PropDef already compiled.");
+        }
+        super.setMandatory(mandatory);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public PropDefId getId() {
+        if (id == null) {
+            id = new PropDefId(this);
+        }
+        return id;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ValueConstraint[] getValueConstraints() {
+        return valueConstraints;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public InternalValue[] getDefaultValues() {
+        return defaultValues;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isMultiple() {
+        return multiple;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean definesNode() {
+        return false;
+    }
+
+    /**
+     * Checks if this prop def is equal to the given one.
+     * @param obj the object to compare to
+     * @return <code>true</code> if equals; <code>false</code> otherwise
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof PropDefImpl) {
+            PropDefImpl other = (PropDefImpl) obj;
+            return super.equals(obj)
+                    && requiredType == other.requiredType
+                    && Arrays.equals(valueConstraints, other.valueConstraints)
+                    && Arrays.equals(defaultValues, other.defaultValues)
+                    && multiple == other.multiple;
+        }
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
------------------------------------------------------------------------------
    svn = 

Propchange: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java Thu Apr 14 08:39:43 2005
@@ -25,16 +25,15 @@
 import javax.jcr.nodetype.PropertyDefinition;
 
 /**
- * A <code>PropertyDefinitionImpl</code> ...
+ * This class implements the PropertyDef interface.
  */
-public class PropertyDefinitionImpl extends ItemDefinitionImpl
-        implements PropertyDefinition {
+public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {
 
+    /**
+     * the default logger
+     */
     private static Logger log = Logger.getLogger(PropertyDefinitionImpl.class);
 
-    private final PropDef propDef;
-
-
     /**
      * Package private constructor
      *
@@ -42,14 +41,16 @@
      * @param ntMgr      node type manager
      * @param nsResolver namespace resolver
      */
-    PropertyDefinitionImpl(PropDef propDef, NodeTypeManagerImpl ntMgr,
-                           NamespaceResolver nsResolver) {
+    PropertyDefinitionImpl(PropDef propDef, NodeTypeManagerImpl ntMgr, NamespaceResolver nsResolver) {
         super(propDef, ntMgr, nsResolver);
-        this.propDef = propDef;
     }
 
+    /**
+     * Returns the underlaying prop def
+     * @return
+     */
     public PropDef unwrap() {
-        return propDef;
+        return (PropDef) itemDef;
     }
 
     //----------------------------------------------------------< PropertyDef >
@@ -57,7 +58,7 @@
      * {@inheritDoc}
      */
     public Value[] getDefaultValues() {
-        InternalValue[] defVals = propDef.getDefaultValues();
+        InternalValue[] defVals = ((PropDef) itemDef).getDefaultValues();
         if (defVals == null) {
             return null;
         }
@@ -68,9 +69,7 @@
             } catch (RepositoryException re) {
                 // should never get here
                 String propName = (getName() == null) ? "[null]" : getName();
-                log.error("illegal default value specified for property "
-                        + propName + " in node type " + getDeclaringNodeType(),
-                        re);
+                log.error("illegal default value specified for property " + propName + " in node type " + getDeclaringNodeType(), re);
                 return null;
             }
         }
@@ -81,14 +80,14 @@
      * {@inheritDoc}
      */
     public int getRequiredType() {
-        return propDef.getRequiredType();
+        return ((PropDef) itemDef).getRequiredType();
     }
 
     /**
      * {@inheritDoc}
      */
     public String[] getValueConstraints() {
-        ValueConstraint[] constraints = propDef.getValueConstraints();
+        ValueConstraint[] constraints = ((PropDef) itemDef).getValueConstraints();
         if (constraints == null || constraints.length == 0) {
             return new String[0];
         }
@@ -103,7 +102,7 @@
      * {@inheritDoc}
      */
     public boolean isMultiple() {
-        return propDef.isMultiple();
+        return ((PropDef) itemDef).isMultiple();
     }
 }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java Thu Apr 14 08:39:43 2005
@@ -45,6 +45,8 @@
 public abstract class ValueConstraint {
     protected static Logger log = Logger.getLogger(ValueConstraint.class);
 
+    public static final ValueConstraint[] EMPTY = new ValueConstraint[0];
+
     final String definition;
 
     protected ValueConstraint(String definition) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml Thu Apr 14 08:39:43 2005
@@ -179,6 +179,7 @@
             <supertype>nt:base</supertype>
             <supertype>mix:referenceable</supertype>
         </supertypes>
+        <propertyDefinition name="jcr:versionableUuid" requiredType="String" autoCreated="true" mandatory="true" onParentVersion="ABORT" protected="true" multiple="false"/>
         <childNodeDefinition name="jcr:rootVersion" defaultPrimaryType="nt:version" autoCreated="true" mandatory="true" onParentVersion="ABORT" protected="true" sameNameSiblings="false">
             <requiredPrimaryTypes>
                 <requiredPrimaryType>nt:version</requiredPrimaryType>

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/Constants.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/Constants.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/xml/Constants.java Thu Apr 14 08:39:43 2005
@@ -19,7 +19,7 @@
 /**
  * Name constants for the node type XML elements and attributes.
  */
-final class Constants {
+public class Constants {
 
     /** Name of the node type definition root element. */
     public static final String NODETYPES_ELEMENT = "nodeTypes";

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?view=diff&r1=161307&r2=161308
==============================================================================
--- 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 Thu Apr 14 08:39:43 2005
@@ -35,6 +35,8 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.nodetype.ValueConstraint;
+import org.apache.jackrabbit.core.nodetype.PropDefImpl;
+import org.apache.jackrabbit.core.nodetype.NodeDefImpl;
 import org.apache.jackrabbit.core.util.DOMWalker;
 
 /**
@@ -54,11 +56,9 @@
      *                                     cannot be read
      * @throws InvalidNodeTypeDefException if the node type definition
      *                                     format is invalid
-     * @throws RepositoryException         on repository errors
      */
     public static NodeTypeDef[] read(InputStream xml)
-            throws IOException, InvalidNodeTypeDefException,
-            RepositoryException {
+            throws IOException, InvalidNodeTypeDefException {
         try {
             NodeTypeReader reader = new NodeTypeReader(xml);
             return reader.getNodeTypeDefs();
@@ -154,7 +154,7 @@
         // property definitions
         Vector properties = new Vector();
         while (walker.iterateElements(Constants.PROPERTYDEFINITION_ELEMENT)) {
-            PropDef def = getPropDef();
+            PropDefImpl def = getPropDef();
             def.setDeclaringNodeType(type.getName());
             properties.add(def);
         }
@@ -164,7 +164,7 @@
         // child node definitions
         Vector nodes = new Vector();
         while (walker.iterateElements(Constants.CHILDNODEDEFINITION_ELEMENT)) {
-            NodeDef def = getChildNodeDef();
+            NodeDefImpl def = getChildNodeDef();
             def.setDeclaringNodeType(type.getName());
             nodes.add(def);
         }
@@ -184,10 +184,10 @@
      * @throws UnknownPrefixException      if the definition contains an
      *                                     unknown namespace prefix
      */
-    private PropDef getPropDef()
+    private PropDefImpl getPropDef()
             throws InvalidNodeTypeDefException, IllegalNameException,
             UnknownPrefixException {
-        PropDef def = new PropDef();
+        PropDefImpl def = new PropDefImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
             def.setName(new QName("", "*"));
@@ -259,16 +259,14 @@
      * Returns the child node definition specified by the current element.
      *
      * @return child node definition
-     * @throws InvalidNodeTypeDefException if the definition is invalid
      * @throws IllegalNameException        if the definition contains an
      *                                     illegal name
      * @throws UnknownPrefixException      if the definition contains an
      *                                     unknown namespace prefix
      */
-    private NodeDef getChildNodeDef()
-            throws InvalidNodeTypeDefException, IllegalNameException,
-            UnknownPrefixException {
-        NodeDef def = new NodeDef();
+    private NodeDefImpl getChildNodeDef()
+            throws IllegalNameException, UnknownPrefixException {
+        NodeDefImpl def = new NodeDefImpl();
         String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
         if (name.equals("*")) {
             def.setName(new QName("", "*"));

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java Thu Apr 14 08:39:43 2005
@@ -42,7 +42,7 @@
         }
         if (obj instanceof NodeReferencesId) {
             NodeReferencesId other = (NodeReferencesId) obj;
-            return uuid.equals(other.uuid);
+            return uuid == other.uuid;
         }
         return false;
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/PropertyState.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/PropertyState.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/PropertyState.java Thu Apr 14 08:39:43 2005
@@ -74,7 +74,7 @@
         super(parentUUID, new PropertyId(parentUUID, name), initialStatus, isTransient);
         this.name = name;
         type = PropertyType.UNDEFINED;
-        values = new InternalValue[0];
+        values = InternalValue.EMPTY;
         multiValued = false;
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Thu Apr 14 08:39:43 2005
@@ -24,7 +24,6 @@
 import org.apache.jackrabbit.core.QName;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
@@ -133,7 +132,7 @@
         // definition of jcr:primaryType property
         PropDef propDef;
         try {
-            nodeDefId = new NodeDefId(ntReg.getRootNodeDef());
+            nodeDefId = ntReg.getRootNodeDef().getId();
             EffectiveNodeType ent = ntReg.getEffectiveNodeType(Constants.REP_ROOT);
             propDef = ent.getApplicablePropertyDef(Constants.JCR_PRIMARYTYPE,
                     PropertyType.NAME, false);
@@ -155,7 +154,7 @@
         prop.setValues(new InternalValue[]{InternalValue.create(Constants.REP_ROOT)});
         prop.setType(propDef.getRequiredType());
         prop.setMultiValued(propDef.isMultiple());
-        prop.setDefinitionId(new PropDefId(propDef));
+        prop.setDefinitionId(propDef.getId());
 
         ChangeLog changeLog = new ChangeLog();
         changeLog.added(rootState);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryNodeState.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryNodeState.java?view=diff&r1=161307&r2=161308
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryNodeState.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryNodeState.java Thu Apr 14 08:39:43 2005
@@ -53,9 +53,7 @@
 
         // version history is referenceable
         setPropertyValue(JCR_UUID, InternalValue.create(vh.getId()));
-
-        // enable for spec 0.16.3
-        // setPropertyValue(JCR_VERSIONABLEUUID, InternalValue.create(vh.getVersionableUUID()));
+        setPropertyValue(JCR_VERSIONABLEUUID, InternalValue.create(vh.getVersionableUUID()));
 
         this.vh = vh;
     }



Mime
View raw message