You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2005/04/24 18:03:48 UTC
svn commit: r164485 - in /incubator/jackrabbit/trunk: ./
src/java/org/apache/jackrabbit/core/
src/java/org/apache/jackrabbit/core/nodetype/
src/java/org/apache/jackrabbit/core/state/
src/test/org/apache/jackrabbit/core/
Author: stefan
Date: Sun Apr 24 09:03:46 2005
New Revision: 164485
URL: http://svn.apache.org/viewcvs?rev=164485&view=rev
Log:
- JCR-73: some javadoc improvements
- slightly changed semantics of identifier computation in PropDefImpl & NodeDefImpl
Modified:
incubator/jackrabbit/trunk/project.properties
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.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/NodeDef.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDef.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeReferencesId.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Modified: incubator/jackrabbit/trunk/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/project.properties?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/project.properties (original)
+++ incubator/jackrabbit/trunk/project.properties Sun Apr 24 09:03:46 2005
@@ -1,5 +1,5 @@
-# Copyright 2003-2005 The Apache Software Foundatio or its licensors,
-# as applicablen
+# Copyright 2003-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.
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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java Sun Apr 24 09:03:46 2005
@@ -29,7 +29,7 @@
/** UUID of the parent node. */
private final String parentUUID;
- /** Qualified name of the property. */
+ /** Qualified name of the property. */
private final QName propName;
/**
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=164485&r1=164484&r2=164485&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 Sun Apr 24 09:03:46 2005
@@ -20,7 +20,11 @@
import org.apache.jackrabbit.core.QName;
/**
- * Superinterface of {@link NodeDef} and {@link PropDef}.
+ * <code>ItemDef</code> is the internal representation of
+ * an item definition. It refers to <code>QName</code>s only
+ * and is thus isolated from session-specific namespace mappings.
+ *
+ * @see javax.jcr.nodetype.ItemDefinition
*/
public interface ItemDef {
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=164485&r1=164484&r2=164485&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 Sun Apr 24 09:03:46 2005
@@ -22,7 +22,7 @@
/**
* This abstract class implements the <code>ItemDef</code>
- * interface and additionally provides setter's for the
+ * interface and additionally provides setter methods for the
* various item definition attributes.
*/
public abstract class ItemDefImpl implements ItemDef {
@@ -56,6 +56,12 @@
* The 'mandatory' flag.
*/
private boolean mandatory = false;
+
+ /**
+ * Default constructor.
+ */
+ public ItemDefImpl() {
+ }
/**
* Sets the name of declaring node type.
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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- 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 Sun Apr 24 09:03:46 2005
@@ -19,32 +19,39 @@
import org.apache.jackrabbit.core.QName;
/**
- * This interface defines a node definition.
+ * <code>NodeDef</code> is the internal representation of
+ * a node definition. It refers to <code>QName</code>s only
+ * and is thus isolated from session-specific namespace mappings.
+ *
+ * @see javax.jcr.nodetype.NodeDefinition
*/
public interface NodeDef extends ItemDef {
/**
- * Returns the id of this node definition.
- * @return the id of this node definition.
+ * Returns an identifier for this node definition.
+ *
+ * @return an identifier for this node definition.
*/
NodeDefId getId();
/**
* Returns the name of the default primary type.
+ *
* @return the name of the default primary type.
*/
QName getDefaultPrimaryType();
/**
* Returns the array of names of the required primary types.
+ *
* @return the array of names of the required primary types.
*/
QName[] getRequiredPrimaryTypes();
/**
- * Returns the 'allowsSameNameSiblings' flag.
+ * Reports whether this node can have same-name siblings.
+ *
* @return the 'allowsSameNameSiblings' flag.
*/
boolean allowsSameNameSiblings();
-
}
Modified: 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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefImpl.java Sun Apr 24 09:03:46 2005
@@ -22,8 +22,8 @@
import java.util.Arrays;
/**
- * This class implements the <code>NodeDef</code> interface and holds the node
- * definition specific attributes.
+ * This class implements the <code>NodeDef</code> interface and additionally
+ * provides setter methods for the various node definition attributes.
*/
public class NodeDefImpl extends ItemDefImpl implements NodeDef {
@@ -43,17 +43,61 @@
private boolean allowsSameNameSiblings = false;
/**
- * The id of the node definition.
+ * The identifier of this node definition. The identifier is lazily computed
+ * based on the characteristics of this node definition and reset on every
+ * attribute change.
*/
- private NodeDefId id;
+ private NodeDefId id = null;
/**
+ * Default constructor.
+ */
+ public NodeDefImpl() {
+ }
+
+ /**
+ * Sets the name of default primary type.
+ *
+ * @param defaultNodeType
+ */
+ public void setDefaultPrimaryType(QName defaultNodeType) {
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
+ this.defaultPrimaryType = defaultNodeType;
+ }
+
+ /**
+ * Sets the names of the required primary types.
+ *
+ * @param requiredPrimaryTypes
+ */
+ public void setRequiredPrimaryTypes(QName[] requiredPrimaryTypes) {
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
+ 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) {
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
+ this.allowsSameNameSiblings = allowsSameNameSiblings;
+ }
+
+ //------------------------------------------------< ItemDefImpl overrides >
+ /**
* {@inheritDoc}
*/
public void setDeclaringNodeType(QName declaringNodeType) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setDeclaringNodeType(declaringNodeType);
}
@@ -61,9 +105,8 @@
* {@inheritDoc}
*/
public void setName(QName name) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setName(name);
}
@@ -71,9 +114,8 @@
* {@inheritDoc}
*/
public void setAutoCreated(boolean autoCreated) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setAutoCreated(autoCreated);
}
@@ -81,9 +123,8 @@
* {@inheritDoc}
*/
public void setOnParentVersion(int onParentVersion) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setOnParentVersion(onParentVersion);
}
@@ -91,9 +132,8 @@
* {@inheritDoc}
*/
public void setProtected(boolean writeProtected) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setProtected(writeProtected);
}
@@ -101,49 +141,25 @@
* {@inheritDoc}
*/
public void setMandatory(boolean mandatory) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setMandatory(mandatory);
}
+ //--------------------------------------------------------------< NodeDef >
/**
- * Sets the name of default primary type.
- *
- * @param defaultNodeType
- */
- public void setDefaultPrimaryType(QName defaultNodeType) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition 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. Node definition already compiled.");
- }
- if (requiredPrimaryTypes == null) {
- throw new IllegalArgumentException("requiredPrimaryTypes can not be null");
- }
- this.requiredPrimaryTypes = requiredPrimaryTypes;
- }
-
- /**
- * Sets the 'allowsSameNameSiblings' flag.
- *
- * @param allowsSameNameSiblings
+ * {@inheritDoc}
+ * <p/>
+ * The identifier is computed based on the characteristics of this property
+ * definition, i.e. modifying attributes of this property definition will
+ * have impact on the identifier returned by this method.
*/
- public void setAllowsSameNameSiblings(boolean allowsSameNameSiblings) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Node definition already compiled.");
+ public NodeDefId getId() {
+ if (id == null) {
+ // generate new identifier based on this node definition
+ id = new NodeDefId(this);
}
- this.allowsSameNameSiblings = allowsSameNameSiblings;
+ return id;
}
/**
@@ -169,29 +185,23 @@
/**
* {@inheritDoc}
- */
- public NodeDefId getId() {
- if (id == null) {
- id = new NodeDefId(this);
- }
- return id;
- }
-
- /**
- * {@inheritDoc}
+ *
+ * @return always <code>true</code>
*/
public boolean definesNode() {
return true;
}
+ //-------------------------------------------< java.lang.Object overrides >
/**
- * Checks if this node definition is equal to the given one. Two node
- * definitions are equal if they are the same object or if all their
- * attributes are equal.
+ * Compares two node definitions for equality. Returns <code>true</code>
+ * if the given object is a node defintion and has the same attributes
+ * as this node definition.
*
- * @param obj the other object to compare to.
- * @return <code>true</code> if this item definition is equals to obj;
- * <code>false</code> otherwise.
+ * @param obj the object to compare this node definition with
+ * @return <code>true</code> if the object is equal to this node definition,
+ * <code>false</code> otherwise
+ * @see Object#equals(Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- 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 Sun Apr 24 09:03:46 2005
@@ -19,38 +19,46 @@
import org.apache.jackrabbit.core.InternalValue;
/**
- * This interface defines a property definition.
+ * <code>PropDef</code> is the internal representation of
+ * a property definition. It refers to <code>QName</code>s only
+ * and is thus isolated from session-specific namespace mappings.
+ *
+ * @see javax.jcr.nodetype.PropertyDefinition
*/
public interface PropDef extends ItemDef {
/**
- * Returns the id of this property definition.
- * @return the id of this property definition.
+ * Returns an identifier for this property definition.
+ *
+ * @return an identifier for this property definition.
*/
PropDefId getId();
/**
* Returns the required type.
+ *
* @return the required type.
*/
int getRequiredType();
/**
* Returns the array of value constraints.
+ *
* @return the array of value constraints.
*/
ValueConstraint[] getValueConstraints();
/**
* Returns the array of default values.
+ *
* @return the array of default values.
*/
InternalValue[] getDefaultValues();
/**
- * Returns the 'multiple' flag.
+ * Reports whether this property can have multiple values.
+ *
* @return the 'multiple' flag.
*/
boolean isMultiple();
-
}
Modified: 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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java Sun Apr 24 09:03:46 2005
@@ -23,8 +23,8 @@
import java.util.Arrays;
/**
- * This class implements the <code>PropDef</code> interface and holds the
- * property definition specific attributes.
+ * This class implements the <code>PropDef</code> interface and additionally
+ * provides setter methods for the various property definition attributes.
*/
public class PropDefImpl extends ItemDefImpl implements PropDef {
@@ -34,7 +34,7 @@
private int requiredType = PropertyType.UNDEFINED;
/**
- * The value constrsints.
+ * The value constraints.
*/
private ValueConstraint[] valueConstraints = ValueConstraint.EMPTY_ARRAY;
@@ -49,9 +49,17 @@
private boolean multiple = false;
/**
- * The id of this property definition.
+ * The identifier of this property definition. The identifier is lazily
+ * computed based on the characteristics of this property definition and
+ * reset on every attribute change.
*/
- private PropDefId id;
+ private PropDefId id = null;
+
+ /**
+ * Default constructor.
+ */
+ public PropDefImpl() {
+ }
/**
* Sets the required type
@@ -59,9 +67,8 @@
* @param requiredType
*/
public void setRequiredType(int requiredType) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
this.requiredType = requiredType;
}
@@ -71,9 +78,8 @@
* @param valueConstraints
*/
public void setValueConstraints(ValueConstraint[] valueConstraints) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
if (valueConstraints != null) {
this.valueConstraints = valueConstraints;
} else {
@@ -87,9 +93,8 @@
* @param defaultValues
*/
public void setDefaultValues(InternalValue[] defaultValues) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
if (defaultValues != null) {
this.defaultValues = defaultValues;
} else {
@@ -103,19 +108,18 @@
* @param multiple
*/
public void setMultiple(boolean multiple) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
this.multiple = multiple;
}
+ //------------------------------------------------< ItemDefImpl overrides >
/**
* {@inheritDoc}
*/
public void setDeclaringNodeType(QName declaringNodeType) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setDeclaringNodeType(declaringNodeType);
}
@@ -123,9 +127,8 @@
* {@inheritDoc}
*/
public void setName(QName name) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setName(name);
}
@@ -133,9 +136,8 @@
* {@inheritDoc}
*/
public void setAutoCreated(boolean autoCreated) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setAutoCreated(autoCreated);
}
@@ -143,9 +145,8 @@
* {@inheritDoc}
*/
public void setOnParentVersion(int onParentVersion) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setOnParentVersion(onParentVersion);
}
@@ -153,9 +154,8 @@
* {@inheritDoc}
*/
public void setProtected(boolean writeProtected) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setProtected(writeProtected);
}
@@ -163,17 +163,22 @@
* {@inheritDoc}
*/
public void setMandatory(boolean mandatory) {
- if (id != null) {
- throw new IllegalStateException("Unable to set attribute. Property definition already compiled.");
- }
+ // reset id field in order to force lazy recomputation of identifier
+ id = null;
super.setMandatory(mandatory);
}
+ //--------------------------------------------------------------< PropDef >
/**
* {@inheritDoc}
+ * <p/>
+ * The identifier is computed based on the characteristics of this property
+ * definition, i.e. modifying attributes of this property definition will
+ * have impact on the identifier returned by this method.
*/
public PropDefId getId() {
if (id == null) {
+ // generate new identifier based on this property definition
id = new PropDefId(this);
}
return id;
@@ -209,19 +214,23 @@
/**
* {@inheritDoc}
+ *
+ * @return always <code>false</code>
*/
public boolean definesNode() {
return false;
}
+ //-------------------------------------------< java.lang.Object overrides >
/**
- * Checks if this property definition is equal to the given one. Two
- * property definitions 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 property definition is equals to obj;
- * <code>false</code> otherwise.
+ * Compares two property definitions for equality. Returns <code>true</code>
+ * if the given object is a property defintion and has the same attributes
+ * as this property definition.
+ *
+ * @param obj the object to compare this property definition with
+ * @return <code>true</code> if the object is equal to this property definition,
+ * <code>false</code> otherwise
+ * @see Object#equals(Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
@@ -237,5 +246,4 @@
}
return false;
}
-
}
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?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- 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 Sun Apr 24 09:03:46 2005
@@ -52,7 +52,6 @@
}
//-------------------------------------------< java.lang.Object overrides >
-
/**
* {@inheritDoc}
*/
@@ -65,5 +64,4 @@
}
return false;
}
-
}
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=164485&r1=164484&r2=164485&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java Sun Apr 24 09:03:46 2005
@@ -21,7 +21,6 @@
import org.apache.jackrabbit.test.RepositoryStubException;
import javax.jcr.Repository;
-import javax.jcr.Credentials;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;