Class PropertyDefinitionImpl
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl
-
- All Implemented Interfaces:
ItemDefinition,PropertyDefinition
public class PropertyDefinitionImpl extends java.lang.Object implements PropertyDefinition
This class implements thePropertyDefinitioninterface. All method calls are delegated to the wrappedQPropertyDefinition, performing the translation fromNames to JCR names (and vice versa) where necessary.
-
-
Constructor Summary
Constructors Constructor Description PropertyDefinitionImpl(QPropertyDefinition propDef, NamePathResolver resolver, ValueFactory valueFactory)Package private constructorPropertyDefinitionImpl(QPropertyDefinition propDef, AbstractNodeTypeManager ntMgr, NamePathResolver resolver, ValueFactory valueFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.String[]getAvailableQueryOperators()Returns the set of query comparison operators supported by this property.NodeTypegetDeclaringNodeType()Gets the node type that contains the declaration of thisItemDefinition.Value[]getDefaultValues()Gets the default value(s) of the property.java.lang.StringgetName()Gets the name of the child item.intgetOnParentVersion()Gets theOnParentVersionstatus of the child item.intgetRequiredType()Gets the required type of the property.java.lang.String[]getValueConstraints()Gets the array of constraint strings.inthashCode()booleanisAutoCreated()Reports whether the item is to be automatically created when its parent node is created.booleanisFullTextSearchable()Returnstrueif this property is full-text searchable, meaning that its value is accessible through the full-text search function within a query.booleanisMandatory()Reports whether the item is mandatory.booleanisMultiple()Reports whether this property can have multiple values.booleanisProtected()Reports whether the child item is protected.booleanisQueryOrderable()Returnstrueif this property is query-orderable, meaning that query results may be ordered by this property using the order-by clause of a query.QPropertyDefinitionunwrap()Returns the wrapped property definition.-
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.jcr.nodetype.ItemDefinition
getDeclaringNodeType, getName, getOnParentVersion, isAutoCreated, isMandatory, isProtected
-
-
-
-
Constructor Detail
-
PropertyDefinitionImpl
public PropertyDefinitionImpl(QPropertyDefinition propDef, NamePathResolver resolver, ValueFactory valueFactory)
Package private constructor- Parameters:
propDef- property definitionresolver- the name-path resolvervalueFactory- a value factory
-
PropertyDefinitionImpl
public PropertyDefinitionImpl(QPropertyDefinition propDef, AbstractNodeTypeManager ntMgr, NamePathResolver resolver, ValueFactory valueFactory)
- Parameters:
propDef- underlying propdefntMgr- nodetype managerresolver- name-path resolvervalueFactory- value factory (for default values)
-
-
Method Detail
-
unwrap
public QPropertyDefinition unwrap()
Returns the wrapped property definition.- Returns:
- the wrapped property definition.
-
getDefaultValues
public Value[] getDefaultValues()
Gets the default value(s) of the property. These are the values that the property defined by this PropertyDefinition will be assigned if it is automatically created (that is, ifItemDefinition.isAutoCreated()returnstrue).This method returns an array of
Valueobjects. If the property is multi-valued, then this array represents the full set of values that the property will be assigned upon being auto-created. Note that this could be the empty array. If the property is single-valued, then the array returned will be of size 1.If
nullis returned, then the property has no fixed default value. This does not exclude the possibility that the property still assumes some value automatically, but that value may be parametrized (for example, "the current date") and hence not expressible as a single fixed value. In particular, this must be the case ifisAutoCreatedreturnstrueand this method returnsnull.Note that to indicate a
nullvalue for this attribute in a node type definition that is stored in content, thejcr:defaultValuesproperty is simply removed (sincenullvalues for properties are not allowed.In implementations that support node type registration, if this
PropertyDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplate, then this method will returnnull.- Specified by:
getDefaultValuesin interfacePropertyDefinition- Returns:
- an array of
Valueobjects.
-
getRequiredType
public int getRequiredType()
Gets the required type of the property. One of:PropertyType.STRINGPropertyType.DATEPropertyType.BINARYPropertyType.DOUBLEPropertyType.DECIMALPropertyType.LONGPropertyType.BOOLEANPropertyType.NAMEPropertyType.PATHPropertyType.URIPropertyType.REFERENCEPropertyType.WEAKREFERENCEPropertyType.UNDEFINED
PropertyType.UNDEFINEDis returned if this property may be of any type.In implementations that support node type registration, if this
PropertyDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplate, then this method will returnPropertyType.STRING.- Specified by:
getRequiredTypein interfacePropertyDefinition- Returns:
- an
intconstant member ofPropertyType.
-
getValueConstraints
public java.lang.String[] getValueConstraints()
Gets the array of constraint strings. Each string in the array specifies a constraint on the value of the property. The constraints are OR-ed together, meaning that in order to be valid, the value must meet at least one of the constraints. For example, a constraint array of["constraint1", "constraint2", "constraint3"]has the interpretation: "the value of this property must meet at least one ofconstraint1,constraint2orconstraint3".Reporting of value constraints is optional. An implementation may return
null, indicating that value constraint information is unavailable (though a constraint may still exist).Returning an empty array, on the other hand, indicates that value constraint information is available and that no constraints are placed on this value.
In the case of multi-value properties, the constraint string array returned applies to all the values of the property.
The constraint strings themselves having differing formats and interpretations depending on the type of the property in question. The following describes the value constraint syntax for each property type:
-
STRINGandURI: The constraint string is a regular expression pattern. For example the regular expression ".*" means "any string, including the empty string". Whereas a simple literal string (without any RE-specific meta-characters) like "banana" matches only the string "banana". -
PATH: The constraint string is a JCR path with an optional "*" character after the last "/" character. For example, possible constraint strings for a property of typePATHinclude:-
"
/myapp:products/myapp:televisions" -
"
/myapp:products/myapp:televisions/" -
"
/myapp:products/*" - "
myapp:products/myapp:televisions" - "
../myapp:televisions" -
"
../myapp:televisions/*"
- The "*" means "matches descendants" not
"matches any subsequent path". For example,
/a/*does not match/a/../c. The constraint must match the normalized path. - Relative path constraint only match relative path values and absolute path constraints only match absolute path values.
-
A trailing "
/" has no effect (hence,1and2, above, are equivalent). - The trailing
"
*" character means that the value of thePATHproperty is restricted to the indicated subgraph (in other words any additional relative path can replace the "*"). For example, 3, above would allow/myapp:products/myapp:radios,/myapp:products/myapp:microwaves/X900, and so forth. - A constraint without a "
*" means that thePATHproperty is restricted to that precise path. For example,1, above, would allow only the value/myapp:products/myapp:televisions. - The constraint
can indicate either a relative path or an absolute path depending on
whether it includes a leading "
/" character.1and4, above for example, are distinct. - The
string returned must reflect the namespace mapping in the current
Session(i.e., the current state of the namespace registry overlaid with any session-specific mappings). Constraint strings forPATHproperties should be stored in fully-qualified form (using the actual URI instead of the prefix) and then be converted to prefix form according to the current mapping upon thePropertyDefinition.getValueConstraintscall.
-
"
-
NAME: The constraint string is a JCR name in prefix form. For example "myapp:products". No wildcards or other pattern matching are supported. As withPATHproperties, the string returned must reflect the namespace mapping in the currentSession. Constraint strings forNAMEproperties should be stored in fully-qualified form (using the actual URI instead of the prefix) and then be converted to prefix form according to the current mapping. -
REFERENCEandWEAKREFERENCE: The constraint string is a JCR name in prefix form. This name is interpreted as a node type name and theREFERENCEorWEAKREFERENCEproperty is restricted to referring only to nodes that have at least the indicated node type. For example, a constraint of "mytype:document" would indicate that the property in question can only refer to nodes that have at least the node typemytype:document(assuming this was the only constraint returned in the array, recall that the array of constraints are to be ORed together). No wildcards or other pattern matching are supported. As withPATHproperties, the string returned must reflect the namespace mapping in the currentSession. Constraint strings forREFERENCEandWEAKREFERENCEproperties should be stored by the implementation in fully-qualified form (using the actual URI instead of the prefix) and then be converted to prefix form according to the current mapping. -
BOOLEAN: A constraint string can be either "true" or "false". In most casesgetValueConstraintswill return an empty array since placing a constraint on aBOOLEANvalue does not usually make sense.
[min, max]", "(min, max)", "(min, max]" or "[min, max)". Where "[" and "]" indicate "inclusive", while "(" and ")" indicate "exclusive". A missingminormaxvalue indicates no bound in that direction. For example [,5] means no minimum but a maximum of 5 (inclusive) while [,] means simply that any value will suffice, The meaning of theminandmaxvalues themselves differ between types as follows:-
BINARY:minandmaxspecify the allowed size range of the binary value in bytes. -
DATE:minandmaxare dates specifying the allowed date range. The date strings must be in the ISO8601-compliant format:YYYY-MM-DDThh:mm:ss.sssTZD. -
LONG,DOUBLE: min and max are numbers.
DATE,LONGorDOUBLEis constrained to be equal to some disjunctive set of constants, a string consisting of just the constant itself, "c" may be used as a shorthand for the standard constraint notation of "[c, c]", where c is the constant. For example, to indicate that particular LONG property is constrained to be one of the values 2, 4, or 8, the constraint string array {"2", "4", "8"} can be used instead of the standard notation, {"[2,2]", "[4,4]", "[8,8]"}. However, even if this shorthand is used on registration, the value returned byPropertyDefinition.getValueConstraints()will always use the standard notation.Because constraints are returned as an array of disjunctive constraints, in many cases the elements of the array can serve directly as a "choice list". This may, for example, be used by an application to display options to the end user indicating the set of permitted values.
In implementations that support node type registration, if this
PropertyDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplate, then this method will returnnull.- Specified by:
getValueConstraintsin interfacePropertyDefinition- Returns:
- a
Stringarray.
-
-
isMultiple
public boolean isMultiple()
Reports whether this property can have multiple values. Note that theisMultipleflag is special in that a given node type may have two property definitions that are identical in every respect except for the theirisMultiplestatus. For example, a node type can specify two string properties both calledX, one of which is multi-valued and the other not. An example of such a node type isnt:unstructured.In implementations that support node type registration, if this
PropertyDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplate, then this method will returnfalse.- Specified by:
isMultiplein interfacePropertyDefinition- Returns:
- a
boolean
-
getAvailableQueryOperators
public java.lang.String[] getAvailableQueryOperators()
Description copied from interface:PropertyDefinitionReturns the set of query comparison operators supported by this property.This attribute only takes effect if the node type holding the property definition has a queryable setting of
true.JCR defines the following comparison operators:
QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO,QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN,QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN,QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, orQueryObjectModelConstants.JCR_OPERATOR_LIKE
Note that the set of operators that can appear in this attribute may be limited by implementation-specific constraints that differ across property types. For example, some implementations may permit property definitions to provide
JCR_OPERATOR_EQUAL_TOandJCR_OPERATOR_NOT_EQUAL_TOas available operators forBINARYproperties while others may not.However, in all cases where a JCR-defined operator is potentially available for a given property type, its behavior must conform to the comparison semantics defined in the specification document (see 3.6.5 Comparison of Values).
In implementations that support node type registration, if this
NodeTypeDefinitionobject is actually a newly-created emptyNodeTypeTemplate, then this method will return an impementation- determined default set of operator constants.- Specified by:
getAvailableQueryOperatorsin interfacePropertyDefinition- Returns:
- a
Stringarray. - See Also:
PropertyDefinition.getAvailableQueryOperators()
-
isFullTextSearchable
public boolean isFullTextSearchable()
Description copied from interface:PropertyDefinitionReturnstrueif this property is full-text searchable, meaning that its value is accessible through the full-text search function within a query.This attribute only takes effect if the node type holding the property definition has a queryable setting of
true.In implementations that support node type registration, if this
NodeTypeDefinitionobject is actually a newly-created emptyNodeTypeTemplate, then this method will return an impementation- determined default value.- Specified by:
isFullTextSearchablein interfacePropertyDefinition- Returns:
- a
boolean - See Also:
PropertyDefinition.isFullTextSearchable()
-
isQueryOrderable
public boolean isQueryOrderable()
Description copied from interface:PropertyDefinitionReturnstrueif this property is query-orderable, meaning that query results may be ordered by this property using the order-by clause of a query.This attribute only takes effect if the node type holding the property definition has a queryable setting of
true.In implementations that support node type registration, if this
NodeTypeDefinitionobject is actually a newly-created emptyNodeTypeTemplate, then this method will return an impementation- determined default value.- Specified by:
isQueryOrderablein interfacePropertyDefinition- Returns:
- a
boolean - See Also:
PropertyDefinition.isQueryOrderable()
-
getDeclaringNodeType
public NodeType getDeclaringNodeType()
Gets the node type that contains the declaration of thisItemDefinition.In implementations that support node type registration an
ItemDefinitionobject may be acquired (in the form of aNodeDefinitionTemplateorPropertyDefinitionTemplate) that is not attached to a liveNodeType. In such cases this method returnsnull.- Specified by:
getDeclaringNodeTypein interfaceItemDefinition- Returns:
- a
NodeTypeobject.
-
getName
public java.lang.String getName()
Gets the name of the child item. If"*", thisItemDefinitiondefines a residual set of child items. That is, it defines the characteristics of all those child items with names apart from the names explicitly used in other child item definitions.In implementations that support node type registration, if this
ItemDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplateorNodeDefinitionTemplate, then this method will returnnull.- Specified by:
getNamein interfaceItemDefinition- Returns:
- a
Stringdenoting the name or"*".
-
getOnParentVersion
public int getOnParentVersion()
Gets theOnParentVersionstatus of the child item. This governs what occurs (in implementations that support versioning) when the parent node of this item is checked-in. One of:OnParentVersionAction.COPYOnParentVersionAction.VERSIONOnParentVersionAction.IGNOREOnParentVersionAction.INITIALIZEOnParentVersionAction.COMPUTEOnParentVersionAction.ABORT
In implementations that support node type registration, if this
ItemDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplateorNodeDefinitionTemplate, then this method will returnOnParentVersionAction.COPY.- Specified by:
getOnParentVersionin interfaceItemDefinition- Returns:
- a
intconstant member ofOnParentVersionAction.
-
isAutoCreated
public boolean isAutoCreated()
Reports whether the item is to be automatically created when its parent node is created. Iftrue, then thisItemDefinitionwill necessarily not be a residual set definition but will specify an actual item name (in other words getName() will not return "*").An autocreated non-protected item must be created immediately when its parent node is created in the transient session space. Creation of autocreated non-protected items is never delayed until
save.An autocreated protected item should be created immediately when its parent node is created in the transient session space. Creation of autocreated protected items should not be delayed until
save, though doing so does not violate JCR compliance.In implementations that support node type registration, if this
ItemDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplateorNodeDefinitionTemplate, then this method will returnfalse.- Specified by:
isAutoCreatedin interfaceItemDefinition- Returns:
- a
boolean.
-
isMandatory
public boolean isMandatory()
Reports whether the item is mandatory. A mandatory item is one that, if its parent node exists, must also exist.This means that a mandatory single-value property must have a value (since there is no such thing a
nullvalue). In the case of multi-value properties this means that the property must exist, though it can have zero or more values.An attempt to save a node that has a mandatory child item without first creating that child item will throw a
ConstraintViolationExceptiononsave.In implementations that support node type registration, if this
ItemDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplateorNodeDefinitionTemplate, then this method will returnfalse.An item definition cannot be both residual and mandatory.
- Specified by:
isMandatoryin interfaceItemDefinition- Returns:
- a
boolean
-
isProtected
public boolean isProtected()
Reports whether the child item is protected. In level 2 implementations, a protected item is one that cannot be removed (except by removing its parent) or modified through the the standard write methods of this API (that is,Item.remove,Node.addNode,Node.setPropertyandProperty.setValue).A protected node may be removed or modified (in a level 2 implementation), however, through some mechanism not defined by this specification or as a side-effect of operations other than the standard write methods of the API.
In implementations that support node type registration, if this
ItemDefinitionobject is actually a newly-created emptyPropertyDefinitionTemplateorNodeDefinitionTemplate, then this method will returnfalse.- Specified by:
isProtectedin interfaceItemDefinition- Returns:
- a
boolean.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-