Class ConverterAttributeMapValidator


  • public class ConverterAttributeMapValidator
    extends Object
    The ConverterAttributeMapValidator class reads any attributes of a node, validates if they appear or not, and returns the validated key-value pair map.
    Author:
    Michael Grammling - Initial contribution
    • Constructor Detail

      • ConverterAttributeMapValidator

        public ConverterAttributeMapValidator​(String[][] validationMaskTemplate)
        Creates a new instance of this class with the specified parameter.

        The validation mask template is a two-dimensional key-required (String, [true|false]) list, defining all attributes the node could have and which are required and which not. The structure of the array is the following:

         String[] validationMaskTemplate = new String[][] {
                 { "uri", "false" },
                 { "attribute", "true" }};
         

        If the validation mask template is null the validation is skipped. If it's empty, no attributes are allowed for this node.

        Parameters:
        validationMaskTemplate - the two-dimensional key-required list (could be null or empty)
      • ConverterAttributeMapValidator

        public ConverterAttributeMapValidator​(Map<String,​Boolean> validationMaskTemplate)
        Creates a new instance of this class with the specified parameter.

        The validation mask template is a key-required (String, [true|false]) map, defining all attributes the node could have, and which are required and which not.

        If the validation mask template is null the validation is skipped. If it's empty, no attributes are allowed for this node.

        Parameters:
        validationMaskTemplate - the key-required map (could be null or empty)
    • Method Detail

      • readValidatedAttributes

        public Map<String,​String> readValidatedAttributes​(com.thoughtworks.xstream.io.HierarchicalStreamReader reader)
                                                         throws com.thoughtworks.xstream.converters.ConversionException
        Reads, validates and returns all attributes of a node associated with the specified reader as key-value map.
        Parameters:
        reader - the reader to be used to read-in all attributes of the node (must not be null)
        Returns:
        the key-value map (not null, could be empty)
        Throws:
        com.thoughtworks.xstream.converters.ConversionException - if the validation check fails
      • readValidatedAttributes

        public static Map<String,​String> readValidatedAttributes​(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                                                       Map<String,​Boolean> validationMaskTemplate)
                                                                throws com.thoughtworks.xstream.converters.ConversionException
        Reads, validates and returns all attributes of a node associated with the specified reader as key-value map.

        The validation mask template is a key-required (String, [true|false]) map, defining all attributes the node could have, and which are required and which not.

        Parameters:
        reader - the reader to be used to read-in all attributes of the node (must not be null)
        validationMaskTemplate - the key-required map (could be null or empty)
        Returns:
        the key-value map (not null, could be empty)
        Throws:
        com.thoughtworks.xstream.converters.ConversionException - if the validation check fails