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 Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newPropertiesListobject that wraps an empty newPropertiesobject.PropertiesList(Dictionary dict) Constructs a newPropertiesListobject that wraps the inputDictionary.PropertiesList(Dictionary dict, boolean searchNextFirst) Constructs a newPropertiesListobject that wraps the inputDictionary. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAfter(PropertiesList cursor) Adds thisPropertiesListobject into a linked list following the object referenced by thecursorparameter.voidaddBefore(PropertiesList cursor) Adds thisPropertiesListobject into a linked list preceding the object referenced by thecursorparameter.voidclear()Invokes the same method on the wrappedHashtableobject.clone()Invokes the same method on the wrappedHashtableobject.booleanInvokes the same method on the wrappedHashtableobject.booleancontainsKey(Object key) Invokes the same method on the wrappedHashtableobject.voidStarting 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 wrappedDictionaryobject.entrySet()Invokes the same method on the wrappedHashtableobject.booleanInvokes the same method on the wrappedHashtableobject.Invokes the same method on the wrappedDictionaryobject.getHead()Returns thePropertiesListobject that is the first object on the list of which this object is a member.getNext()Returns thePropertiesListobject that succedes this object on the list of which this object is a member.getPrior()Returns thePropertiesListobject that precedes this object on the list of which this object is a member.getProperty(String key) Looks upkeyin the wrapped object.getProperty(String key, String defaultValue) UsesgetProperty(String)to look up the value associated with the key.Returns theDictionaryobject wrapped by thisPropertiesList.inthashCode()Invokes the same method on the wrappedHashtableobject.booleanisEmpty()Invokes the same method on the wrappedDictionaryobject.booleanSub-classes of PropertiesList can override this to mark themselves "transient", in which caseaddAfterwill skip this list.keys()Invokes the same method on the wrappedDictionaryobject.keySet()Invokes the same method on the wrappedHashtableobject.voidlist(PrintStream out) Invokes the same method on the wrappedPropertiesobject.voidlist(PrintWriter out) Invokes the same method on the wrappedPropertiesobject.voidload(InputStream in) Invokes the same method on the wrappedPropertiesobject.Invokes the same method on the wrappedPropertiesobject.propertyNames(String pattern) Returns anEnumerationof property names that match aglobpattern.Invokes the same method on the wrappedDictionaryobject.voidInvokes the same method on the wrappedHashtableobject.booleanremove()Remove this object from the list in which it's a member.Invokes the same method on the wrappedDictionaryobject.booleanremoveProperty(String key) Remove the key and its associated value from the first properties object in the chain that contains this key.booleanremoveProperty(String key, boolean all) Remove a property from a a chain of properties lists.voidsave(OutputStream out, String header) Invokes the same method on the wrappedPropertiesobject.setProperty(String key, String value) Invokes the same method on the wrappedPropertiesobject if it exists.intsize()Invokes the same method on the wrappedDictionaryobject.voidstore(OutputStream out, String header) Invokes the same method on the wrappedPropertiesobject.toString()Returns aStringcontaining theSystem.identityHashCodes 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 wrappedHashtableobject.wraps(Dictionary d) Find the firstPropertiesListobject on the list of which this object is a member that wraps theDictionaryparameter.Methods inherited from class 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 debugSettrueto turn on debug output. It's alot of output and probably of use only to the author. Note, ifserver.propscontains the namedebugPropsthis variable will be settruebyServer.
-
-
Constructor Details
-
PropertiesList
public PropertiesList()Constructs a newPropertiesListobject that wraps an empty newPropertiesobject. -
PropertiesList
Constructs a newPropertiesListobject that wraps the inputDictionary.- Parameters:
dict- TheDictionaryobject wrapped by thisPropertiesList.
-
PropertiesList
Constructs a newPropertiesListobject that wraps the inputDictionary. If the boolean parameter is settrue, the wrappedDictionaryis searched after subsequentPropertiesListobjects in the linked list are searched, and only if the result of that search wasnull.- Parameters:
dict- TheDictionaryobject wrapped by thisPropertiesList.searchNextFirst- Iftrueall the following objects in the list are searched before this one.
-
-
Method Details
-
getWrapped
Returns theDictionaryobject wrapped by thisPropertiesList. -
addAfter
Adds thisPropertiesListobject into a linked list following the object referenced by thecursorparameter. 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 thisPropertiesListobject into a linked list preceding the object referenced by thecursorparameter. 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 thePropertiesListobject that succedes this object on the list of which this object is a member.- Returns:
- A
PropertiesListobject ornull.
-
getPrior
Returns thePropertiesListobject that precedes this object on the list of which this object is a member.- Returns:
- A
PropertiesListobject ornull.
-
getHead
Returns thePropertiesListobject 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
PropertiesListobject.
-
wraps
Find the firstPropertiesListobject on the list of which this object is a member that wraps theDictionaryparameter.- Parameters:
d- TheDictionarythat is compared with the wrappedDictionary's for a match.- Returns:
PropertiesListobject 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- Iftruealso print the contents of the wrappedDictionaryobject.msg- If notnull, add this message to the header line.
-
elements
Invokes the same method on the wrappedDictionaryobject.- Overrides:
elementsin classProperties
-
get
-
isEmpty
-
keys
Invokes the same method on the wrappedDictionaryobject.- Overrides:
keysin classProperties
-
put
-
remove
-
size
-
clear
-
clone
Invokes the same method on the wrappedHashtableobject.- Overrides:
clonein classProperties
-
contains
Invokes the same method on the wrappedHashtableobject.- Overrides:
containsin classProperties
-
containsKey
Invokes the same method on the wrappedHashtableobject.- Specified by:
containsKeyin interfaceMap<Object,Object> - Overrides:
containsKeyin classProperties
-
entrySet
-
equals
-
hashCode
-
keySet
-
putAll
-
values
Invokes the same method on the wrappedHashtableobject. -
toString
Returns aStringcontaining theSystem.identityHashCodes of this object, the wrapped object, and the preceding and succeding objects on the list of which this object is a member. Additionally, ifdebugistrue, the result of invokingtoStringon the wrappedDictionaryis appended.- Overrides:
toStringin classProperties- Returns:
Stringrepresentation of this object.
-
getProperty
Looks upkeyin the wrapped object. If the result isnullthe 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, thekeyis looked up in the wrappedPropertiesobject.- Overrides:
getPropertyin 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:
getPropertyin 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 wrappedPropertiesobject.- Overrides:
listin classProperties
-
list
Invokes the same method on the wrappedPropertiesobject.- Overrides:
listin classProperties
-
load
Invokes the same method on the wrappedPropertiesobject.- Overrides:
loadin classProperties- Throws:
IOException
-
propertyNames
Invokes the same method on the wrappedPropertiesobject.- Overrides:
propertyNamesin classProperties
-
save
Invokes the same method on the wrappedPropertiesobject.- Overrides:
savein classProperties
-
setProperty
Invokes the same method on the wrappedPropertiesobject if it exists. Otherwise invokesputon the wrappedDictionaryobject.- Overrides:
setPropertyin classProperties
-
store
Invokes the same method on the wrappedPropertiesobject.- Overrides:
storein classProperties- Throws:
IOException
-
propertyNames
Returns anEnumerationof property names that match aglobpattern.- Parameters:
pattern- Theglobpattern to match.- Returns:
- An
Enumerationcontaining matching property names, if any.
-
isTransient
public boolean isTransient()Sub-classes of PropertiesList can override this to mark themselves "transient", in which caseaddAfterwill skip this list.
-