Class DefaultSchema

  • All Implemented Interfaces:
    Schema

    public class DefaultSchema
    extends Object
    implements Schema
    Default implementation of Schema.
    Version:
    $Revision$ $Date$
    Author:
    Nick Collier
    • Constructor Detail

      • DefaultSchema

        public DefaultSchema()
        Creates an empty Schema.
      • DefaultSchema

        public DefaultSchema​(Pair<String,​Class>[] pairs)
        Creates a schema from an array of String, Class pairs.
        Parameters:
        pairs - first item in pair is parameter name, second is parameter type
    • Method Detail

      • removeEntry

        public boolean removeEntry​(String name)
        Removes a schema entry from this Schema
        Parameters:
        name - the name of the parameter
        Returns:
        whether or not the removal was successful
      • addEntry

        public void addEntry​(String name,
                             Class type,
                             Object defValue)
        Adds a schema entry to this Schema.
        Parameters:
        name - the name of the parameter
        type - the type of the parameter
        defValue - the default value of hte parameter.
      • addConstraint

        public void addConstraint​(String name,
                                  List constrainingList)
        Constains the value of the named to parameter to those in the list.
        Parameters:
        name - the name of the parameter
        constrainingList - a list containing the possible values for the named parameter
      • addConvertor

        public void addConvertor​(String name,
                                 StringConverter converter)
        Adds a converter to convert the named parameter back and forth to a String.
        Parameters:
        name - the name of the parameter
        converter - the converter
      • addConstraint

        public void addConstraint​(String name,
                                  SteppedRange constrainingRange)
        Constrains the value of the named parameter to those in the specified range.
        Parameters:
        name - the name of the parmaeter
        constrainingRange - a range of the possible values for the named parameter
      • getDetails

        public ParameterSchema getDetails​(String paramName)
        Gets the schema for the specified parameter.
        Specified by:
        getDetails in interface Schema
        Parameters:
        paramName - the name of the parameter
        Returns:
        the schema for the specified parameter
      • parameterNames

        public Iterable<String> parameterNames()
        Gets an iterable over a list of parameter names.
        Specified by:
        parameterNames in interface Schema
        Returns:
        an iterable over a list of parameter names.
      • validate

        public boolean validate​(String paramName,
                                Object obj)
        Validates the specified object against the type info contained for the parameter name.
        Specified by:
        validate in interface Schema
        Parameters:
        paramName - the name of the parameter
        obj - the object to validate
        Returns:
        true if the object is of a type valid for the parameter, otherwise false.
      • contains

        public boolean contains​(String paramName)
        Returns true if this schema contains contains the specified parameter name, otherwise false.
        Specified by:
        contains in interface Schema
        Parameters:
        paramName - the name of the parameter
        Returns:
        true if this schema contains contains the specified parameter name, otherwise false.
      • size

        public int size()
        Gets the number of parameters in this schema.
        Specified by:
        size in interface Schema
        Returns:
        the number of parameters in this schema.