Class DataAccessFactory.Param

    • Constructor Detail

      • Param

        public Param​(String key)
        Provides support for text representations

        The parameter type of String is assumed.

        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
      • Param

        public Param​(String key,
                     Class<?> type)
        Provides support for text representations.

        You may specify a type for this Param.

        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
      • Param

        public Param​(String key,
                     Class<?> type,
                     String description)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
      • Param

        public Param​(String key,
                     Class<?> type,
                     String description,
                     boolean required)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
        required - true is param is required
      • Param

        public Param​(String key,
                     Class<?> type,
                     String description,
                     boolean required,
                     Object sample)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
        required - true is param is required
        sample - Sample value as an example for user input
      • Param

        public Param​(String key,
                     Class<?> type,
                     InternationalString description,
                     boolean required,
                     Object sample)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
        required - true is param is required
        sample - Sample value as an example for user input
      • Param

        public Param​(String key,
                     Class<?> type,
                     String description,
                     boolean required,
                     Object sample,
                     Map<String,​?> metadata)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
        required - true is param is required
        sample - Sample value as an example for user input
        metadata - metadata information, preferably keyed by known identifiers like Parameter.IS_PASSWORD
      • Param

        public Param​(String key,
                     Class<?> type,
                     String description,
                     boolean required,
                     Object sample,
                     Object... metadata)
      • Param

        public Param​(String key,
                     Class<?> type,
                     InternationalString description,
                     boolean required,
                     Object sample,
                     Map<String,​?> metadata)
        Provides support for text representations
        Parameters:
        key - Key used to file this Param in the Parameter Map for createDataStore
        type - Class type intended for this Param
        description - User description of Param (40 chars or less)
        required - true is param is required
        sample - Sample value as an example for user input
        metadata - metadata information, preferably keyed by known identifiers like Parameter.IS_PASSWORD
      • Param

        public Param​(String key,
                     Class<?> type,
                     InternationalString title,
                     InternationalString description,
                     boolean required,
                     int min,
                     int max,
                     Object sample,
                     Map<String,​?> metadata)
        Supports all Parameter values.
        Parameters:
        key - machine readable key for use in a java.util.Map
        type - Java class for the expected value
        title - Human readable title used for use in a user interface
        description - Human readable description
        required - true if the value is required
        min - Minimum value; or -1 if not needed
        max - Maximum value; or -1 for unbound
        sample - Sample value; may be used as a default in a user interface
        metadata - Hints to the user interface (read the javadocs for each metadata key)
    • Method Detail

      • lookUp

        public Object lookUp​(Map<String,​?> map)
                      throws IOException
        Lookup Param in a user supplied map.

        Type conversion will occur if required, this may result in an IOException. An IOException will be throw in the Param is required and the Map does not contain the Map.

        The handle method is used to process the user's value.

        Parameters:
        map - Map of user input
        Returns:
        Parameter as specified in map
        Throws:
        IOException - if parse could not handle value
      • text

        public String text​(Object value)
        Convert value to text representation for this Parameter
      • handle

        public Object handle​(String text)
                      throws IOException
        Handle text in a sensible manner.

        Performs the most common way of handling text value:

        • null: If text is null
        • original text: if type == String.class
        • first character of original text: if type == Character.class
        • null: if type != String.class and text.getLength == 0
        • parse( text ): if type != String.class
        Returns:
        Value as processed by text
        Throws:
        IOException - If text could not be parsed
      • parse

        public Object parse​(String text)
                     throws Throwable
        Provides support for text representations

        Provides basic support for common types using reflection.

        If needed you may extend this class to handle your own custome types.

        Parameters:
        text - Text representation of type should not be null or empty
        Returns:
        Object converted from text representation
        Throws:
        IOException - If text could not be parsed
        Throwable
      • toString

        public String toString()
        key=Type description
        Overrides:
        toString in class Parameter