Class ValueConstraint
java.lang.Object
org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint
- All Implemented Interfaces:
QValueConstraint
ValueConstraint and its subclasses are used to check the
syntax of a value constraint and to test if a specific value satisfies
it.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckValueConstraints(QPropertyDefinition pd, QValue[] values) Tests if the value constraints defined in the property definitionpdare satisfied by the the specifiedvalues.static ValueConstraintCreate a newValueConstraintfrom the String representation.static ValueConstraint[]Create a newValueConstraintarray from the String representation.static ValueConstraint[]create(int type, String[] jcrDefinition, NamePathResolver resolver) Create a newValueConstraintarray from the specified JCR representations.static ValueConstraintcreate(int type, String jcrDefinition, NamePathResolver resolver) booleangetDefinition(NamePathResolver resolver) For constraints that are not namespace prefix mapping sensitive this method returns the same result as.getString()For constraints that are not namespace prefix mapping sensitive this method returns the same defined in.PropertyDefinition.getValueConstraints()inthashCode()Returns the hashCode of the definition StringtoString()Same asgetString()Methods inherited from interface org.apache.jackrabbit.spi.QValueConstraint
check
-
Field Details
-
EMPTY_ARRAY
-
-
Method Details
-
getDefinition
For constraints that are not namespace prefix mapping sensitive this method returns the same result as.getString()Those that are namespace prefix mapping sensitive (e.g.
NameConstraint,PathConstraintandReferenceConstraint) use the givennsResolverto reflect the current mapping in the returned value. In other words: subclasses, that need to make a conversion to JCR value must overwrite this and return a value that has theNames orPathproperly resolved to their JCR representation.- Parameters:
resolver- name-path resolver- Returns:
- the definition of this constraint.
- See Also:
-
getString
Description copied from interface:QValueConstraintFor constraints that are not namespace prefix mapping sensitive this method returns the same defined in.PropertyDefinition.getValueConstraints()Those that are namespace prefix mapping sensitive (e.g.
NameConstraint,PathConstraintandReferenceConstraint) return an internal string.- Specified by:
getStringin interfaceQValueConstraint- Returns:
- the internal definition String
- See Also:
-
toString
Same asgetString() -
equals
-
hashCode
public int hashCode()Returns the hashCode of the definition String -
create
Create a newValueConstraintfrom the String representation. Note, that the definition must be independent of session specific namespace mappings in case of the following constraint types:- Parameters:
type- required typedefinition- The internal definition string.- Returns:
- a new value constraint
- Throws:
InvalidConstraintException- if the constraint is not valid.- See Also:
-
create
public static ValueConstraint[] create(int type, String[] definition) throws InvalidConstraintException Create a newValueConstraintarray from the String representation. Note, that the definition must be in the internal format in case of the following types:- Parameters:
type- the required typedefinition- internal definition strings- Returns:
- the array of constraints
- Throws:
InvalidConstraintException- if one of the constraints is invalid
-
create
public static ValueConstraint[] create(int type, String[] jcrDefinition, NamePathResolver resolver) throws InvalidConstraintException Create a newValueConstraintarray from the specified JCR representations.- Parameters:
type- the required typejcrDefinition- The definition strings as exposed through the JCR API.resolver- name-path resolver- Returns:
- the array of constraints
- Throws:
InvalidConstraintException- if one of the constraints is invalid
-
create
public static ValueConstraint create(int type, String jcrDefinition, NamePathResolver resolver) throws InvalidConstraintException - Parameters:
type- required typejcrDefinition- A JCR representation of a value constraint definition.resolver- name-path resolver- Returns:
- a new value constraint
- Throws:
InvalidConstraintException- if the constraint is invalid
-
checkValueConstraints
public static void checkValueConstraints(QPropertyDefinition pd, QValue[] values) throws ConstraintViolationException, RepositoryException Tests if the value constraints defined in the property definitionpdare satisfied by the the specifiedvalues.Note that the protected flag is not checked. Also note that no type conversions are attempted if the type of the given values does not match the required type as specified in the given definition.
- Parameters:
pd- property definitionvalues- values to check- Throws:
ConstraintViolationException- if the constraints are violatedRepositoryException
-