Class ConfigurableProperties


  • public class ConfigurableProperties
    extends java.lang.Object
    Similar as Properties, with the extension to use the place-holder ${env:ENVIROMENT-NAME} for the environment, and ${sys:JAVA-PROPERTY-NAME} for the Java system property.
    Since:
    6.3.1
    Author:
    Lijun Liao (xipki)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(java.lang.String key)  
      java.lang.String getProperty​(java.lang.String key)
      Searches for the property with the specified key in this property list.
      java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
      Searches for the property with the specified key in this property list.
      int hashCode()  
      boolean isEmpty()  
      void load​(java.io.InputStream inStream)
      Reads a property list (key and element pairs) from the input byte stream.
      void load​(java.io.Reader reader)
      Reads a property list (key and element pairs) from the input character stream in a simple line-oriented format.
      void load​(java.util.Properties props)  
      java.util.Set<java.lang.String> propertyNames()
      Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.
      java.lang.String remove​(java.lang.String key)  
      java.lang.String setProperty​(java.lang.String key, java.lang.String value)
      Calls the Hashtable method put.
      int size()  
      java.util.Properties toProperties()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConfigurableProperties

        public ConfigurableProperties()
    • Method Detail

      • load

        public void load​(java.util.Properties props)
      • load

        public void load​(java.io.InputStream inStream)
                  throws java.io.IOException
        Reads a property list (key and element pairs) from the input byte stream.

        The specified stream remains open after this method returns.

        Parameters:
        inStream - the input stream.
        Throws:
        java.io.IOException - if an error occurred when reading from the input stream.
        java.lang.NullPointerException - if inStream is null.
      • load

        public void load​(java.io.Reader reader)
                  throws java.io.IOException
        Reads a property list (key and element pairs) from the input character stream in a simple line-oriented format.

        The specified stream remains open after this method returns.

        Parameters:
        reader - the input character stream.
        Throws:
        java.io.IOException - if an error occurred when reading from the input stream.
        java.lang.NullPointerException - if reader is null.
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
        Parameters:
        key - the property key.
        Returns:
        the value in this property list with the specified key value.
      • getProperty

        public java.lang.String getProperty​(java.lang.String key,
                                            java.lang.String defaultValue)
        Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.
        Parameters:
        key - the hashtable key.
        defaultValue - a default value.
        Returns:
        the value in this property list with the specified key value.
      • propertyNames

        public java.util.Set<java.lang.String> propertyNames()
        Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted.

        The returned set is not backed by this Properties object. Changes to this Properties object are not reflected in the returned set.

        Returns:
        an unmodifiable set of keys in this property list where the key and its corresponding value are strings, including the keys in the default property list.
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • containsKey

        public boolean containsKey​(java.lang.String key)
      • setProperty

        public java.lang.String setProperty​(java.lang.String key,
                                            java.lang.String value)
        Calls the Hashtable method put. Provided for parallelism with the getProperty method. Enforces use of strings for property keys and values. The value returned is the result of the Hashtable call to put.
        Parameters:
        key - the key to be placed into this property list.
        value - the value corresponding to key.
        Returns:
        the previous value of the specified key in this property list, or null if it did not have one.
      • remove

        public java.lang.String remove​(java.lang.String key)
      • clear

        public void clear()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toProperties

        public java.util.Properties toProperties()