Class PropertiesList

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class PropertiesList extends Properties
A PropertiesList instance is intended to be an element of a doubly linked list consisting of other PropertiesList instances. Each PropertiesList instance "wraps" a Dictionary object. A PropertiesList is a subclass of Properties and therefore provides the same API, including the methods and fields of Dictionary and Hashtable. The PropertiesList class overrides all methods of the Properties API and delegates the method evaluation to the wrapped Properties object.

The linked list of PropertiesList objects is constructed by Request for each incoming request. That is, there is a unique PropertiesList linked list for each request. The head of the initial list constructed by request is Request.props and the tail of the two element list is Request.serverProps. The former wraps an empty Properties object, while the latter wraps Server.props. Other PropertiesList objects can be added, and removed, from this initial list as required.

Given a reference to a PropertiesList object on the linked list (e.g. request.props), one typically "looks up" the value associated with a name using the getProperty method, which delegates to the wrapped Properties.getProperty method. If the result is null, meaning the name/value pair is not stored in the wrapped Properties object, the request is "forwarded" to the next object on the linked list, and so on until either the name/value pair is found (and the value is returned) or the end of the list is reached (and null is returned).

It may be desirable for the name/value lookup to be delayed until after the lookup request has been passed on to subsequent objects on the list. This can be done by using the two parameter constructor and setting the second, boolean, parameter to true. Then the getProperty request is forwarded to the next object in the list rather than delegated to the wrapped Properties object. If the result of the forwarded request is null, the request is then passed to the wrapped Properties object and it's result is returned.

