public class PropertiesList
extends java.util.Properties
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.
Dictionary
,
Hashtable
,
Properties
,
Serialized FormModifier and Type | Field and Description |
---|---|
static boolean |
debug
Set
true to turn on debug output. |
Constructor and Description |
---|
PropertiesList()
Constructs a new
PropertiesList object that wraps
an empty new Properties object. |
PropertiesList(java.util.Dictionary dict)
Constructs a new
PropertiesList object that wraps
the input Dictionary . |
PropertiesList(java.util.Dictionary dict,
boolean searchNextFirst)
Constructs a new
PropertiesList object that wraps
the input Dictionary . |
Modifier and Type | Method and Description |
---|---|
void |
addAfter(PropertiesList cursor)
Adds this
PropertiesList object into
a linked list following the object referenced by
the cursor parameter. |
void |
addBefore(PropertiesList cursor)
Adds this
PropertiesList object into
a linked list preceding the object referenced by
the cursor parameter. |
void |
clear()
Invokes the same method on the wrapped
Hashtable object. |
java.lang.Object |
clone()
Invokes the same method on the wrapped
Hashtable object. |
boolean |
contains(java.lang.Object value)
Invokes the same method on the wrapped
Hashtable object. |
boolean |
containsKey(java.lang.Object key)
Invokes the same method on the wrapped
Hashtable object. |
void |
dump(boolean full,
java.lang.String msg)
Starting with this object, print the contents of this and
succeeding objects that are on the same list as this object
is.
|
java.util.Enumeration |
elements()
Invokes the same method on the wrapped
Dictionary object. |
java.util.Set |
entrySet()
Invokes the same method on the wrapped
Hashtable object. |
boolean |
equals(java.lang.Object o)
Invokes the same method on the wrapped
Hashtable object. |
java.lang.Object |
get(java.lang.Object key)
Invokes the same method on the wrapped
Dictionary object. |
PropertiesList |
getHead()
Returns the
PropertiesList object that is the first object
on the list of which this object is a member. |
PropertiesList |
getNext()
Returns the
PropertiesList object that succedes this
object on the list of which this object is a member. |
PropertiesList |
getPrior()
Returns the
PropertiesList object that precedes this
object on the list of which this object is a member. |
java.lang.String |
getProperty(java.lang.String key)
Looks up
key in the wrapped object. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Uses
getProperty(String) to look up the value associated
with the key. |
java.util.Dictionary |
getWrapped()
Returns the
Dictionary object wrapped by this
PropertiesList . |
int |
hashCode()
Invokes the same method on the wrapped
Hashtable object. |
boolean |
isEmpty()
Invokes the same method on the wrapped
Dictionary object. |
boolean |
isTransient()
Sub-classes of PropertiesList can override this to mark
themselves "transient", in which case
addAfter
will skip this list. |
java.util.Enumeration |
keys()
Invokes the same method on the wrapped
Dictionary object. |
java.util.Set |
keySet()
Invokes the same method on the wrapped
Hashtable object. |
void |
list(java.io.PrintStream out)
Invokes the same method on the wrapped
Properties object. |
void |
list(java.io.PrintWriter out)
Invokes the same method on the wrapped
Properties object. |
void |
load(java.io.InputStream in)
Invokes the same method on the wrapped
Properties object. |
java.util.Enumeration |
propertyNames()
Invokes the same method on the wrapped
Properties object. |
java.util.Enumeration |
propertyNames(java.lang.String pattern)
Returns an
Enumeration of property names that
match a glob pattern. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Invokes the same method on the wrapped
Dictionary object. |
void |
putAll(java.util.Map t)
Invokes the same method on the wrapped
Hashtable object. |
boolean |
remove()
Remove this object from the list in which it's a member.
|
java.lang.Object |
remove(java.lang.Object key)
Invokes the same method on the wrapped
Dictionary object. |
boolean |
removeProperty(java.lang.String key)
Remove the key and its associated value from the first properties
object in the chain that contains this key.
|
boolean |
removeProperty(java.lang.String key,
boolean all)
Remove a property from a a chain of properties lists.
|
void |
save(java.io.OutputStream out,
java.lang.String header)
Invokes the same method on the wrapped
Properties object. |
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Invokes the same method on the wrapped
Properties object
if it exists. |
int |
size()
Invokes the same method on the wrapped
Dictionary object. |
void |
store(java.io.OutputStream out,
java.lang.String header)
Invokes the same method on the wrapped
Properties object. |
java.lang.String |
toString()
Returns a
String containing the
System.identityHashCode s of this object, the wrapped
object, and the preceding and succeding objects on the list of
which this object is a member. |
java.util.Collection |
values()
Invokes the same method on the wrapped
Hashtable object. |
PropertiesList |
wraps(java.util.Dictionary d)
Find the first
PropertiesList object on the list of which
this object is a member that wraps the Dictionary
parameter. |
public static boolean debug
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
.public PropertiesList()
PropertiesList
object that wraps
an empty new Properties
object.public PropertiesList(java.util.Dictionary dict)
PropertiesList
object that wraps
the input Dictionary
.dict
- The Dictionary
object wrapped
by this PropertiesList
.public PropertiesList(java.util.Dictionary dict, boolean searchNextFirst)
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
.dict
- The Dictionary
object wrapped
by this PropertiesList
.searchNextFirst
- If true
all the following
objects in the list are searched before
this one.public java.util.Dictionary getWrapped()
Dictionary
object wrapped by this
PropertiesList
.public void addAfter(PropertiesList cursor)
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
cursor
- The list object that will precede this object.public void addBefore(PropertiesList cursor)
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 -> serverPropscursor
- The list object that will succede this object.public boolean remove()
true
.public PropertiesList getNext()
PropertiesList
object that succedes this
object on the list of which this object is a member.PropertiesList
object or
null
.public PropertiesList getPrior()
PropertiesList
object that precedes this
object on the list of which this object is a member.PropertiesList
object or
null
.public PropertiesList getHead()
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.PropertiesList
object.public PropertiesList wraps(java.util.Dictionary d)
PropertiesList
object on the list of which
this object is a member that wraps the Dictionary
parameter.d
- The Dictionary
that is compared with the
wrapped Dictionary
's for a match.PropertiesList
object that wraps the
input parameter, otherwise null
.public void dump(boolean full, java.lang.String msg)
full
- If true
also print the contents of the
wrapped Dictionary
object.msg
- If not null
, add this message to the
header line.public java.util.Enumeration elements()
Dictionary
object.elements
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.Object get(java.lang.Object key)
Dictionary
object.get
in interface java.util.Map<java.lang.Object,java.lang.Object>
get
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public boolean isEmpty()
Dictionary
object.isEmpty
in interface java.util.Map<java.lang.Object,java.lang.Object>
isEmpty
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.util.Enumeration keys()
Dictionary
object.keys
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Dictionary
object.put
in interface java.util.Map<java.lang.Object,java.lang.Object>
put
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.Object remove(java.lang.Object key)
Dictionary
object.remove
in interface java.util.Map<java.lang.Object,java.lang.Object>
remove
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public int size()
Dictionary
object.size
in interface java.util.Map<java.lang.Object,java.lang.Object>
size
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public void clear()
Hashtable
object.clear
in interface java.util.Map<java.lang.Object,java.lang.Object>
clear
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.Object clone()
Hashtable
object.clone
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public boolean contains(java.lang.Object value)
Hashtable
object.contains
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public boolean containsKey(java.lang.Object key)
Hashtable
object.containsKey
in interface java.util.Map<java.lang.Object,java.lang.Object>
containsKey
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.util.Set entrySet()
Hashtable
object.entrySet
in interface java.util.Map<java.lang.Object,java.lang.Object>
entrySet
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public boolean equals(java.lang.Object o)
Hashtable
object.equals
in interface java.util.Map<java.lang.Object,java.lang.Object>
equals
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public int hashCode()
Hashtable
object.hashCode
in interface java.util.Map<java.lang.Object,java.lang.Object>
hashCode
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.util.Set keySet()
Hashtable
object.keySet
in interface java.util.Map<java.lang.Object,java.lang.Object>
keySet
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public void putAll(java.util.Map t)
Hashtable
object.putAll
in interface java.util.Map<java.lang.Object,java.lang.Object>
putAll
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.util.Collection values()
Hashtable
object.values
in interface java.util.Map<java.lang.Object,java.lang.Object>
values
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.String toString()
String
containing the
System.identityHashCode
s 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.toString
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
String
representation of this object.public java.lang.String getProperty(java.lang.String key)
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.getProperty
in class java.util.Properties
key
- The key whose value is sought.null
.public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
getProperty(String)
to look up the value associated
with the key. If the result is null
, returns the default
value.getProperty
in class java.util.Properties
key
- The key whose value is sought.defaultValue
- The default value.null
.public boolean removeProperty(java.lang.String key, boolean all)
key
- The key whose value is to be removedall
- remove all matching keys.public boolean removeProperty(java.lang.String key)
public void list(java.io.PrintStream out)
Properties
object.list
in class java.util.Properties
public void list(java.io.PrintWriter out)
Properties
object.list
in class java.util.Properties
public void load(java.io.InputStream in) throws java.io.IOException
Properties
object.load
in class java.util.Properties
java.io.IOException
public java.util.Enumeration propertyNames()
Properties
object.propertyNames
in class java.util.Properties
public void save(java.io.OutputStream out, java.lang.String header)
Properties
object.save
in class java.util.Properties
public java.lang.Object setProperty(java.lang.String key, java.lang.String value)
Properties
object
if it exists. Otherwise invokes put
on the wrapped
Dictionary
object.setProperty
in class java.util.Properties
public void store(java.io.OutputStream out, java.lang.String header) throws java.io.IOException
Properties
object.store
in class java.util.Properties
java.io.IOException
public java.util.Enumeration propertyNames(java.lang.String pattern)
Enumeration
of property names that
match a glob
pattern.pattern
- The glob
pattern to match.Enumeration
containing
matching property names, if any.public boolean isTransient()
addAfter
will skip this list.