6.7.13 PropertyDefinition

The PropertyDefinition represents a property definition. It inherits all the method of ItemDefinition and adds the following:

javax.jcr.nodetype.
PropertyDefinition extends ItemDefinition

int

getRequiredType()

Gets the required type of the property. One of STRING, BINARY, DATE, LONG, DOUBLE, NAME, PATH, REFERENCE, BOOLEAN or UNDEFINED. See 6.2.5 Property Types. If UNDEFINED, then this property may be of any type.

String[]

getValueConstraints()

Gets the array of constraint strings. This array of strings describes the constraints that exist on values of the property. Reporting of value constraints is optional. An implementation may return null, indicating that value constraint information is unavailable (though a constraint may still exist). Note that to indicate a null value for this attribute in a node type definition that is stored in content, the jcr:valueConstraints property is simply removed (since null values for properties are not allowed, see 6.7.20 Node Type Definitions in Content).

Returning an empty array, on the other hand, indicates that constraint information is available and that no constraints are placed on the value of the property.

If a non-empty array is returned then it is interpreted as a disjunctive set of constraints (i.e. the value must meet at least one of the constraints). The interpretation of the constraint strings themselves differs according to the type of the property. See 6.7.16 Value Constraints for details.

Value[]

getDefaultValues()

Gets the default value(s) of the property. These are the values (or value) that the property defined by this PropertyDefinition will be assigned if it is automatically created (that is, if isAutoCreated() returns true).

This method returns an array of Value objects. 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 null is 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 parameterized (for example, “the current date”) and hence not expressible as a single fixed value. In particular, this must be the case if isAutoCreated returns true and this method returns null.

Note that to indicate a null value for this attribute in a node type definition that is stored in content, the jcr:defaultValues property is simply removed (since null values for properties are not allowed, see 6.7.20 Node Type Definitions in Content).

boolean

isMultiple()

Reports whether this property can have multiple values. Note that the isMultiple flag is special in that a given node type may have two property definitions that are identical in every respect except for the their isMultiple status. For example, a node type can specify two string properties both called X, one of which is multi-valued and the other not. An example of such a node type is nt:unstructured (see 6.7.22.4 nt:unstructured).