Version:
2.8
Author:
Steve Drach <drach@sun.com>
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
    Set true to turn on debug output.

    Fields inherited from class Properties

    defaults
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new PropertiesList object that wraps an empty new Properties object.
    Constructs a new PropertiesList object that wraps the input Dictionary.
    PropertiesList(Dictionary dict, boolean searchNextFirst)
    Constructs a new PropertiesList object that wraps the input Dictionary.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds this PropertiesList object into a linked list following the object referenced by the cursor parameter.
    void
    Adds this PropertiesList object into a linked list preceding the object referenced by the cursor parameter.
    void
    Invokes the same method on the wrapped Hashtable object.
    Invokes the same method on the wrapped Hashtable object.
    boolean
    Invokes the same method on the wrapped Hashtable object.
    boolean
    Invokes the same method on the wrapped Hashtable object.
    void
    dump(boolean full, String msg)
    Starting with this object, print the contents of this and succeeding objects that are on the same list as this object is.
    Invokes the same method on the wrapped Dictionary object.
    Invokes the same method on the wrapped Hashtable object.
    boolean
    Invokes the same method on the wrapped Hashtable object.
    get(Object key)
    Invokes the same method on the wrapped Dictionary object.
    Returns the PropertiesList object that is the first object on the list of which this object is a member.
    Returns the PropertiesList object that succedes this object on the list of which this object is a member.
    Returns the PropertiesList object that precedes this object on the list of which this object is a member.
    Looks up key in the wrapped object.
    getProperty(String key, String defaultValue)
    Uses getProperty(String) to look up the value associated with the key.
    Returns the Dictionary object wrapped by this PropertiesList.
    int
    Invokes the same method on the wrapped Hashtable object.
    boolean
    Invokes the same method on the wrapped Dictionary object.
    boolean
    Sub-classes of PropertiesList can override this to mark themselves "transient", in which case addAfter will skip this list.
    Invokes the same method on the wrapped Dictionary object.
    Invokes the same method on the wrapped Hashtable object.
    void
    Invokes the same method on the wrapped Properties object.
    void
    Invokes the same method on the wrapped Properties object.
    void
    Invokes the same method on the wrapped Properties object.
    Invokes the same method on the wrapped Properties object.
    Returns an Enumeration of property names that match a glob pattern.
    put(Object key, Object value)
    Invokes the same method on the wrapped Dictionary object.
    void
    Invokes the same method on the wrapped Hashtable object.
    boolean
    Remove this object from the list in which it's a member.
    Invokes the same method on the wrapped Dictionary object.
    boolean
    Remove the key and its associated value from the first properties object in the chain that contains this key.
    boolean
    removeProperty(String key, boolean all)
    Remove a property from a a chain of properties lists.
    void
    save(OutputStream out, String header)
    Invokes the same method on the wrapped Properties object.
    setProperty(String key, String value)
    Invokes the same method on the wrapped Properties object if it exists.
    int
    Invokes the same method on the wrapped Dictionary object.
    void
    store(OutputStream out, String header)
    Invokes the same method on the wrapped Properties object.
    Returns a String containing the System.identityHashCodes of this object, the wrapped object, and the preceding and succeding objects on the list of which this object is a member.
    Invokes the same method on the wrapped Hashtable object.
    Find the first PropertiesList object on the list of which this object is a member that wraps the Dictionary parameter.

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • debug

      public static boolean debug
      Set true to turn on debug output. It's alot of output and probably of use only to the author. Note, if server.props contains the name debugProps this variable will be set true by Server.
  • Constructor Details

    • PropertiesList

      public PropertiesList()
      Constructs a new PropertiesList object that wraps an empty new Properties object.
    • PropertiesList

      public PropertiesList(Dictionary dict)
      Constructs a new PropertiesList object that wraps the input Dictionary.
      Parameters:
      dict - The Dictionary object wrapped by this PropertiesList.
    • PropertiesList

      public PropertiesList(Dictionary dict, boolean searchNextFirst)
      Constructs a new PropertiesList object that wraps the input Dictionary. If the boolean parameter is set true, the wrapped Dictionary is searched after subsequent PropertiesList objects in the linked list are searched, and only if the result of that search was null.
      Parameters:
      dict - The Dictionary object wrapped by this PropertiesList.
      searchNextFirst - If true all the following objects in the list are searched before this one.
  • Method Details

    • getWrapped

      public Dictionary getWrapped()
      Returns the Dictionary object wrapped by this PropertiesList.
    • addAfter

      public void addAfter(PropertiesList cursor)
      Adds this PropertiesList object into a linked list following the object referenced by the cursor parameter. The result is a list that could look like: request.props -> cursor -> this -> serverProps

      Any transient properties lists's are skipped over before this one is inserted into the list

      Parameters:
      cursor - The list object that will precede this object.
    • addBefore

      public void addBefore(PropertiesList cursor)
      Adds this PropertiesList object into a linked list preceding the object referenced by the cursor parameter. The result is a list that could look like: request.props -> this -> cursor -> serverProps
      Parameters:
      cursor - The list object that will succede this object.
    • remove

      public boolean remove()
      Remove this object from the list in which it's a member.
      Returns:
      true.
    • getNext

      public PropertiesList getNext()
      Returns the PropertiesList object that succedes this object on the list of which this object is a member.
      Returns:
      A PropertiesList object or null.
    • getPrior

      public PropertiesList getPrior()
      Returns the PropertiesList object that precedes this object on the list of which this object is a member.
      Returns:
      A PropertiesList object or null.
    • getHead

      public PropertiesList getHead()
      Returns the PropertiesList object that is the first object on the list of which this object is a member. Note that the first object may be this object.
      Returns:
      A PropertiesList object.
    • wraps

      public PropertiesList wraps(Dictionary d)
      Find the first PropertiesList object on the list of which this object is a member that wraps the Dictionary parameter.
      Parameters:
      d - The Dictionary that is compared with the wrapped Dictionary's for a match.
      Returns:
      PropertiesList object that wraps the input parameter, otherwise null.
    • dump

      public void dump(boolean full, String msg)
      Starting with this object, print the contents of this and succeeding objects that are on the same list as this object is.
      Parameters:
      full - If true also print the contents of the wrapped Dictionary object.
      msg - If not null, add this message to the header line.
    • elements

      public Enumeration elements()
      Invokes the same method on the wrapped Dictionary object.
      Overrides:
      elements in class Properties
    • get

      public Object get(Object key)
      Invokes the same method on the wrapped Dictionary object.
      Specified by:
      get in interface Map<Object,Object>
      Overrides:
      get in class Properties
    • isEmpty

      public boolean isEmpty()
      Invokes the same method on the wrapped Dictionary object.
      Specified by:
      isEmpty in interface Map<Object,Object>
      Overrides:
      isEmpty in class Properties
    • keys

      public Enumeration keys()
      Invokes the same method on the wrapped Dictionary object.
      Overrides:
      keys in class Properties
    • put

      public Object put(Object key, Object value)
      Invokes the same method on the wrapped Dictionary object.
      Specified by:
      put in interface Map<Object,Object>
      Overrides:
      put in class Properties
    • remove

      public Object remove(Object key)
      Invokes the same method on the wrapped Dictionary object.
      Specified by:
      remove in interface Map<Object,Object>
      Overrides:
      remove in class Properties
    • size

      public int size()
      Invokes the same method on the wrapped Dictionary object.
      Specified by:
      size in interface Map<Object,Object>
      Overrides:
      size in class Properties
    • clear

      public void clear()
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      clear in interface Map<Object,Object>
      Overrides:
      clear in class Properties
    • clone

      public Object clone()
      Invokes the same method on the wrapped Hashtable object.
      Overrides:
      clone in class Properties
    • contains

      public boolean contains(Object value)
      Invokes the same method on the wrapped Hashtable object.
      Overrides:
      contains in class Properties
    • containsKey

      public boolean containsKey(Object key)
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      containsKey in interface Map<Object,Object>
      Overrides:
      containsKey in class Properties
    • entrySet

      public Set entrySet()
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      entrySet in interface Map<Object,Object>
      Overrides:
      entrySet in class Properties
    • equals

      public boolean equals(Object o)
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      equals in interface Map<Object,Object>
      Overrides:
      equals in class Properties
    • hashCode

      public int hashCode()
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      hashCode in interface Map<Object,Object>
      Overrides:
      hashCode in class Properties
    • keySet

      public Set keySet()
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      keySet in interface Map<Object,Object>
      Overrides:
      keySet in class Properties
    • putAll

      public void putAll(Map t)
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      putAll in interface Map<Object,Object>
      Overrides:
      putAll in class Properties
    • values

      public Collection values()
      Invokes the same method on the wrapped Hashtable object.
      Specified by:
      values in interface Map<Object,Object>
      Overrides:
      values in class Properties
    • toString

      public String toString()
      Returns a String containing the System.identityHashCodes of this object, the wrapped object, and the preceding and succeding objects on the list of which this object is a member. Additionally, if debug is true, the result of invoking toString on the wrapped Dictionary is appended.
      Overrides:
      toString in class Properties
      Returns:
      String representation of this object.
    • getProperty

      public String getProperty(String key)
      Looks up key in the wrapped object. If the result is null the request is forwarded to the succeeding object in the list of which this object is a member. If the search order was changed by constructing this object with the two parameter constructor, the request is first forwarded and then, if the result of the forwarded request is null, the key is looked up in the wrapped Properties object.
      Overrides:
      getProperty in class Properties
      Parameters:
      key - The key whose value is sought.
      Returns:
      The value or null.
    • getProperty

      public String getProperty(String key, String defaultValue)
      Uses getProperty(String) to look up the value associated with the key. If the result is null, returns the default value.
      Overrides:
      getProperty in class Properties
      Parameters:
      key - The key whose value is sought.
      defaultValue - The default value.
      Returns:
      The value or null.
    • removeProperty

      public boolean removeProperty(String key, boolean all)
      Remove a property from a a chain of properties lists. if "all" is specified, then remove all the keys and values from all property lists in the chain instead of just the first one found.
      Parameters:
      key - The key whose value is to be removed
      all - remove all matching keys.
      Returns:
      true, if at least one key/value pair was removed.
    • removeProperty

      public boolean removeProperty(String key)
      Remove the key and its associated value from the first properties object in the chain that contains this key.
      Returns:
      true, if the key was removed.
    • list

      public void list(PrintStream out)
      Invokes the same method on the wrapped Properties object.
      Overrides:
      list in class Properties
    • list

      public void list(PrintWriter out)
      Invokes the same method on the wrapped Properties object.
      Overrides:
      list in class Properties
    • load

      public void load(InputStream in) throws IOException
      Invokes the same method on the wrapped Properties object.
      Overrides:
      load in class Properties
      Throws:
      IOException
    • propertyNames

      public Enumeration propertyNames()
      Invokes the same method on the wrapped Properties object.
      Overrides:
      propertyNames in class Properties
    • save

      public void save(OutputStream out, String header)
      Invokes the same method on the wrapped Properties object.
      Overrides:
      save in class Properties
    • setProperty

      public Object setProperty(String key, String value)
      Invokes the same method on the wrapped Properties object if it exists. Otherwise invokes put on the wrapped Dictionary object.
      Overrides:
      setProperty in class Properties
    • store

      public void store(OutputStream out, String header) throws IOException
      Invokes the same method on the wrapped Properties object.
      Overrides:
      store in class Properties
      Throws:
      IOException
    • propertyNames

      public Enumeration propertyNames(String pattern)
      Returns an Enumeration of property names that match a glob pattern.
      Parameters:
      pattern - The glob pattern to match.
      Returns:
      An Enumeration containing matching property names, if any.
    • isTransient

      public boolean isTransient()
      Sub-classes of PropertiesList can override this to mark themselves "transient", in which case addAfter will skip this list.