Class MiniLangValidate


  • public final class MiniLangValidate
    extends java.lang.Object
    Mini-language validation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String module  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void attributeNames​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... validAttributeNames)
      Tests element for invalid attribute names.
      static java.lang.String checkAttribute​(java.lang.String attributeValue, java.lang.String defaultValue)
      Returns attributeValue if it is not empty, else returns defaultValue.
      static void childElements​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... validChildElementNames)
      Tests element for invalid child elements.
      static void constantAttributes​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests if element attributes are constant type.
      static void constantPlusExpressionAttributes​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests if element attributes are constant+expr type.
      static void deprecatedAttribute​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String fixInstruction)
      Tests element for a deprecated attribute.
      static void expressionAttributes​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests if element attributes are expression type.
      static void handleError​(java.lang.String errorMessage, SimpleMethod method, org.w3c.dom.Element element)
      Handles a Mini-language validation error.
      static boolean lenientOn()
      Returns true if validation.level=lenient.
      static void noChildElements​(SimpleMethod method, org.w3c.dom.Element element)
      Tests element for child elements.
      static void requireAnyAttribute​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests element for any one required attribute from a set of attribute names.
      static void requireAnyChildElement​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... elementNames)
      Tests element for any one required child element from a set of tag names.
      static void requiredAttributes​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests element for required attributes.
      static void requiredChildElements​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... elementNames)
      Tests element for required child elements.
      static void scriptAttributes​(SimpleMethod method, org.w3c.dom.Element element, java.lang.String... attributeNames)
      Tests if element attributes are script type.
      static boolean strictOn()
      Returns true if validation.level=strict.
      static boolean validationOn()
      Returns true if validation.level is set to lenient or strict.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • module

        public static final java.lang.String module
    • Method Detail

      • attributeNames

        public static void attributeNames​(SimpleMethod method,
                                          org.w3c.dom.Element element,
                                          java.lang.String... validAttributeNames)
                                   throws ValidationException
        Tests element for invalid attribute names.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        validAttributeNames - The valid attribute names
        Throws:
        ValidationException - If an invalid attribute name is found and validation.level=strict
      • checkAttribute

        public static java.lang.String checkAttribute​(java.lang.String attributeValue,
                                                      java.lang.String defaultValue)
        Returns attributeValue if it is not empty, else returns defaultValue. No null checks are performed.
        Parameters:
        attributeValue -
        defaultValue -
        Returns:
        attributeValue if it is not empty, else returns defaultValue
      • childElements

        public static void childElements​(SimpleMethod method,
                                         org.w3c.dom.Element element,
                                         java.lang.String... validChildElementNames)
                                  throws ValidationException
        Tests element for invalid child elements.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        validChildElementNames - The valid child element tag names
        Throws:
        ValidationException - If an invalid child element is found and validation.level=strict
      • constantAttributes

        public static void constantAttributes​(SimpleMethod method,
                                              org.w3c.dom.Element element,
                                              java.lang.String... attributeNames)
                                       throws ValidationException
        Tests if element attributes are constant type.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The attributes to test
        Throws:
        ValidationException - If an invalid attribute is found and validation.level=strict
      • constantPlusExpressionAttributes

        public static void constantPlusExpressionAttributes​(SimpleMethod method,
                                                            org.w3c.dom.Element element,
                                                            java.lang.String... attributeNames)
                                                     throws ValidationException
        Tests if element attributes are constant+expr type.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The attributes to test
        Throws:
        ValidationException - If an invalid attribute is found and validation.level=strict
      • deprecatedAttribute

        public static void deprecatedAttribute​(SimpleMethod method,
                                               org.w3c.dom.Element element,
                                               java.lang.String attributeName,
                                               java.lang.String fixInstruction)
                                        throws ValidationException
        Tests element for a deprecated attribute.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeName - The name of the deprecated attribute
        fixInstruction - Instructions to fix the deprecated attribute
        Throws:
        ValidationException - If the deprecated attribute is found and validation.level=strict
      • expressionAttributes

        public static void expressionAttributes​(SimpleMethod method,
                                                org.w3c.dom.Element element,
                                                java.lang.String... attributeNames)
                                         throws ValidationException
        Tests if element attributes are expression type.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The attributes to test
        Throws:
        ValidationException - If an invalid attribute is found and validation.level=strict
      • handleError

        public static void handleError​(java.lang.String errorMessage,
                                       SimpleMethod method,
                                       org.w3c.dom.Element element)
                                throws ValidationException
        Handles a Mini-language validation error.
        Parameters:
        errorMessage - The error message
        method - The <simple-method> that contains element
        element - The element that contains the error
        Throws:
        ValidationException - If validation.level=strict, otherwise a warning is logged
      • lenientOn

        public static boolean lenientOn()
        Returns true if validation.level=lenient.
        Returns:
        true if validation.level=lenient
      • noChildElements

        public static void noChildElements​(SimpleMethod method,
                                           org.w3c.dom.Element element)
                                    throws ValidationException
        Tests element for child elements.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        Throws:
        ValidationException - If a child element is found and validation.level=strict
      • requireAnyAttribute

        public static void requireAnyAttribute​(SimpleMethod method,
                                               org.w3c.dom.Element element,
                                               java.lang.String... attributeNames)
                                        throws ValidationException
        Tests element for any one required attribute from a set of attribute names.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The required attribute names
        Throws:
        ValidationException - If none of the required attributes are found and validation.level=strict
      • requireAnyChildElement

        public static void requireAnyChildElement​(SimpleMethod method,
                                                  org.w3c.dom.Element element,
                                                  java.lang.String... elementNames)
                                           throws ValidationException
        Tests element for any one required child element from a set of tag names.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        elementNames - The required child element tag names
        Throws:
        ValidationException - If none of the required child elements are found and validation.level=strict
      • requiredAttributes

        public static void requiredAttributes​(SimpleMethod method,
                                              org.w3c.dom.Element element,
                                              java.lang.String... attributeNames)
                                       throws ValidationException
        Tests element for required attributes.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The required attribute names
        Throws:
        ValidationException - If any of the required attributes are not found and validation.level=strict
      • requiredChildElements

        public static void requiredChildElements​(SimpleMethod method,
                                                 org.w3c.dom.Element element,
                                                 java.lang.String... elementNames)
                                          throws ValidationException
        Tests element for required child elements.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        elementNames - The required child element tag names
        Throws:
        ValidationException - If any of the required child elements are not found and validation.level=strict
      • scriptAttributes

        public static void scriptAttributes​(SimpleMethod method,
                                            org.w3c.dom.Element element,
                                            java.lang.String... attributeNames)
                                     throws ValidationException
        Tests if element attributes are script type.
        Parameters:
        method - The <simple-method> that contains element
        element - The element to test
        attributeNames - The attributes to test
        Throws:
        ValidationException - If an invalid attribute is found and validation.level=strict
      • strictOn

        public static boolean strictOn()
        Returns true if validation.level=strict.
        Returns:
        true if validation.level=strict
      • validationOn

        public static boolean validationOn()
        Returns true if validation.level is set to lenient or strict.
        Returns:
        true if validation.level is set to lenient or strict