javax.jcr.nodetype
Interface PropertyDefinition

All Superinterfaces:
ItemDefinition
All Known Subinterfaces:
PropertyDefinitionTemplate

public interface PropertyDefinition
extends ItemDefinition

A property definition. Used in node type definitions.


Method Summary
 java.lang.String[] getAvailableQueryOperators()
          Returns the set of query comparison operators supported by this property.
 Value[] getDefaultValues()
          Gets the default value(s) of the property.
 int getRequiredType()
          Gets the required type of the property.
 java.lang.String[] getValueConstraints()
          Gets the array of constraint strings.
 boolean isFullTextSearchable()
          Returns true if this property is full-text searchable, meaning that its value is accessible through the full-text search function within a query.
 boolean isMultiple()
          Reports whether this property can have multiple values.
 boolean isQueryOrderable()
          Returns true if this property is query-orderable, meaning that query results may be ordered by this property using the order-by clause of a query.
 
Methods inherited from interface javax.jcr.nodetype.ItemDefinition
getDeclaringNodeType, getName, getOnParentVersion, isAutoCreated, isMandatory, isProtected
 

Method Detail

getRequiredType

int getRequiredType()
Gets the required type of the property. One of: PropertyType.UNDEFINED is returned if this property may be of any type.

In implementations that support node type registration, if this PropertyDefinition object is actually a newly-created empty PropertyDefinitionTemplate, then this method will return PropertyType.STRING.

Returns:
an int constant member of PropertyType.

getValueConstraints

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 of constraint1, constraint2 or constraint3".

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:

The remaining types all have value constraints in the form of inclusive or exclusive ranges: i.e., "[min, max]", "(min, max)", "(min, max]" or "[min, max)". Where "[" and "]" indicate "inclusive", while "(" and ")" indicate "exclusive". A missing min or max value 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 the min and max values themselves differ between types as follows: In implementations that support node type registration, when specifying that a DATE, LONG or DOUBLE is 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 by PropertyDefinition.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 PropertyDefinition object is actually a newly-created empty PropertyDefinitionTemplate, then this method will return null.

Returns:
a String array.

getDefaultValues

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, if ItemDefinition.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 parametrized (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.

In implementations that support node type registration, if this PropertyDefinition object is actually a newly-created empty PropertyDefinitionTemplate, then this method will return null.

Returns:
an array of Value objects.

isMultiple

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.

In implementations that support node type registration, if this PropertyDefinition object is actually a newly-created empty PropertyDefinitionTemplate, then this method will return false.

Returns:
a boolean

getAvailableQueryOperators

java.lang.String[] getAvailableQueryOperators()
Returns 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:

An implementation may define additional comparison operators.

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_TO and JCR_OPERATOR_NOT_EQUAL_TO as available operators for BINARY properties 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 NodeTypeDefinition object is actually a newly-created empty NodeTypeTemplate, then this method will return an impementation- determined default set of operator constants.

Returns:
a String array.
Since:
JCR 2.0

isFullTextSearchable

boolean isFullTextSearchable()
Returns true if 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 NodeTypeDefinition object is actually a newly-created empty NodeTypeTemplate, then this method will return an impementation- determined default value.

Returns:
a boolean
Since:
JCR 2.0

isQueryOrderable

boolean isQueryOrderable()
Returns true if 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 NodeTypeDefinition object is actually a newly-created empty NodeTypeTemplate, then this method will return an impementation- determined default value.

Returns:
a boolean
Since:
JCR 2.0