Class PropertyManager


  • public final class PropertyManager
    extends java.lang.Object
    A more robust replacement of java.lang.System for property access.
    Version:
    $Revision$
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PropertyManager()
      Do not allow instantiation of this class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addPropertyListener​(PropertyListener listener)
      Add a property listener.
      static void addPropertyListeners​(PropertyListener[] listeners)
      Add an array of property listeners.
      static boolean containsProperty​(java.lang.String name)
      Check if this map contains a given property.
      static java.lang.String[] getArrayProperty​(java.lang.String name)
      Get an array style property.
      static java.lang.String[] getArrayProperty​(java.lang.String base, java.lang.String[] defaultValues)
      Get an array style property.
      static PropertyMap getDefaultPropertyMap()
      Get the default PropertyMap.
      static java.lang.String getProperty​(java.lang.String name)
      Get a property.
      static java.lang.String getProperty​(java.lang.String name, java.lang.String defaultValue)
      Get a property.
      static PropertyGroup getPropertyGroup​(java.lang.String basename)
      Get a property group for the given property base.
      static PropertyGroup getPropertyGroup​(java.lang.String basename, int index)
      Get a property group for the given property base at the given index.
      static void load​(java.lang.String classname)
      Load properties from a PropertyReader specifed by the given class name.
      static void load​(java.lang.String prefix, java.util.Map map)
      Load properties from a map.
      static void load​(java.util.Map map)
      Load properties from a map.
      static void load​(PropertyReader reader)
      Load properties from a PropertyReader.
      static java.util.Iterator names()
      Return an iterator over all contained property names.
      static java.lang.String removeProperty​(java.lang.String name)
      Remove a property.
      static boolean removePropertyListener​(PropertyListener listener)
      Remove a property listener.
      static java.lang.String setProperty​(java.lang.String name, java.lang.String value)
      Set a property.
      • Methods inherited from class java.lang.Object

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

      • READER_PROPERTY_NAME

        public static final java.lang.String READER_PROPERTY_NAME
        Property reader list property name
        See Also:
        Constant Field Values
      • DEFAULT_PROPERTY_READER_TOKEN

        public static final java.lang.String DEFAULT_PROPERTY_READER_TOKEN
        Token which specifies the default property reader
        See Also:
        Constant Field Values
      • DEFAULT_PROPERTY_READERS

        private static final java.lang.String[] DEFAULT_PROPERTY_READERS
        The default property reader name array
      • props

        private static PropertyMap props
        Default property container
    • Constructor Detail

      • PropertyManager

        private PropertyManager()
        Do not allow instantiation of this class.
    • Method Detail

      • getDefaultPropertyMap

        public static PropertyMap getDefaultPropertyMap()
        Get the default PropertyMap.
        Returns:
        Default PropertyMap.
      • addPropertyListener

        public static void addPropertyListener​(PropertyListener listener)
        Add a property listener.
        Parameters:
        listener - Property listener to add.
      • addPropertyListeners

        public static void addPropertyListeners​(PropertyListener[] listeners)
        Add an array of property listeners.
        Parameters:
        listeners - Array of property listeners to add.
      • removePropertyListener

        public static boolean removePropertyListener​(PropertyListener listener)
        Remove a property listener.
        Parameters:
        listener - Property listener to remove.
        Returns:
        True if listener was removed.
      • load

        public static void load​(java.lang.String prefix,
                                java.util.Map map)
                         throws PropertyException
        Load properties from a map.
        Parameters:
        prefix - Prefix to append to all map keys (or null).
        map - Map containing properties to load.
        Throws:
        PropertyException
      • load

        public static void load​(java.util.Map map)
                         throws PropertyException,
                                java.io.IOException
        Load properties from a map.
        Parameters:
        map - Map containing properties to load.
        Throws:
        PropertyException
        java.io.IOException
      • load

        public static void load​(PropertyReader reader)
                         throws PropertyException,
                                java.io.IOException
        Load properties from a PropertyReader.
        Parameters:
        reader - PropertyReader to read properties from.
        Throws:
        PropertyException
        java.io.IOException
      • load

        public static void load​(java.lang.String classname)
                         throws PropertyException,
                                java.io.IOException
        Load properties from a PropertyReader specifed by the given class name.
        Parameters:
        classname - Class name of a PropertyReader to read from.
        Throws:
        PropertyException
        java.io.IOException
      • setProperty

        public static java.lang.String setProperty​(java.lang.String name,
                                                   java.lang.String value)
        Set a property.
        Parameters:
        name - Property name.
        value - Property value.
        Returns:
        Previous property value or null.
      • removeProperty

        public static java.lang.String removeProperty​(java.lang.String name)
        Remove a property.
        Parameters:
        name - Property name.
        Returns:
        Removed property value or null.
      • getProperty

        public static java.lang.String getProperty​(java.lang.String name,
                                                   java.lang.String defaultValue)
        Get a property.
        Parameters:
        name - Property name.
        defaultValue - Default property value.
        Returns:
        Property value or default.
      • getProperty

        public static java.lang.String getProperty​(java.lang.String name)
        Get a property.
        Parameters:
        name - Property name.
        Returns:
        Property value or null.
      • getArrayProperty

        public static java.lang.String[] getArrayProperty​(java.lang.String base,
                                                          java.lang.String[] defaultValues)
        Get an array style property.
        Parameters:
        base - Base property name.
        defaultValues - Default property values.
        Returns:
        Array of property values or default.
      • getArrayProperty

        public static java.lang.String[] getArrayProperty​(java.lang.String name)
        Get an array style property.
        Parameters:
        name - Property name.
        Returns:
        Array of property values or empty array.
      • names

        public static java.util.Iterator names()
        Return an iterator over all contained property names.
        Returns:
        Property name iterator.
      • containsProperty

        public static boolean containsProperty​(java.lang.String name)
        Check if this map contains a given property.
        Parameters:
        name - Property name.
        Returns:
        True if contains property.
      • getPropertyGroup

        public static PropertyGroup getPropertyGroup​(java.lang.String basename)
        Get a property group for the given property base.
        Parameters:
        basename - Base property name.
        Returns:
        Property group.
      • getPropertyGroup

        public static PropertyGroup getPropertyGroup​(java.lang.String basename,
                                                     int index)
        Get a property group for the given property base at the given index.
        Parameters:
        basename - Base property name.
        index - Array property index.
        Returns:
        Property group.