You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2009/09/08 11:47:15 UTC
svn commit: r812419 [2/3] - in /jackrabbit/sandbox/JCR-2170:
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/...
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropDefImpl.java Tue Sep 8 09:47:13 2009
@@ -20,40 +20,13 @@
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValueConstraint;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
-import java.util.Arrays;
-
/**
* 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 {
-
- /**
- * The required type.
- */
- private int requiredType = PropertyType.UNDEFINED;
-
- /**
- * The value constraints.
- */
- private QValueConstraint[] valueConstraints = QValueConstraint.EMPTY_ARRAY;
-
- /**
- * The default values.
- */
- private InternalValue[] defaultValues = InternalValue.EMPTY_ARRAY;
-
- /**
- * The 'multiple' flag
- */
- private boolean multiple = false;
+public class PropDefImpl extends QPropertyDefinitionImpl implements PropDef {
/**
* The identifier of this property definition. The identifier is lazily
@@ -62,69 +35,15 @@
*/
private PropDefId id = null;
- /*
- * The 'fulltext searchable' flag.
- */
- private boolean fullTextSearchable = true;
-
- /*
- * The 'query orderable' flag.
- */
- private boolean queryOrderable = true;
-
- /*
- * The 'query operators.
- */
- private String[] queryOperators = Operator.getAllQueryOperators();
-
-
/**
* Default constructor.
*/
public PropDefImpl() {
+ super();
}
public PropDefImpl(QPropertyDefinition pd) {
super(pd);
- requiredType = pd.getRequiredType();
- valueConstraints = pd.getValueConstraints();
- QValue[] vs = pd.getDefaultValues();
- if (vs != null) {
- defaultValues = new InternalValue[vs.length];
- for (int i=0; i<vs.length; i++) {
- try {
- defaultValues[i] = InternalValue.create(vs[i]);
- } catch (RepositoryException e) {
- throw new IllegalStateException("Error while converting default values.", e);
- }
- }
- }
- multiple = pd.isMultiple();
- fullTextSearchable = pd.isFullTextSearchable();
- queryOrderable = pd.isQueryOrderable();
- queryOperators = pd.getAvailableQueryOperators();
- }
-
- /**
- * Returns the QPropertyDefinition of this PropDef
- * @return the QPropertyDefinition
- */
- public QPropertyDefinition getQPropertyDefinition() {
- return new QPropertyDefinitionImpl(
- getName(),
- getDeclaringNodeType(),
- isAutoCreated(),
- isMandatory(),
- getOnParentVersion(),
- isProtected(),
- getDefaultValues(),
- isMultiple(),
- getRequiredType(),
- getValueConstraints(),
- getAvailableQueryOperators(),
- isFullTextSearchable(),
- isQueryOrderable()
- );
}
/**
@@ -135,7 +54,7 @@
public void setRequiredType(int requiredType) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- this.requiredType = requiredType;
+ super.setRequiredType(requiredType);
}
/**
@@ -146,11 +65,7 @@
public void setValueConstraints(QValueConstraint[] valueConstraints) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- if (valueConstraints != null) {
- this.valueConstraints = valueConstraints;
- } else {
- this.valueConstraints = QValueConstraint.EMPTY_ARRAY;
- }
+ super.setValueConstraints(valueConstraints);
}
/**
@@ -161,11 +76,7 @@
public void setDefaultValues(InternalValue[] defaultValues) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- if (defaultValues != null) {
- this.defaultValues = defaultValues;
- } else {
- this.defaultValues = InternalValue.EMPTY_ARRAY;
- }
+ super.setDefaultValues(defaultValues);
}
/**
@@ -176,7 +87,7 @@
public void setMultiple(boolean multiple) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- this.multiple = multiple;
+ super.setMultiple(multiple);
}
/**
@@ -187,7 +98,7 @@
public void setFullTextSearchable(boolean fullTextSearchable) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- this.fullTextSearchable = fullTextSearchable;
+ super.setFullTextSearchable(fullTextSearchable);
}
/**
@@ -198,7 +109,7 @@
public void setQueryOrderable(boolean queryOrderable) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- this.queryOrderable = queryOrderable;
+ super.setQueryOrderable(queryOrderable);
}
/**
@@ -209,11 +120,7 @@
public void setAvailableQueryOperators(String[] queryOperators) {
// reset id field in order to force lazy recomputation of identifier
id = null;
- if (queryOperators != null) {
- this.queryOperators = queryOperators;
- } else {
- this.queryOperators = new String[0];
- }
+ super.setAvailableQueryOperators(queryOperators);
}
//------------------------------------------------< ItemDefImpl overrides >
@@ -286,103 +193,4 @@
}
return id;
}
-
- /**
- * {@inheritDoc}
- */
- public int getRequiredType() {
- return requiredType;
- }
-
- /**
- * {@inheritDoc}
- */
- public QValueConstraint[] getValueConstraints() {
- return valueConstraints;
- }
-
- /**
- * {@inheritDoc}
- */
- public InternalValue[] getDefaultValues() {
- return defaultValues;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isMultiple() {
- return multiple;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return always <code>false</code>
- */
- public boolean definesNode() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public String[] getAvailableQueryOperators() {
- return queryOperators;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isFullTextSearchable() {
- return fullTextSearchable;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isQueryOrderable() {
- return queryOrderable;
- }
-
- //-------------------------------------------< java.lang.Object overrides >
- /**
- * 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) {
- 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
- && Arrays.equals(queryOperators, other.queryOperators)
- && queryOrderable == other.queryOrderable
- && fullTextSearchable == other.fullTextSearchable;
- }
- return false;
- }
-
- /**
- * Returns zero to satisfy the Object equals/hashCode contract.
- * This class is mutable and not meant to be used as a hash key.
- *
- * @return always zero
- * @see Object#hashCode()
- */
- public int hashCode() {
- return 0;
- }
-
}
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java Tue Sep 8 09:47:13 2009
@@ -21,8 +21,9 @@
import javax.jcr.ValueFactory;
import javax.jcr.nodetype.PropertyDefinition;
-import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.value.ValueFormat;
import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
@@ -54,7 +55,7 @@
* @param resolver name resolver
* @param valueFactory the value factory
*/
- PropertyDefinitionImpl(PropDef propDef, NodeTypeManagerImpl ntMgr,
+ PropertyDefinitionImpl(QPropertyDefinition propDef, NodeTypeManagerImpl ntMgr,
NamePathResolver resolver, ValueFactory valueFactory) {
super(propDef, ntMgr, resolver);
this.valueFactory = valueFactory;
@@ -74,7 +75,7 @@
* {@inheritDoc}
*/
public Value[] getDefaultValues() {
- InternalValue[] defVals = ((PropDef) itemDef).getDefaultValues();
+ QValue[] defVals = ((QPropertyDefinition) itemDef).getDefaultValues();
if (defVals == null) {
return null;
}
@@ -98,21 +99,21 @@
* {@inheritDoc}
*/
public int getRequiredType() {
- return ((PropDef) itemDef).getRequiredType();
+ return ((QPropertyDefinition) itemDef).getRequiredType();
}
/**
* {@inheritDoc}
*/
public String[] getValueConstraints() {
- QValueConstraint[] constraints = ((PropDef) itemDef).getValueConstraints();
+ QValueConstraint[] constraints = ((QPropertyDefinition) itemDef).getValueConstraints();
if (constraints == null || constraints.length == 0) {
return new String[0];
}
String[] vca = new String[constraints.length];
for (int i = 0; i < constraints.length; i++) {
try {
- ValueConstraint vc = ValueConstraint.create(((PropDef) itemDef).getRequiredType(), constraints[i].getString());
+ ValueConstraint vc = ValueConstraint.create(((QPropertyDefinition) itemDef).getRequiredType(), constraints[i].getString());
vca[i] = vc.getDefinition(resolver);
} catch (InvalidConstraintException e) {
log.warn("Error during conversion of value constraint.", e);
@@ -126,27 +127,27 @@
* {@inheritDoc}
*/
public boolean isMultiple() {
- return ((PropDef) itemDef).isMultiple();
+ return ((QPropertyDefinition) itemDef).isMultiple();
}
/**
* {@inheritDoc}
*/
public String[] getAvailableQueryOperators() {
- return ((PropDef) itemDef).getAvailableQueryOperators();
+ return ((QPropertyDefinition) itemDef).getAvailableQueryOperators();
}
/**
* {@inheritDoc}
*/
public boolean isFullTextSearchable() {
- return ((PropDef) itemDef).isFullTextSearchable();
+ return ((QPropertyDefinition) itemDef).isFullTextSearchable();
}
/**
* {@inheritDoc}
*/
public boolean isQueryOrderable() {
- return ((PropDef) itemDef).isQueryOrderable();
+ return ((QPropertyDefinition) itemDef).isQueryOrderable();
}
}
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Tue Sep 8 09:47:13 2009
@@ -25,11 +25,9 @@
import javax.jcr.version.OnParentVersionAction;
import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeDefId;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.state.ChangeLog;
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -38,6 +36,8 @@
import org.apache.jackrabbit.core.virtual.VirtualNodeState;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
/**
@@ -168,7 +168,7 @@
}
// add property defs
- PropDef[] propDefs = ntDef.getPropertyDefs();
+ QPropertyDefinition[] propDefs = ntDef.getPropertyDefs();
for (int i = 0; i < propDefs.length; i++) {
VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i);
ntState.addChildNodeEntry(NameConstants.JCR_PROPERTYDEFINITION, pdState.getNodeId());
@@ -177,7 +177,7 @@
}
// add child node defs
- NodeDef[] cnDefs = ntDef.getChildNodeDefs();
+ QNodeDefinition[] cnDefs = ntDef.getChildNodeDefs();
for (int i = 0; i < cnDefs.length; i++) {
VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i);
ntState.addChildNodeEntry(NameConstants.JCR_CHILDNODEDEFINITION, cnState.getNodeId());
@@ -197,7 +197,7 @@
* @throws RepositoryException
*/
private VirtualNodeState createPropertyDefState(VirtualNodeState parent,
- PropDef propDef,
+ QPropertyDefinition propDef,
NodeTypeDef ntDef, int n)
throws RepositoryException {
NodeId id = calculateStableId(
@@ -218,7 +218,7 @@
pState.setPropertyValue(
NameConstants.JCR_REQUIREDTYPE,
InternalValue.create(PropertyType.nameFromValue(propDef.getRequiredType()).toUpperCase()));
- InternalValue[] defVals = propDef.getDefaultValues();
+ InternalValue[] defVals = InternalValue.create(propDef.getDefaultValues());
// retrieve the property type from the first default value present with
// the property definition. in case no default values are defined,
// fallback to PropertyType.STRING in order to avoid creating a property
@@ -227,7 +227,9 @@
if (defVals != null && defVals.length > 0) {
defValsType = defVals[0].getType();
}
- pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
+ if (defVals != null) {
+ pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
+ }
QValueConstraint[] vc = propDef.getValueConstraints();
InternalValue[] vals = new InternalValue[vc.length];
for (int i = 0; i < vc.length; i++) {
@@ -246,7 +248,7 @@
* @throws RepositoryException
*/
private VirtualNodeState createChildNodeDefState(VirtualNodeState parent,
- NodeDef cnDef,
+ QNodeDefinition cnDef,
NodeTypeDef ntDef, int n)
throws RepositoryException {
NodeId id = calculateStableId(
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java Tue Sep 8 09:47:13 2009
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.core.nodetype.xml;
import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.ItemDef;
import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeDefImpl;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
@@ -34,6 +33,7 @@
import org.apache.jackrabbit.spi.commons.value.ValueFormat;
import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QValueFactory;
import org.apache.jackrabbit.spi.QValueConstraint;
@@ -217,7 +217,7 @@
PropDefImpl def = new PropDefImpl();
String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
if (name.equals("*")) {
- def.setName(ItemDef.ANY_NAME);
+ def.setName(NameConstants.ANY_NAME);
} else {
def.setName(resolver.getQName(name));
}
@@ -324,7 +324,7 @@
NodeDefImpl def = new NodeDefImpl();
String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
if (name.equals("*")) {
- def.setName(ItemDef.ANY_NAME);
+ def.setName(NameConstants.ANY_NAME);
} else {
def.setName(resolver.getQName(name));
}
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java Tue Sep 8 09:47:13 2009
@@ -16,11 +16,8 @@
*/
package org.apache.jackrabbit.core.nodetype.xml;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.util.DOMBuilder;
-import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.core.value.InternalValueFactory;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
@@ -30,6 +27,9 @@
import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import javax.jcr.NamespaceRegistry;
import javax.jcr.PropertyType;
@@ -165,14 +165,14 @@
}
// property definitions
- PropDef[] properties = def.getPropertyDefs();
- for (PropDef property : properties) {
+ QPropertyDefinition[] properties = def.getPropertyDefs();
+ for (QPropertyDefinition property : properties) {
addPropDef(property);
}
// child node definitions
- NodeDef[] nodes = def.getChildNodeDefs();
- for (NodeDef node : nodes) {
+ QNodeDefinition[] nodes = def.getChildNodeDefs();
+ for (QNodeDefinition node : nodes) {
addChildNodeDef(node);
}
@@ -188,7 +188,7 @@
* @throws NamespaceException if the property definition contains
* invalid namespace references
*/
- private void addPropDef(PropDef def)
+ private void addPropDef(QPropertyDefinition def)
throws NamespaceException, RepositoryException {
builder.startElement(Constants.PROPERTYDEFINITION_ELEMENT);
@@ -261,10 +261,10 @@
}
// default values
- InternalValue[] defaults = def.getDefaultValues();
+ QValue[] defaults = def.getDefaultValues();
if (defaults != null && defaults.length > 0) {
builder.startElement(Constants.DEFAULTVALUES_ELEMENT);
- for (InternalValue v : defaults) {
+ for (QValue v : defaults) {
builder.addContentElement(
Constants.DEFAULTVALUE_ELEMENT,
factory.createValue(v).getString());
@@ -282,7 +282,7 @@
* @throws NamespaceException if the child node definition contains
* invalid namespace references
*/
- private void addChildNodeDef(NodeDef def)
+ private void addChildNodeDef(QNodeDefinition def)
throws NamespaceException {
builder.startElement(Constants.CHILDNODEDEFINITION_ELEMENT);
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/PropertyTypeRegistry.java Tue Sep 8 09:47:13 2009
@@ -19,8 +19,8 @@
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistryListener;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -87,9 +87,9 @@
public void nodeTypeRegistered(Name ntName) {
try {
NodeTypeDef def = registry.getNodeTypeDef(ntName);
- PropDef[] propDefs = def.getPropertyDefs();
+ QPropertyDefinition[] propDefs = def.getPropertyDefs();
synchronized (typeMapping) {
- for (PropDef propDef : propDefs) {
+ for (QPropertyDefinition propDef : propDefs) {
int type = propDef.getRequiredType();
if (!propDef.definesResidual() && type != PropertyType.UNDEFINED) {
Name name = propDef.getName();
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Tue Sep 8 09:47:13 2009
@@ -35,10 +35,10 @@
import org.apache.jackrabbit.core.id.ItemId;
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
import org.apache.jackrabbit.core.util.Dumpable;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -867,7 +867,7 @@
} catch (ItemStateException e) {
return false;
}
- NodeDef def = ntReg.getNodeDef(ns.getDefinitionId());
+ QNodeDefinition def = ntReg.getNodeDef(ns.getDefinitionId());
return def != null ? def.allowsSameNameSiblings() : false;
}
};
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Tue Sep 8 09:47:13 2009
@@ -33,7 +33,6 @@
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.id.PropertyId;
import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeDefId;
import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
@@ -47,6 +46,7 @@
import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -631,7 +631,7 @@
} catch (ItemStateException e) {
return false;
}
- NodeDef def = ntReg.getNodeDef(ns.getDefinitionId());
+ QNodeDefinition def = ntReg.getNodeDef(ns.getDefinitionId());
return def != null ? def.allowsSameNameSiblings() : false;
}
};
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java Tue Sep 8 09:47:13 2009
@@ -242,6 +242,18 @@
}
}
+ public static InternalValue[] create(QValue[] values)
+ throws RepositoryException {
+ if (values == null) {
+ return null;
+ }
+ InternalValue[] tmp = new InternalValue[values.length];
+ for (int i = 0; i < values.length; i++) {
+ tmp[i] = InternalValue.create(values[i]);
+ }
+ return tmp;
+ }
+
static InternalValue getInternalValue(DataIdentifier identifier, DataStore store) throws DataStoreException {
// access the record to ensure it is not garbage collected
if (store.getRecordIfStored(identifier) != null) {
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java Tue Sep 8 09:47:13 2009
@@ -42,6 +42,8 @@
import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QItemDefinition;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
/**
@@ -826,7 +828,7 @@
* Returns the NodeDef for this state
* @return the node def
*/
- public NodeDef getDefinition() {
+ public QItemDefinition getDefinition() {
return ntReg.getNodeDef(nodeState.getDefinitionId());
}
@@ -835,7 +837,7 @@
* @param prop the property state
* @return the prop def
*/
- public PropDef getDefinition(PropertyState prop) {
+ public QPropertyDefinition getDefinition(PropertyState prop) {
return ntReg.getPropDef(prop.getDefinitionId());
}
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java Tue Sep 8 09:47:13 2009
@@ -34,7 +34,6 @@
import org.apache.jackrabbit.core.ItemValidator;
import org.apache.jackrabbit.core.SessionImpl;
import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.security.authorization.Permission;
import org.apache.jackrabbit.core.state.ChildNodeEntry;
import org.apache.jackrabbit.core.state.ItemStateException;
@@ -43,6 +42,7 @@
import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -428,7 +428,7 @@
}
// add 'auto-create' properties that do not exist yet
- for (PropDef def: state.getEffectiveNodeType().getAutoCreatePropDefs()) {
+ for (QPropertyDefinition def: state.getEffectiveNodeType().getAutoCreatePropDefs()) {
if (!state.hasProperty(def.getName())) {
InternalValue[] values = computeAutoValues(state, def, true);
if (values != null) {
@@ -644,14 +644,16 @@
* @param def property definition
* @param useDefaultValues if <code>true</code> the default values are respected
* @return the values or <code>null</code>
+ * @throws RepositoryException if the values cannot be computed.
*/
- private InternalValue[] computeAutoValues(NodeStateEx state, PropDef def,
- boolean useDefaultValues) {
+ private InternalValue[] computeAutoValues(NodeStateEx state, QPropertyDefinition def,
+ boolean useDefaultValues)
+ throws RepositoryException {
// compute system generated values if necessary
InternalValue[] values = session.getNodeTypeInstanceHandler().
computeSystemGeneratedPropertyValues(state.getState(), def);
if (values == null && useDefaultValues) {
- values = def.getDefaultValues();
+ values = InternalValue.create(def.getDefaultValues());
}
// avoid empty value array for single value property
if (values != null && values.length == 0 && !def.isMultiple()) {
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DefaultProtectedPropertyImporter.java Tue Sep 8 09:47:13 2009
@@ -20,9 +20,9 @@
import org.apache.jackrabbit.core.NodeImpl;
import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
/**
* Default implementation that isn't able to handle any protected properties.
@@ -46,18 +46,18 @@
/**
* Always returns <code>false</code>.
*
- * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.NodeImpl, PropInfo, org.apache.jackrabbit.core.nodetype.PropDef)
+ * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.NodeImpl, PropInfo, QPropertyDefinition)
*/
- public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, PropDef def) {
+ public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def) {
return false;
}
/**
* Always returns <code>false</code>.
*
- * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.state.NodeState, PropInfo, PropDef)
+ * @see ProtectedPropertyImporter#handlePropInfo(org.apache.jackrabbit.core.state.NodeState, PropInfo, QPropertyDefinition)
*/
- public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, PropDef def) throws RepositoryException {
+ public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws RepositoryException {
return false;
}
}
\ No newline at end of file
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/PropInfo.java Tue Sep 8 09:47:13 2009
@@ -26,9 +26,8 @@
import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.state.NodeState;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Information about a property being imported. This class is used
@@ -79,7 +78,7 @@
}
}
- public int getTargetType(PropDef def) {
+ public int getTargetType(QPropertyDefinition def) {
int target = def.getRequiredType();
if (target != PropertyType.UNDEFINED) {
return target;
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ProtectedPropertyImporter.java Tue Sep 8 09:47:13 2009
@@ -19,8 +19,8 @@
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
/**
* <code>ProtectedPropertyImporter</code> is in charge of importing single
@@ -42,7 +42,7 @@
* <code>false</code> otherwise.
* @throws RepositoryException If an error occurs.
*/
- boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, PropDef def)
+ boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def)
throws RepositoryException;
/**
@@ -56,7 +56,7 @@
* <code>false</code> otherwise.
* @throws RepositoryException If an error occurs.
*/
- boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, PropDef def)
+ boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def)
throws RepositoryException;
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java Tue Sep 8 09:47:13 2009
@@ -35,10 +35,10 @@
import org.apache.jackrabbit.core.NodeImpl;
import org.apache.jackrabbit.core.SessionImpl;
import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.nodetype.PropDef;
import org.apache.jackrabbit.core.security.authorization.Permission;
import org.apache.jackrabbit.core.util.ReferenceChangeTracker;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -153,7 +153,7 @@
}
- protected void createProperty(NodeImpl node, PropInfo pInfo, PropDef def) throws RepositoryException {
+ protected void createProperty(NodeImpl node, PropInfo pInfo, QPropertyDefinition def) throws RepositoryException {
// convert serialized values to Value objects
Value[] va = pInfo.getValues(pInfo.getTargetType(def), session);
@@ -369,7 +369,7 @@
for (PropInfo pi : propInfos) {
// find applicable definition
- PropDef def = pi.getApplicablePropertyDef(node.getEffectiveNodeType());
+ QPropertyDefinition def = pi.getApplicablePropertyDef(node.getEffectiveNodeType());
if (def.isProtected()) {
// skip protected property
log.debug("Skipping protected property " + pi.getName());
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java Tue Sep 8 09:47:13 2009
@@ -50,6 +50,7 @@
import org.apache.jackrabbit.core.version.VersionHistoryInfo;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.slf4j.Logger;
@@ -492,7 +493,7 @@
parent.getChildNodeEntry(nodeName, 1);
NodeId idExisting = entry.getId();
NodeState existing = (NodeState) itemOps.getItemState(idExisting);
- NodeDef def = ntReg.getNodeDef(existing.getDefinitionId());
+ QNodeDefinition def = ntReg.getNodeDef(existing.getDefinitionId());
if (!def.allowsSameNameSiblings()) {
// existing doesn't allow same-name siblings,
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java Tue Sep 8 09:47:13 2009
@@ -21,6 +21,7 @@
import org.apache.jackrabbit.test.AbstractJCRTest;
import org.apache.jackrabbit.spi.NameFactory;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java Tue Sep 8 09:47:13 2009
@@ -20,17 +20,18 @@
import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.core.value.InternalValueFactory;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
import org.apache.jackrabbit.test.AbstractJCRTest;
@@ -126,16 +127,16 @@
* @param propertyName property name, or <code>null</code>
* @return property definition
*/
- private PropDef getPropDef(String typeName, String propertyName) {
+ private QPropertyDefinition getPropDef(String typeName, String propertyName) {
Name name;
if (propertyName != null) {
name = FACTORY.create(TEST_NAMESPACE, propertyName);
} else {
- name = PropDef.ANY_NAME;
+ name = NameConstants.ANY_NAME;
}
NodeTypeDef def = getNodeType(typeName);
- PropDef[] defs = def.getPropertyDefs();
+ QPropertyDefinition[] defs = def.getPropertyDefs();
for (int i = 0; i < defs.length; i++) {
if (name.equals(defs[i].getName())) {
return defs[i];
@@ -153,9 +154,9 @@
* @param index default value index
* @return default value
*/
- private String getDefaultValue(PropDef def, int index) {
+ private String getDefaultValue(QPropertyDefinition def, int index) {
try {
- InternalValue[] values = def.getDefaultValues();
+ QValue[] values = def.getDefaultValues();
NamespaceResolver nsResolver = new AdditionalNamespaceResolver(registry);
NamePathResolver resolver = new DefaultNamePathResolver(nsResolver);
ValueFactoryQImpl factory = new ValueFactoryQImpl(InternalValueFactory.getInstance(), resolver);
@@ -174,11 +175,11 @@
* @param nodeName child node name
* @return child node definition
*/
- private NodeDef getChildNode(String typeName, String nodeName) {
+ private QNodeDefinition getChildNode(String typeName, String nodeName) {
Name name = FACTORY.create(TEST_NAMESPACE, nodeName);
NodeTypeDef def = getNodeType(typeName);
- NodeDef[] defs = def.getChildNodeDefs();
+ QNodeDefinition[] defs = def.getChildNodeDefs();
for (int i = 0; i < defs.length; i++) {
if (name.equals(defs[i].getName())) {
return defs[i];
@@ -236,7 +237,7 @@
def.getPrimaryItemName());
assertEquals("itemNodeType propertyDefs",
10, def.getPropertyDefs().length);
- PropDef pdef = getPropDef("itemNodeType", null);
+ QPropertyDefinition pdef = getPropDef("itemNodeType", null);
assertTrue("itemNodeType wildcard property", pdef.definesResidual());
}
@@ -317,7 +318,7 @@
/** Test for the empty item definition. */
public void testEmptyItem() {
- PropDef def = getPropDef("itemNodeType", "emptyItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "emptyItem");
assertEquals("emptyItem autoCreate",
false, def.isAutoCreated());
assertEquals("emptyItem mandatory",
@@ -330,56 +331,56 @@
/** Test for the <code>autoCreated</code> item definition attribute. */
public void testAutoCreateItem() {
- PropDef def = getPropDef("itemNodeType", "autoCreatedItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "autoCreatedItem");
assertEquals("autoCreatedItem autoCreated",
true, def.isAutoCreated());
}
/** Test for the <code>mandatory</code> item definition attribute. */
public void testMandatoryItem() {
- PropDef def = getPropDef("itemNodeType", "mandatoryItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "mandatoryItem");
assertEquals("mandatoryItem mandatory",
true, def.isMandatory());
}
/** Test for the <code>copy</code> parent version action. */
public void testCopyItem() {
- PropDef def = getPropDef("itemNodeType", "copyItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "copyItem");
assertEquals("copyItem onParentVersion",
OnParentVersionAction.COPY, def.getOnParentVersion());
}
/** Test for the <code>version</code> parent version action. */
public void testVersionItem() {
- PropDef def = getPropDef("itemNodeType", "versionItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "versionItem");
assertEquals("versionItem onParentVersion",
OnParentVersionAction.VERSION, def.getOnParentVersion());
}
/** Test for the <code>initialize</code> parent version action. */
public void testInitializeItem() {
- PropDef def = getPropDef("itemNodeType", "initializeItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "initializeItem");
assertEquals("initializeItem onParentVersion",
OnParentVersionAction.INITIALIZE, def.getOnParentVersion());
}
/** Test for the <code>compute</code> parent version action. */
public void testComputeItem() {
- PropDef def = getPropDef("itemNodeType", "computeItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "computeItem");
assertEquals("computeItem onParentVersion",
OnParentVersionAction.COMPUTE, def.getOnParentVersion());
}
/** Test for the <code>abort</code> parent version action. */
public void testAbortItem() {
- PropDef def = getPropDef("itemNodeType", "abortItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "abortItem");
assertEquals("abortItem onParentVersion",
OnParentVersionAction.ABORT, def.getOnParentVersion());
}
/** Test for the <code>protected</code> item definition attribute. */
public void testProtectedItem() {
- PropDef def = getPropDef("itemNodeType", "protectedItem");
+ QPropertyDefinition def = getPropDef("itemNodeType", "protectedItem");
assertEquals("protectedItem protected",
true, def.isProtected());
}
@@ -393,7 +394,7 @@
/** Test for the empty property definition. */
public void testEmptyProperty() {
- PropDef def = getPropDef("propertyNodeType", "emptyProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "emptyProperty");
assertEquals("emptyProperty requiredType",
PropertyType.UNDEFINED, def.getRequiredType());
assertEquals("emptyProperty multiple",
@@ -406,7 +407,7 @@
/** Test for the <code>binary</code> property definition type. */
public void testBinaryProperty() {
- PropDef def = getPropDef("propertyNodeType", "binaryProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "binaryProperty");
assertEquals("binaryProperty requiredType",
PropertyType.BINARY, def.getRequiredType());
assertEquals("binaryProperty valueConstraints",
@@ -419,7 +420,7 @@
/** Test for the <code>boolean</code> property definition type. */
public void testBooleanProperty() {
- PropDef def = getPropDef("propertyNodeType", "booleanProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "booleanProperty");
assertEquals("booleanProperty requiredType",
PropertyType.BOOLEAN, def.getRequiredType());
assertEquals("booleanProperty valueConstraints",
@@ -436,7 +437,7 @@
/** Test for the <code>date</code> property definition type. */
public void testDateProperty() {
- PropDef def = getPropDef("propertyNodeType", "dateProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "dateProperty");
assertEquals("dateProperty requiredType",
PropertyType.DATE, def.getRequiredType());
assertEquals("dateProperty valueConstraints",
@@ -452,7 +453,7 @@
/** Test for the <code>double</code> property definition type. */
public void testDoubleProperty() {
- PropDef def = getPropDef("propertyNodeType", "doubleProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "doubleProperty");
assertEquals("doubleProperty requiredType",
PropertyType.DOUBLE, def.getRequiredType());
assertEquals("doubleProperty valueConstraints",
@@ -471,7 +472,7 @@
/** Test for the <code>long</code> property definition type. */
public void testLongProperty() {
- PropDef def = getPropDef("propertyNodeType", "longProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "longProperty");
assertEquals("longProperty requiredType",
PropertyType.LONG, def.getRequiredType());
assertEquals("longProperty valueConstraints",
@@ -490,7 +491,7 @@
/** Test for the <code>name</code> property definition type. */
public void testNameProperty() {
- PropDef def = getPropDef("propertyNodeType", "nameProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "nameProperty");
assertEquals("nameProperty requiredType",
PropertyType.NAME, def.getRequiredType());
assertEquals("nameProperty valueConstraints",
@@ -506,7 +507,7 @@
/** Test for the <code>path</code> property definition type. */
public void testPathProperty() {
- PropDef def = getPropDef("propertyNodeType", "pathProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty");
assertEquals("pathProperty requiredType",
PropertyType.PATH, def.getRequiredType());
assertEquals("pathProperty valueConstraints",
@@ -520,7 +521,7 @@
/** Test for the <code>path</code> property definition type. */
public void testPathProperty1() {
- PropDef def = getPropDef("propertyNodeType", "pathProperty1");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty1");
assertEquals("pathProperty requiredType",
PropertyType.PATH, def.getRequiredType());
assertEquals("pathProperty valueConstraints",
@@ -534,7 +535,7 @@
/** Test for the <code>path</code> property definition type. */
public void testPathProperty2() {
- PropDef def = getPropDef("propertyNodeType", "pathProperty2");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty2");
assertEquals("pathProperty requiredType",
PropertyType.PATH, def.getRequiredType());
assertEquals("pathProperty valueConstraints",
@@ -548,7 +549,7 @@
/** Test for the <code>reference</code> property definition type. */
public void testReferenceProperty() {
- PropDef def = getPropDef("propertyNodeType", "referenceProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "referenceProperty");
assertEquals("referenceProperty requiredType",
PropertyType.REFERENCE, def.getRequiredType());
assertEquals("referenceProperty valueConstraints",
@@ -562,7 +563,7 @@
/** Test for the <code>string</code> property definition type. */
public void testStringProperty() {
- PropDef def = getPropDef("propertyNodeType", "stringProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "stringProperty");
assertEquals("stringProperty requiredType",
PropertyType.STRING, def.getRequiredType());
assertEquals("stringProperty valueConstraints",
@@ -580,7 +581,7 @@
/** Test for the <code>multiple</code> property definition attribute. */
public void testMultipleProperty() {
- PropDef def = getPropDef("propertyNodeType", "multipleProperty");
+ QPropertyDefinition def = getPropDef("propertyNodeType", "multipleProperty");
assertEquals("multipleProperty multiple",
true, def.isMultiple());
}
@@ -594,7 +595,7 @@
/** Test for the empty child node definition. */
public void testEmptyNode() {
- NodeDef def = getChildNode("childNodeType", "emptyNode");
+ QNodeDefinition def = getChildNode("childNodeType", "emptyNode");
assertEquals("emptyNode allowsSameNameSiblings",
false, def.allowsSameNameSiblings());
assertEquals("emptyNode defaultPrimaryType",
@@ -603,14 +604,14 @@
/** Test for the <code>allowsSameNameSiblings</code> child node attribute. */
public void testSiblingNode() {
- NodeDef def = getChildNode("childNodeType", "siblingNode");
+ QNodeDefinition def = getChildNode("childNodeType", "siblingNode");
assertEquals("siblingNode allowsSameNameSiblings",
true, def.allowsSameNameSiblings());
}
/** Test for the <code>defaultPrimaryType</code> child node attribute. */
public void testDefaultTypeNode() {
- NodeDef def = getChildNode("childNodeType", "defaultTypeNode");
+ QNodeDefinition def = getChildNode("childNodeType", "defaultTypeNode");
assertEquals("defaultTypeNode defaultPrimaryType",
FACTORY.create(Name.NS_NT_URI, "base"),
def.getDefaultPrimaryType());
@@ -618,7 +619,7 @@
/** Test for the <code>requiredPrimaryTypes</code> child node attributes. */
public void testRequiredTypeNode() {
- NodeDef def = getChildNode("childNodeType", "requiredTypeNode");
+ QNodeDefinition def = getChildNode("childNodeType", "requiredTypeNode");
assertEquals("requiredTypeNode requiredPrimaryTypes",
2, def.getRequiredPrimaryTypes().length);
Name[] types = def.getRequiredPrimaryTypes();
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java Tue Sep 8 09:47:13 2009
@@ -20,10 +20,12 @@
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
import java.io.Serializable;
+import javax.jcr.version.OnParentVersionAction;
+
/**
* This abstract class implements the <code>QItemDefinition</code>
* interface and additionally provides setter methods for the
@@ -32,40 +34,34 @@
public abstract class QItemDefinitionImpl implements QItemDefinition, Serializable {
/**
- * The special wildcard name used as the name of residual item definitions.
- * TODO don't rely on specific factory impl
- */
- public static final Name ANY_NAME = NameFactoryImpl.getInstance().create("", "*");
-
- /**
* The name of the child item.
*/
- private final Name name;
+ private Name name;
/**
* The name of the declaring node type.
*/
- private final Name declaringNodeType;
+ private Name declaringNodeType;
/**
* The 'autoCreated' flag.
*/
- private final boolean autoCreated;
+ private boolean autoCreated;
/**
* The 'onParentVersion' attribute.
*/
- private final int onParentVersion;
+ private int onParentVersion;
/**
* The 'protected' flag.
*/
- private final boolean writeProtected;
+ private boolean writeProtected;
/**
* The 'mandatory' flag.
*/
- private final boolean mandatory;
+ private boolean mandatory;
/**
* HashCode of this object
@@ -73,6 +69,14 @@
protected transient int hashCode = 0;
/**
+ * Default constructor.
+ */
+ public QItemDefinitionImpl() {
+ this(NameConstants.ANY_NAME, null, false, false,
+ OnParentVersionAction.COPY, false);
+ }
+
+ /**
* Creates a new <code>QItemDefinitionImpl</code>.
*
* @param name the name of the child item.
@@ -82,7 +86,7 @@
* @param onParentVersion the on parent version behaviour.
* @param isProtected if this item is protected.
*/
- QItemDefinitionImpl(Name name, Name declaringNodeType,
+ public QItemDefinitionImpl(Name name, Name declaringNodeType,
boolean isAutoCreated, boolean isMandatory,
int onParentVersion, boolean isProtected) {
this.name = name;
@@ -93,6 +97,75 @@
this.writeProtected = isProtected;
}
+ /**
+ * Sets the name of declaring node type.
+ *
+ * @param declaringNodeType name of the declaring node type (must not be
+ * <code>null</code>)
+ */
+ public void setDeclaringNodeType(Name declaringNodeType) {
+ if (declaringNodeType == null) {
+ throw new IllegalArgumentException("declaringNodeType can not be null");
+ }
+ this.declaringNodeType = declaringNodeType;
+ }
+
+ /**
+ * Sets the name of the child item.
+ *
+ * @param name name of child item (must not be <code>null</code>)
+ */
+ public void setName(Name name) {
+ if (name == null) {
+ throw new IllegalArgumentException("name can not be null");
+ }
+ this.name = name;
+ }
+
+ /**
+ * Sets the 'autoCreated' flag.
+ *
+ * @param autoCreated a <code>boolean</code>
+ */
+ public void setAutoCreated(boolean autoCreated) {
+ this.autoCreated = autoCreated;
+ }
+
+ /**
+ * Sets the 'onParentVersion' attribute.
+ *
+ * @param onParentVersion any of the following constants:
+ * <UL>
+ * <LI><code>OnParentVersionAction.COPY</code>
+ * <LI><code>OnParentVersionAction.VERSION</code>
+ * <LI><code>OnParentVersionAction.INITIALIZE</code>
+ * <LI><code>OnParentVersionAction.COMPUTE</code>
+ * <LI><code>OnParentVersionAction.IGNORE</code>
+ * <LI><code>OnParentVersionAction.ABORT</code>
+ * </UL>
+ */
+ public void setOnParentVersion(int onParentVersion) {
+ this.onParentVersion = onParentVersion;
+ }
+
+ /**
+ * Sets the 'protected' flag.
+ *
+ * @param writeProtected a <code>boolean</code>
+ */
+ public void setProtected(boolean writeProtected) {
+ this.writeProtected = writeProtected;
+ }
+
+ /**
+ * Sets the 'mandatory' flag.
+ *
+ * @param mandatory a <code>boolean</code>
+ */
+ public void setMandatory(boolean mandatory) {
+ this.mandatory = mandatory;
+ }
+
//--------------------------------------------------------------< QItemDefinition >
/**
* {@inheritDoc}
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java Tue Sep 8 09:47:13 2009
@@ -18,9 +18,12 @@
import org.apache.jackrabbit.spi.QNodeDefinition;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
import java.util.Arrays;
import java.util.TreeSet;
+import java.util.Set;
+import java.util.HashSet;
/**
* <code>QNodeDefinitionImpl</code> implements a <code>QNodeDefinition</code>.
@@ -30,17 +33,25 @@
/**
* The name of the default primary type.
*/
- private final Name defaultPrimaryType;
+ private Name defaultPrimaryType;
/**
* The names of the required primary types.
*/
- private final Name[] requiredPrimaryTypes;
+ private final Set<Name> requiredPrimaryTypes = new HashSet<Name>();
/**
* The 'allowsSameNameSiblings' flag.
*/
- private final boolean allowsSameNameSiblings;
+ private boolean allowsSameNameSiblings;
+
+ /**
+ * Default constructor.
+ */
+ public QNodeDefinitionImpl() {
+ super();
+ requiredPrimaryTypes.add(NameConstants.NT_BASE);
+ }
/**
* Copy constructor.
@@ -77,11 +88,43 @@
super(name, declaringNodeType, isAutoCreated, isMandatory,
onParentVersion, isProtected);
this.defaultPrimaryType = defaultPrimaryType;
- this.requiredPrimaryTypes = requiredPrimaryTypes;
+ this.requiredPrimaryTypes.addAll(Arrays.asList(requiredPrimaryTypes));
+ this.allowsSameNameSiblings = allowsSameNameSiblings;
+ }
+
+ /**
+ * Sets the name of default primary type.
+ *
+ * @param defaultNodeType the name of the default primary type.
+ */
+ public void setDefaultPrimaryType(Name defaultNodeType) {
+ this.defaultPrimaryType = defaultNodeType;
+ }
+
+ /**
+ * Sets the names of the required primary types.
+ *
+ * @param requiredPrimaryTypes the names of the required primary types.
+ */
+ public void setRequiredPrimaryTypes(Name[] requiredPrimaryTypes) {
+ if (requiredPrimaryTypes == null) {
+ throw new IllegalArgumentException("requiredPrimaryTypes can not be null");
+ }
+ this.requiredPrimaryTypes.clear();
+ this.requiredPrimaryTypes.addAll(Arrays.asList(requiredPrimaryTypes));
+ }
+
+ /**
+ * Sets the 'allowsSameNameSiblings' flag.
+ *
+ * @param allowsSameNameSiblings whether to allow same named siblings.
+ */
+ public void setAllowsSameNameSiblings(boolean allowsSameNameSiblings) {
this.allowsSameNameSiblings = allowsSameNameSiblings;
}
//-------------------------------------------------------< QNodeDefinition >
+
/**
* {@inheritDoc}
*/
@@ -93,7 +136,7 @@
* {@inheritDoc}
*/
public Name[] getRequiredPrimaryTypes() {
- return requiredPrimaryTypes;
+ return requiredPrimaryTypes.toArray(new Name[requiredPrimaryTypes.size()]);
}
/**
@@ -130,7 +173,8 @@
if (obj instanceof QNodeDefinition) {
QNodeDefinition other = (QNodeDefinition) obj;
return super.equals(obj)
- && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes())
+ && requiredPrimaryTypes.equals(new HashSet<Name>(
+ Arrays.asList(other.getRequiredPrimaryTypes())))
&& (defaultPrimaryType == null
? other.getDefaultPrimaryType() == null
: defaultPrimaryType.equals(other.getDefaultPrimaryType()))
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java Tue Sep 8 09:47:13 2009
@@ -25,6 +25,7 @@
import org.apache.jackrabbit.spi.QValueFactory;
import org.apache.jackrabbit.spi.QValueConstraint;
import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -40,23 +41,26 @@
import java.util.HashSet;
import java.util.Collections;
import java.util.Arrays;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Set;
import java.io.Serializable;
/**
* <code>QNodeTypeDefinitionImpl</code> implements a serializable SPI node
* type definition.
*/
-public class QNodeTypeDefinitionImpl implements QNodeTypeDefinition, Serializable {
+public class QNodeTypeDefinitionImpl implements QNodeTypeDefinition, Serializable, Cloneable {
/**
* The name of the node definition.
*/
- private final Name name;
+ private Name name;
/**
* The names of the declared super types of this node type definition.
*/
- private final Name[] supertypes;
+ private Name[] supertypes;
/**
* The names of the supported mixins on this node type (or <code>null</code>)
@@ -66,37 +70,37 @@
/**
* Indicates whether this is a mixin node type definition.
*/
- private final boolean isMixin;
+ private boolean isMixin;
/**
* Indicates whether this is an abstract node type definition.
*/
- private final boolean isAbstract;
+ private boolean isAbstract;
/**
* Indicates whether this is a queryable node type definition.
*/
- private final boolean isQueryable;
+ private boolean isQueryable;
/**
* Indicates whether this node type definition has orderable child nodes.
*/
- private final boolean hasOrderableChildNodes;
+ private boolean hasOrderableChildNodes;
/**
* The name of the primary item or <code>null</code> if none is defined.
*/
- private final Name primaryItemName;
+ private Name primaryItemName;
/**
- * The list of property definitions.
+ * The list of child node definitions.
*/
- private final QPropertyDefinition[] propertyDefs;
+ private final Set<QPropertyDefinition> propertyDefs;
/**
- * The list of child node definitions.
+ * The list of property definitions.
*/
- private final QNodeDefinition[] childNodeDefs;
+ private final Set<QNodeDefinition> childNodeDefs;
/**
* Unmodifiable collection of dependent node type <code>Name</code>s.
@@ -105,6 +109,14 @@
private transient Collection<Name> dependencies;
/**
+ * Default constructor.
+ */
+ public QNodeTypeDefinitionImpl() {
+ this(null, Name.EMPTY_ARRAY, null, false, false, true, false, null,
+ QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
+ }
+
+ /**
* Copy constructor.
*
* @param nt the node type definition.
@@ -143,7 +155,6 @@
QPropertyDefinition[] declaredPropDefs,
QNodeDefinition[] declaredNodeDefs) {
this.name = name;
- this.supertypes = supertypes;
this.supportedMixins = supportedMixins;
this.isMixin = isMixin;
this.isAbstract = isAbstract;
@@ -152,6 +163,7 @@
this.primaryItemName = primaryItemName;
this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs);
this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs);
+ setSupertypes(supertypes); // make sure supertypes are sorted
}
/**
@@ -194,7 +206,105 @@
createQNodeDefinitions(name, def.getDeclaredChildNodeDefinitions(), resolver));
}
+ /**
+ * Sets the name of the node type being defined.
+ *
+ * @param name The name of the node type.
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the supertypes.
+ *
+ * @param names the names of the supertypes.
+ */
+ public void setSupertypes(Name[] names) {
+ resetDependencies();
+ // Optimize common cases (zero or one supertypes)
+ if (names.length == 0) {
+ supertypes = Name.EMPTY_ARRAY;
+ } else if (names.length == 1) {
+ supertypes = new Name[] { names[0] };
+ } else {
+ // Sort and remove duplicates
+ SortedSet<Name> types = new TreeSet<Name>();
+ types.addAll(Arrays.asList(names));
+ supertypes = types.toArray(new Name[types.size()]);
+ }
+ }
+
+ /**
+ * Sets the mixin flag.
+ *
+ * @param mixin flag
+ */
+ public void setMixin(boolean mixin) {
+ this.isMixin = mixin;
+ }
+
+ /**
+ * Sets the orderableChildNodes flag.
+ *
+ * @param orderableChildNodes flag
+ */
+ public void setOrderableChildNodes(boolean orderableChildNodes) {
+ this.hasOrderableChildNodes = orderableChildNodes;
+ }
+
+ /**
+ * Sets the 'abstract' flag.
+ *
+ * @param abstractStatus flag
+ */
+ public void setAbstract(boolean abstractStatus) {
+ this.isAbstract = abstractStatus;
+ }
+
+ /**
+ * Sets the 'queryable' flag.
+ *
+ * @param queryable flag
+ */
+ public void setQueryable(boolean queryable) {
+ this.isQueryable = queryable;
+ }
+
+ /**
+ * Sets the name of the primary item (one of the child items of the node's
+ * of this node type)
+ *
+ * @param primaryItemName The name of the primary item.
+ */
+ public void setPrimaryItemName(Name primaryItemName) {
+ this.primaryItemName = primaryItemName;
+ }
+
+ /**
+ * Sets the property definitions.
+ *
+ * @param defs An array of <code>QPropertyDefinition</code> objects.
+ */
+ public void setPropertyDefs(QPropertyDefinition[] defs) {
+ resetDependencies();
+ propertyDefs.clear();
+ propertyDefs.addAll(Arrays.asList(defs));
+ }
+
+ /**
+ * Sets the child node definitions.
+ *
+ * @param defs An array of <code>QNodeDefinition</code> objects
+ */
+ public void setChildNodeDefs(QNodeDefinition[] defs) {
+ resetDependencies();
+ childNodeDefs.clear();
+ childNodeDefs.addAll(Arrays.asList(defs));
+ }
+
//------------------------------------------------< QNodeTypeDefinition >---
+
/**
* {@inheritDoc}
*/
@@ -206,9 +316,12 @@
* {@inheritDoc}
*/
public Name[] getSupertypes() {
- Name[] sTypes = new Name[supertypes.length];
- System.arraycopy(supertypes, 0, sTypes, 0, supertypes.length);
- return sTypes;
+ if (supertypes.length > 0
+ || isMixin() || NameConstants.NT_BASE.equals(getName())) {
+ return supertypes;
+ } else {
+ return new Name[] { NameConstants.NT_BASE };
+ }
}
/**
@@ -250,24 +363,20 @@
* {@inheritDoc}
*/
public QPropertyDefinition[] getPropertyDefs() {
- QPropertyDefinition[] pDefs = new QPropertyDefinition[propertyDefs.length];
- System.arraycopy(propertyDefs, 0, pDefs, 0, propertyDefs.length);
- return pDefs;
+ return propertyDefs.toArray(new QPropertyDefinition[propertyDefs.size()]);
}
/**
* {@inheritDoc}
*/
public QNodeDefinition[] getChildNodeDefs() {
- QNodeDefinition[] cnDefs = new QNodeDefinition[childNodeDefs.length];
- System.arraycopy(childNodeDefs, 0, cnDefs, 0, childNodeDefs.length);
- return cnDefs;
+ return childNodeDefs.toArray(new QNodeDefinition[childNodeDefs.size()]);
}
/**
* {@inheritDoc}
*/
- public Collection getDependencies() {
+ public Collection<Name> getDependencies() {
if (dependencies == null) {
Collection<Name> deps = new HashSet<Name>();
// supertypes
@@ -320,46 +429,92 @@
}
}
+ //-------------------------------------------< java.lang.Object overrides >
+
+ public QNodeTypeDefinitionImpl clone() {
+ try {
+ // todo: itemdefs should be cloned as well, since mutable
+ return (QNodeTypeDefinitionImpl) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // does not happen, this class is cloneable
+ throw new InternalError();
+ }
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof QNodeTypeDefinitionImpl) {
+ QNodeTypeDefinitionImpl other = (QNodeTypeDefinitionImpl) obj;
+ return (name == null ? other.name == null : name.equals(other.name))
+ && (primaryItemName == null ? other.primaryItemName == null : primaryItemName.equals(other.primaryItemName))
+ && Arrays.equals(getSupertypes(), other.getSupertypes())
+ && isMixin == other.isMixin
+ && hasOrderableChildNodes == other.hasOrderableChildNodes
+ && isAbstract == other.isAbstract
+ && isQueryable == other.isQueryable
+ && propertyDefs.equals(other.propertyDefs)
+ && childNodeDefs.equals(other.childNodeDefs);
+ }
+ return false;
+ }
+
+ /**
+ * Returns zero to satisfy the Object equals/hashCode contract.
+ * This class is mutable and not meant to be used as a hash key.
+ *
+ * @return always zero
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return 0;
+ }
+
//-------------------------------< internal >-------------------------------
+ private void resetDependencies() {
+ dependencies = null;
+ }
+
/**
- * Returns an array of serializable property definitions for
+ * Returns a set of serializable property definitions for
* <code>propDefs</code>.
*
* @param propDefs the SPI property definitions.
- * @return an array of serializable property definitions.
+ * @return a set of serializable property definitions.
*/
- private static QPropertyDefinition[] getSerializablePropertyDefs(
+ private static Set<QPropertyDefinition> getSerializablePropertyDefs(
QPropertyDefinition[] propDefs) {
- QPropertyDefinition[] serDefs = new QPropertyDefinition[propDefs.length];
- for (int i = 0; i < propDefs.length; i++) {
- if (propDefs[i] instanceof Serializable) {
- serDefs[i] = propDefs[i];
+ Set<QPropertyDefinition> defs = new HashSet<QPropertyDefinition>();
+ for (QPropertyDefinition pd : propDefs) {
+ if (pd instanceof Serializable) {
+ defs.add(pd);
} else {
- serDefs[i] = new QPropertyDefinitionImpl(propDefs[i]);
+ defs.add(new QPropertyDefinitionImpl(pd));
}
}
- return serDefs;
+ return defs;
}
/**
- * Returns an array of serializable node definitions for
+ * Returns a set of serializable node definitions for
* <code>nodeDefs</code>.
*
* @param nodeDefs the node definitions.
- * @return an array of serializable node definitions.
+ * @return a set of serializable node definitions.
*/
- private static QNodeDefinition[] getSerializableNodeDefs(
+ private static Set<QNodeDefinition> getSerializableNodeDefs(
QNodeDefinition[] nodeDefs) {
- QNodeDefinition[] serDefs = new QNodeDefinition[nodeDefs.length];
- for (int i = 0; i < nodeDefs.length; i++) {
- if (nodeDefs[i] instanceof Serializable) {
- serDefs[i] = nodeDefs[i];
+ Set<QNodeDefinition> defs = new HashSet<QNodeDefinition>();
+ for (QNodeDefinition nd : nodeDefs) {
+ if (nd instanceof Serializable) {
+ defs.add(nd);
} else {
- serDefs[i] = new QNodeDefinitionImpl(nodeDefs[i]);
+ defs.add(new QNodeDefinitionImpl(nd));
}
}
- return serDefs;
+ return defs;
}
private static Name[] getNames(String[] jcrNames, NamePathResolver resolver) throws NamespaceException, IllegalNameException {
@@ -381,8 +536,8 @@
QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
for (int i = 0; i < pds.length; i++) {
PropertyDefinition propDef = pds[i];
- Name name = propDef.getName().equals(QItemDefinitionImpl.ANY_NAME.getLocalName())
- ? QItemDefinitionImpl.ANY_NAME
+ Name name = propDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
+ ? NameConstants.ANY_NAME
: resolver.getQName(propDef.getName());
// check if propDef provides declaring node type and if it matches 'this' one.
if (propDef.getDeclaringNodeType() != null) {
@@ -429,8 +584,8 @@
QNodeDefinition[] declaredNodeDefs = new QNodeDefinition[nds.length];
for (int i = 0; i < nds.length; i++) {
NodeDefinition nodeDef = nds[i];
- Name name = nodeDef.getName().equals(QItemDefinitionImpl.ANY_NAME.getLocalName())
- ? QItemDefinitionImpl.ANY_NAME
+ Name name = nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
+ ? NameConstants.ANY_NAME
: resolver.getQName(nodeDef.getName());
// check if propDef provides declaring node type and if it matches 'this' one.
if (nodeDef.getDeclaringNodeType() != null) {
Modified: jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=812419&r1=812418&r2=812419&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-2170/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java Tue Sep 8 09:47:13 2009
@@ -20,11 +20,14 @@
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import javax.jcr.PropertyType;
+
/**
* <code>QPropertyDefinitionImpl</code> implements SPI property
* definition interface.
@@ -35,37 +38,44 @@
/**
* The required type.
*/
- private final int requiredType;
+ private int requiredType = PropertyType.UNDEFINED;
/**
* The value constraints.
*/
- private final QValueConstraint[] valueConstraints;
+ private QValueConstraint[] valueConstraints = QValueConstraint.EMPTY_ARRAY;
/**
* The default values.
*/
- private final QValue[] defaultValues;
+ private QValue[] defaultValues = QValue.EMPTY_ARRAY;
/**
* The 'multiple' flag
*/
- private final boolean multiple;
+ private boolean multiple = false;
/**
* The available query operators
*/
- private final String[] availableQueryOperators;
+ private String[] availableQueryOperators = Operator.getAllQueryOperators();
/**
* The 'fullTextSearcheable' flag
*/
- private final boolean fullTextSearchable;
+ private boolean fullTextSearchable = true;
/**
* The 'queryOrderable' flag
*/
- private final boolean queryOrderable;
+ private boolean queryOrderable = true;
+
+ /**
+ * Default constructor.
+ */
+ public QPropertyDefinitionImpl() {
+ super();
+ }
/**
* Copy constructor.
@@ -128,6 +138,81 @@
this.queryOrderable = isQueryOrderable;
}
+ /**
+ * Sets the required type
+ *
+ * @param requiredType the required type.
+ */
+ public void setRequiredType(int requiredType) {
+ this.requiredType = requiredType;
+ }
+
+ /**
+ * Sets the value constraints.
+ *
+ * @param valueConstraints the value constraints.
+ */
+ public void setValueConstraints(QValueConstraint[] valueConstraints) {
+ if (valueConstraints != null) {
+ this.valueConstraints = valueConstraints;
+ } else {
+ this.valueConstraints = QValueConstraint.EMPTY_ARRAY;
+ }
+ }
+
+ /**
+ * Sets the default values.
+ *
+ * @param defaultValues the default values.
+ */
+ public void setDefaultValues(QValue[] defaultValues) {
+ if (defaultValues != null) {
+ this.defaultValues = defaultValues;
+ } else {
+ this.defaultValues = QValue.EMPTY_ARRAY;
+ }
+ }
+
+ /**
+ * Sets the 'multiple' flag.
+ *
+ * @param multiple whether the property is multi-valued.
+ */
+ public void setMultiple(boolean multiple) {
+ this.multiple = multiple;
+ }
+
+ /**
+ * Sets the 'fulltext searchable' flag.
+ *
+ * @param fullTextSearchable whether the property is fulltext searchable.
+ */
+ public void setFullTextSearchable(boolean fullTextSearchable) {
+ this.fullTextSearchable = fullTextSearchable;
+ }
+
+ /**
+ * Sets the 'query orderable' flag.
+ *
+ * @param queryOrderable whether the property is orderable.
+ */
+ public void setQueryOrderable(boolean queryOrderable) {
+ this.queryOrderable = queryOrderable;
+ }
+
+ /**
+ * Sets the 'available' query operators.
+ *
+ * @param queryOperators the available query operators.
+ */
+ public void setAvailableQueryOperators(String[] queryOperators) {
+ if (queryOperators != null) {
+ this.availableQueryOperators = queryOperators;
+ } else {
+ this.availableQueryOperators = new String[0];
+ }
+ }
+
//------------------------------------------------< QPropertyDefinition >---
/**
* {@inheritDoc}