Class ValueConstraint

  • All Implemented Interfaces:
    QValueConstraint

    public abstract class ValueConstraint
    extends java.lang.Object
    implements QValueConstraint
    ValueConstraint and its subclasses are used to check the syntax of a value constraint and to test if a specific value satisfies it.
    • Method Detail

      • getDefinition

        public java.lang.String getDefinition​(NamePathResolver resolver)
        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, 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 the Names or Path properly resolved to their JCR representation.

        Parameters:
        resolver - name-path resolver
        Returns:
        the definition of this constraint.
        See Also:
        (), NameResolver.getJCRName(org.apache.jackrabbit.spi.Name), PathResolver.getJCRPath(org.apache.jackrabbit.spi.Path)
      • toString

        public java.lang.String toString()
        Same as getString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the internal definition String
        See Also:
        Object.toString()
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(Object)
      • hashCode

        public int hashCode()
        Returns the hashCode of the definition String
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode of the definition String
        See Also:
        Object.hashCode()
      • create

        public static ValueConstraint[] create​(int type,
                                               java.lang.String[] jcrDefinition,
                                               NamePathResolver resolver)
                                        throws InvalidConstraintException
        Create a new ValueConstraint array from the specified JCR representations.
        Parameters:
        type - the required type
        jcrDefinition - 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
      • 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 - property definition
        values - values to check
        Throws:
        ConstraintViolationException - if the constraints are violated
        RepositoryException