Class PropertiesList
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
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
FieldsFields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newPropertiesList
object that wraps an empty newProperties
object.PropertiesList
(Dictionary dict) Constructs a newPropertiesList
object that wraps the inputDictionary
.PropertiesList
(Dictionary dict, boolean searchNextFirst) Constructs a newPropertiesList
object that wraps the inputDictionary
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAfter
(PropertiesList cursor) Adds thisPropertiesList
object into a linked list following the object referenced by thecursor
parameter.void
addBefore
(PropertiesList cursor) Adds thisPropertiesList
object into a linked list preceding the object referenced by thecursor
parameter.void
clear()
Invokes the same method on the wrappedHashtable
object.clone()
Invokes the same method on the wrappedHashtable
object.boolean
Invokes the same method on the wrappedHashtable
object.boolean
containsKey
(Object key) Invokes the same method on the wrappedHashtable
object.void
Starting with this object, print the contents of this and succeeding objects that are on the same list as this object is.elements()
Invokes the same method on the wrappedDictionary
object.entrySet()
Invokes the same method on the wrappedHashtable
object.boolean
Invokes the same method on the wrappedHashtable
object.Invokes the same method on the wrappedDictionary
object.getHead()
Returns thePropertiesList
object that is the first object on the list of which this object is a member.getNext()
Returns thePropertiesList
object that succedes this object on the list of which this object is a member.getPrior()
Returns thePropertiesList
object that precedes this object on the list of which this object is a member.getProperty
(String key) Looks upkey
in the wrapped object.getProperty
(String key, String defaultValue) UsesgetProperty(String)
to look up the value associated with the key.Returns theDictionary
object wrapped by thisPropertiesList
.int
hashCode()
Invokes the same method on the wrappedHashtable
object.boolean
isEmpty()
Invokes the same method on the wrappedDictionary
object.boolean
Sub-classes of PropertiesList can override this to mark themselves "transient", in which caseaddAfter
will skip this list.keys()
Invokes the same method on the wrappedDictionary
object.keySet()
Invokes the same method on the wrappedHashtable
object.void
list
(PrintStream out) Invokes the same method on the wrappedProperties
object.void
list
(PrintWriter out) Invokes the same method on the wrappedProperties
object.void
load
(InputStream in) Invokes the same method on the wrappedProperties
object.Invokes the same method on the wrappedProperties
object.propertyNames
(String pattern) Returns anEnumeration
of property names that match aglob
pattern.Invokes the same method on the wrappedDictionary
object.void
Invokes the same method on the wrappedHashtable
object.boolean
remove()
Remove this object from the list in which it's a member.Invokes the same method on the wrappedDictionary
object.boolean
removeProperty
(String key) 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 wrappedProperties
object.setProperty
(String key, String value) Invokes the same method on the wrappedProperties
object if it exists.int
size()
Invokes the same method on the wrappedDictionary
object.void
store
(OutputStream out, String header) Invokes the same method on the wrappedProperties
object.toString()
Returns aString
containing theSystem.identityHashCode
s of this object, the wrapped object, and the preceding and succeding objects on the list of which this object is a member.values()
Invokes the same method on the wrappedHashtable
object.wraps
(Dictionary d) Find the firstPropertiesList
object on the list of which this object is a member that wraps theDictionary
parameter.Methods inherited from class java.util.Properties
compute, computeIfAbsent, computeIfPresent, containsValue, forEach, getOrDefault, load, loadFromXML, merge, putIfAbsent, rehash, remove, replace, replace, replaceAll, store, storeToXML, storeToXML, storeToXML, stringPropertyNames
-
Field Details
-
debug
public static boolean debugSettrue
to turn on debug output. It's alot of output and probably of use only to the author. Note, ifserver.props
contains the namedebugProps
this variable will be settrue
byServer
.
-
-
Constructor Details
-
PropertiesList
public PropertiesList()Constructs a newPropertiesList
object that wraps an empty newProperties
object. -
PropertiesList
Constructs a newPropertiesList
object that wraps the inputDictionary
.- Parameters:
dict
- TheDictionary
object wrapped by thisPropertiesList
.
-
PropertiesList
Constructs a newPropertiesList
object that wraps the inputDictionary
. If the boolean parameter is settrue
, the wrappedDictionary
is searched after subsequentPropertiesList
objects in the linked list are searched, and only if the result of that search wasnull
.- Parameters:
dict
- TheDictionary
object wrapped by thisPropertiesList
.searchNextFirst
- Iftrue
all the following objects in the list are searched before this one.
-
-
Method Details
-
getWrapped
Returns theDictionary
object wrapped by thisPropertiesList
. -
addAfter
Adds thisPropertiesList
object into a linked list following the object referenced by thecursor
parameter. The result is a list that could look like: request.props -> cursor -> this -> serverPropsAny 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
Adds thisPropertiesList
object into a linked list preceding the object referenced by thecursor
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
Returns thePropertiesList
object that succedes this object on the list of which this object is a member.- Returns:
- A
PropertiesList
object ornull
.
-
getPrior
Returns thePropertiesList
object that precedes this object on the list of which this object is a member.- Returns:
- A
PropertiesList
object ornull
.
-
getHead
Returns thePropertiesList
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
Find the firstPropertiesList
object on the list of which this object is a member that wraps theDictionary
parameter.- Parameters:
d
- TheDictionary
that is compared with the wrappedDictionary
's for a match.- Returns:
PropertiesList
object that wraps the input parameter, otherwisenull
.
-
dump
Starting with this object, print the contents of this and succeeding objects that are on the same list as this object is.- Parameters:
full
- Iftrue
also print the contents of the wrappedDictionary
object.msg
- If notnull
, add this message to the header line.
-
elements
Invokes the same method on the wrappedDictionary
object.- Overrides:
elements
in classProperties
-
get
Invokes the same method on the wrappedDictionary
object. -
isEmpty
public boolean isEmpty()Invokes the same method on the wrappedDictionary
object. -
keys
Invokes the same method on the wrappedDictionary
object.- Overrides:
keys
in classProperties
-
put
Invokes the same method on the wrappedDictionary
object. -
remove
Invokes the same method on the wrappedDictionary
object. -
size
public int size()Invokes the same method on the wrappedDictionary
object. -
clear
public void clear()Invokes the same method on the wrappedHashtable
object. -
clone
Invokes the same method on the wrappedHashtable
object.- Overrides:
clone
in classProperties
-
contains
Invokes the same method on the wrappedHashtable
object.- Overrides:
contains
in classProperties
-
containsKey
Invokes the same method on the wrappedHashtable
object.- Specified by:
containsKey
in interfaceMap<Object,
Object> - Overrides:
containsKey
in classProperties
-
entrySet
Invokes the same method on the wrappedHashtable
object. -
equals
Invokes the same method on the wrappedHashtable
object. -
hashCode
public int hashCode()Invokes the same method on the wrappedHashtable
object. -
keySet
Invokes the same method on the wrappedHashtable
object. -
putAll
Invokes the same method on the wrappedHashtable
object. -
values
Invokes the same method on the wrappedHashtable
object. -
toString
Returns aString
containing theSystem.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, ifdebug
istrue
, the result of invokingtoString
on the wrappedDictionary
is appended.- Overrides:
toString
in classProperties
- Returns:
String
representation of this object.
-
getProperty
Looks upkey
in the wrapped object. If the result isnull
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 isnull
, thekey
is looked up in the wrappedProperties
object.- Overrides:
getProperty
in classProperties
- Parameters:
key
- The key whose value is sought.- Returns:
- The value or
null
.
-
getProperty
UsesgetProperty(String)
to look up the value associated with the key. If the result isnull
, returns the default value.- Overrides:
getProperty
in classProperties
- Parameters:
key
- The key whose value is sought.defaultValue
- The default value.- Returns:
- The value or
null
.
-
removeProperty
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 removedall
- remove all matching keys.- Returns:
- true, if at least one key/value pair was removed.
-
removeProperty
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
Invokes the same method on the wrappedProperties
object.- Overrides:
list
in classProperties
-
list
Invokes the same method on the wrappedProperties
object.- Overrides:
list
in classProperties
-
load
Invokes the same method on the wrappedProperties
object.- Overrides:
load
in classProperties
- Throws:
IOException
-
propertyNames
Invokes the same method on the wrappedProperties
object.- Overrides:
propertyNames
in classProperties
-
save
Invokes the same method on the wrappedProperties
object.- Overrides:
save
in classProperties
-
setProperty
Invokes the same method on the wrappedProperties
object if it exists. Otherwise invokesput
on the wrappedDictionary
object.- Overrides:
setProperty
in classProperties
-
store
Invokes the same method on the wrappedProperties
object.- Overrides:
store
in classProperties
- Throws:
IOException
-
propertyNames
Returns anEnumeration
of property names that match aglob
pattern.- Parameters:
pattern
- Theglob
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 caseaddAfter
will skip this list.
-