org.apache.jackrabbit.spi.commons.nodetype
Class ValueConstraint

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.nodetype.ValueConstraint

public abstract class ValueConstraint
extends Object

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
static ValueConstraint[] EMPTY_ARRAY
           
protected static org.slf4j.Logger log
           
 
Constructor Summary
protected ValueConstraint(String qualifiedDefinition)
           
 
Method Summary
static void checkValueConstraints(QPropertyDefinition pd, QValue[] values)
          Tests if the value constraints defined in the property definition pd are satisfied by the the specified values.
static ValueConstraint create(int type, String qualifiedDefinition)
          Create a new ValueConstraint from the String representation.
static ValueConstraint create(int type, String definition, NamePathResolver resolver)
           
 boolean equals(Object other)
           
 String getDefinition(NamePathResolver resolver)
          For constraints that are not namespace prefix mapping sensitive this method returns the same result as getQualifiedDefinition().
 String getQualifiedDefinition()
          By default the qualified definition is the same as the JCR definition.
 int hashCode()
          Returns the hashCode of the definition String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log

EMPTY_ARRAY

public static final ValueConstraint[] EMPTY_ARRAY
Constructor Detail

ValueConstraint

protected ValueConstraint(String qualifiedDefinition)
Method Detail

getDefinition

public String getDefinition(NamePathResolver resolver)
For constraints that are not namespace prefix mapping sensitive this method returns the same result as getQualifiedDefinition().

Those that are namespace prefix mapping sensitive (e.g. NameConstraint, PathConstraint and ReferenceConstraint) use the given nsResolver to 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 all qualified names and path elements resolved.

Parameters:
resolver -
Returns:
the definition of this constraint.
See Also:
getQualifiedDefinition()

getQualifiedDefinition

public String getQualifiedDefinition()
By default the qualified definition is the same as the JCR definition.

Returns:
the qualified definition String
See Also:
getDefinition(NamePathResolver)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hashCode of the definition String

Overrides:
hashCode in class Object
Returns:
the hashCode of the definition String
See Also:
Object.hashCode()

create

public static ValueConstraint create(int type,
                                     String qualifiedDefinition)
                              throws InvalidConstraintException
Create a new ValueConstraint from the String representation. Note, that the definition must be in the qualified format in case the type indicates PropertyType.NAME, PropertyType.PATH or PropertyType.REFERENCE

Parameters:
type -
qualifiedDefinition -
Returns:
Throws:
InvalidConstraintException

create

public static ValueConstraint create(int type,
                                     String definition,
                                     NamePathResolver resolver)
                              throws InvalidConstraintException
Parameters:
type -
definition -
resolver -
Returns:
Throws:
InvalidConstraintException

checkValueConstraints

public static void checkValueConstraints(QPropertyDefinition pd,
                                         QValue[] values)
                                  throws ConstraintViolationException,
                                         RepositoryException
Tests if the value constraints defined in the property definition pd are satisfied by the the specified values.

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 -
values -
Throws:
ConstraintViolationException
RepositoryException


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.