public class ParameterList extends java.lang.Object implements CloneImplemented, java.io.Serializable, java.lang.Iterable<Parameter>
for more on the individual parameters
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
cat |
static java.lang.String |
copyrightNotice |
static java.lang.String |
DEF_MERGE_DUPE_VALUES_DELIM |
static java.lang.String |
DEF_MERGE_DUPE_VALUES_DELIM_URLENC |
Constructor and Description |
---|
ParameterList()
Constructs an empty parameter list.
|
ParameterList(boolean dupesAllowed)
Constructs an empty parameter list, setting the allows dupes flag
(it does allow dupes by default)
|
ParameterList(org.w3c.dom.Element parent)
This constructor will build a ParameterList object from the given XML
Node.
|
ParameterList(java.lang.String paramData)
Constructs a parameter list out of a string.
|
ParameterList(java.lang.String paramData,
boolean allowDups) |
ParameterList(java.lang.String paramData,
java.lang.String mergeDupesDelimiter)
Constructs a parameter list out of a string.
|
ParameterList(java.lang.String paramData,
java.lang.String mergeDupesDelimiter,
java.lang.String delimiter) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(java.util.Map<?,?> newOnes)
Method to bulk-append a Map to this one.
|
void |
addAll(ParameterList newOnes)
Method to bulk-append another list to this one.
|
void |
addAll(ParameterList newOnes,
boolean allowDupes)
Method to bulk-append another list to this one.
|
void |
addChildNodes(org.w3c.dom.Element parent)
Given a parent XML DOM Element, this method will add all the child
nodes' attributes as parameters, plus any child text elements as Parameters
with the key of the element name and the value of the child text.
|
void |
addNodeAttributes(org.w3c.dom.Element el)
This method will add every attribute in the given XML DOM Element to
this list
|
void |
addParameter(int index,
Parameter parameter) |
void |
addParameter(Parameter t)
Adds a new Parameter to the end of the list
|
void |
addParameters(java.lang.String paramData)
Adds the set of Parameter objects that can be parsed from the given String.
|
void |
addParameters(java.lang.String paramData,
boolean encoded)
Adds the set of Parameter objects that can be parsed from the given String.
|
void |
addTerm(Parameter t)
Deprecated.
use addParameter() instead
|
ParameterList |
buildTempUnmergedList() |
int |
capacity()
This returns the capacity of our underlying vector.
|
void |
clear() |
java.lang.Object |
clone()
Does a deep copy of the current object into a new ParameterList object.
|
ParameterList |
cloneQuick()
Does a shallow copy of the current object into a new ParameterList object.
|
boolean |
containsKey(java.lang.String key) |
void |
decodeParamsFromUnicode() |
void |
encodeParamsToUnicode() |
boolean |
equals(java.lang.Object o) |
Parameter |
get(int index) |
java.lang.String |
get(java.lang.String key) |
java.util.Map<java.lang.String,java.lang.Object> |
getAllKeyValuePairs() |
java.lang.String |
getDelimiter() |
java.lang.String[] |
getKeyArray()
Will build a string array of every key in our list, then return it.
|
Parameter |
getMatchingParameter(Parameter p)
If the list contains a parameter with the same key and value as the one passed in,
we return it.
|
java.lang.String |
getMergeDupesDelimiter() |
Parameter |
getParameter(java.lang.String key)
A way to get an individual Parameter from the collection
|
Parameter |
getParameterByValue(java.lang.String value) |
java.lang.String |
getParameterValue(java.lang.String key)
Method used to retrieve the value side of a Parameter.
|
Parameter |
getTerm(java.lang.String key)
Deprecated.
use getParameter()
|
java.lang.String |
getTermValue(java.lang.String key)
Deprecated.
use getParameterValue()
|
java.lang.String[] |
getValueArray()
Will build a string array of every value in our list, then return it.
|
boolean |
hasDupeKey(boolean ignoreCase)
Does String compares on the keys in our list to determine if we have a dupe
|
int |
hashCode() |
boolean |
hasMatchingParameter(Parameter p)
This method does a value-based comparison of the parameter list for the given
parameter.
|
void |
initialize(org.w3c.dom.Element parent) |
boolean |
isDupesAllowed()
Tells us what the allow-dupes setting is allowed
|
boolean |
isEncoded()
Tells us what the allow-dupes setting is allowed
|
java.util.Iterator<Parameter> |
iterator() |
void |
moveDown(int row) |
void |
moveUp(int row) |
void |
put(java.lang.String key,
java.lang.String value) |
void |
readEncryptedPropertyFile(java.lang.String fname)
Reads a property file which may contain encrypted property values
|
void |
readPropertyFile(java.lang.String fname)
This is a handy way to read a whole old-school properties file into this ParameterList
|
void |
readPropertyStream(java.io.InputStream inputStream)
This method constructs a ParameterList by reading the contents from the
specified input stream.
|
void |
remove(int index) |
void |
removeAllParameters()
Will remove all the parameters from the list, a synomym for clear()
|
void |
removeParameter(java.lang.String key)
Removes the given Parameter from the list
|
void |
removeTerm(java.lang.String key)
Deprecated.
use removeParameter()
|
void |
reset()
Clears the collection of Parameters in this list
|
void |
setAllowDupes(boolean allowDupes)
Tell us whether to allow duplicate keys in the collection.
|
void |
setDelimiter(java.lang.String delimiter) |
void |
setEncoded(boolean encoded)
Tell us whether the ParameterList is URL-encoded.
|
void |
setMergeDupesDelimiter(java.lang.String mergeDupesDelimiter)
Providing a delimiter has the affect of not allowing dupe keys in the list, but instead of
just ignoring them, it appends the dupe value to the existing parameter.
|
void |
setParameterValue(java.lang.String key,
java.lang.String value)
Sometimes you want to allow for duplicate values in a list but you want the ability to
set a parameter value as if you didn't.
|
int |
size()
The number of Parameters in the list
|
void |
sortOnKeys()
Will sort the ParameterList according to the keys
|
void |
sortOnValues()
Will sort the ParameterList according to the values
|
java.util.Enumeration<Parameter> |
terms()
Returns an Enumeration for the Parameters in the list
|
java.lang.String |
toArgumentString()
Returns the key notation string for this list
|
java.lang.String |
toAttributeString()
An attribute string doesn't use the & between terms.
|
java.lang.String |
toDecodedArgumentString() |
java.lang.String |
toEncodedArgumentString() |
java.lang.String |
toString()
Returns the key notation string for this list
|
int |
totalWeight()
The total weight of Parameters in the list
|
java.lang.String[] |
unMergeParameterValues(Parameter p) |
void |
writeEncryptedPropsFile(java.io.OutputStream os)
Write the properties to the given OutputStream.
|
void |
writeEncryptedPropsFile(java.io.PrintWriter ps)
Deprecated.
Please use
( OutputStream ) |
void |
writePropertyFile(java.io.PrintWriter ps) |
void |
writeSimpleUnsafeXML(java.io.PrintWriter pw,
int indent)
Builds an element string out of the list.
|
void |
writeXML(java.io.PrintWriter pw,
int indent)
This method generates the Parameter Terms into an XML-like series
of child nodes.
|
void |
writeXML(java.io.PrintWriter pw,
int indent,
boolean writeTypeMap) |
void |
writeXML(java.io.PrintWriter pw,
int indent,
boolean writeTypeMap,
boolean usesUnicode) |
java.lang.String |
writeXMLString(int indent)
Builds an element string out of the list.
|
public static final java.lang.String copyrightNotice
protected static org.apache.log4j.Logger cat
public static final java.lang.String DEF_MERGE_DUPE_VALUES_DELIM
public static final java.lang.String DEF_MERGE_DUPE_VALUES_DELIM_URLENC
public ParameterList()
public ParameterList(java.lang.String paramData)
paramData
- - the string of parameter datapublic ParameterList(java.lang.String paramData, boolean allowDups)
public ParameterList(java.lang.String paramData, java.lang.String mergeDupesDelimiter)
paramData
- - the string of parameter datamergeDupesDelimiter
- - the delimiter to use for merging dupe key values; pass
DEF_MERGE_DUPE_VALUES_DELIM to get what this class uses by defaultpublic ParameterList(java.lang.String paramData, java.lang.String mergeDupesDelimiter, java.lang.String delimiter)
public ParameterList(org.w3c.dom.Element parent)
parent
- - the parent DOM Element for this new parameters collection
For more info on how this actually works, see the following:public ParameterList(boolean dupesAllowed)
dupesAllowed
- true to allow duplicate keyspublic void initialize(org.w3c.dom.Element parent)
public void setAllowDupes(boolean allowDupes)
allowDupes
- - to tell us whether to replace instead of append dupe keyspublic boolean isDupesAllowed()
public void setEncoded(boolean encoded)
encoded
- - to tell us whether values are URL-encoded in the collectionpublic boolean isEncoded()
public java.lang.String getMergeDupesDelimiter()
public void setMergeDupesDelimiter(java.lang.String mergeDupesDelimiter)
mergeDupesDelimiter
- the token to use to separate dupe values for a given keypublic java.lang.String getDelimiter()
public void setDelimiter(java.lang.String delimiter)
public void encodeParamsToUnicode()
public void decodeParamsFromUnicode()
public boolean hasDupeKey(boolean ignoreCase)
ignoreCase
- public void addParameters(java.lang.String paramData)
paramData
- the additional Parameters you want added to this Listpublic void addParameters(java.lang.String paramData, boolean encoded)
paramData
- the additional Parameters you want added to this Listencoded
- a flag indicating whether the string should be URL decoded or not.public void readPropertyFile(java.lang.String fname) throws java.io.IOException
fname
- the string to the stream (StreamHelp-based)java.io.IOException
- If an I/O exception occurs reading or closing the input stream.public void readPropertyStream(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- java.io.IOException
public void readEncryptedPropertyFile(java.lang.String fname) throws java.io.IOException
fname
- the FQN of (or URL to) the property file (NotNull
)java.io.IOException
- for I/O errors encountered reading the filepublic java.lang.Object clone()
clone
in interface CloneImplemented
clone
in class java.lang.Object
public ParameterList cloneQuick()
public void reset()
public boolean containsKey(java.lang.String key)
public Parameter getMatchingParameter(Parameter p)
public boolean hasMatchingParameter(Parameter p)
public void sortOnKeys()
public void sortOnValues()
public void addParameter(int index, Parameter parameter) throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
public void addParameter(Parameter t)
t
- the parameter to addpublic void addTerm(Parameter t)
t
- public void put(java.lang.String key, java.lang.String value)
public void addNodeAttributes(org.w3c.dom.Element el)
el
- XML DOM Element whose attributes you want addedfor an example
public void addChildNodes(org.w3c.dom.Element parent)
<Parent> <Sub1 key1=value>text</Sub1> <key2>value2</key2> </Parent>Will add the following: key1=value&Sub1=text&key2=value2
parent
- public int size()
public int totalWeight()
public java.util.Enumeration<Parameter> terms()
public Parameter getTerm(java.lang.String key)
key
- - the key for this ParametergetParameter(java.lang.String)
public java.lang.String getTermValue(java.lang.String key)
key
- - the key for the Parameter to returnpublic Parameter getParameter(java.lang.String key)
key
- - for the Parameter you wantpublic Parameter getParameterByValue(java.lang.String value)
public java.lang.String get(java.lang.String key)
public java.util.Map<java.lang.String,java.lang.Object> getAllKeyValuePairs()
public java.lang.String getParameterValue(java.lang.String key)
key
- - the key for the parameter to findpublic void setParameterValue(java.lang.String key, java.lang.String value)
key
- the key to the parameter to update.value
- the (possibly new) value for named parameter.public void removeTerm(java.lang.String key)
key
- public void removeParameter(java.lang.String key)
key
- - for the parameter to removepublic void clear()
public void removeAllParameters()
public void addAll(ParameterList newOnes)
newOnes
- the ParameterList to add to this onepublic void addAll(ParameterList newOnes, boolean allowDupes)
newOnes
- the ParameterList to add to this onepublic void addAll(java.util.Map<?,?> newOnes)
newOnes
- the Map of key/values to add to this onepublic Parameter get(int index)
public void remove(int index)
public void moveUp(int row)
public void moveDown(int row)
public java.lang.String[] getKeyArray()
public java.lang.String[] getValueArray()
public java.lang.String[] unMergeParameterValues(Parameter p)
public ParameterList buildTempUnmergedList()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toArgumentString()
public java.lang.String toDecodedArgumentString()
public java.lang.String toEncodedArgumentString()
public java.lang.String toAttributeString()
public java.lang.String writeXMLString(int indent)
<key1>value1</key1>The entire string will be indented by the given spaces
<singleton>singleton</singleton>
<key2>value2</key2>
indent
- - how many spaces to pad each "line" in the stringpublic void writeSimpleUnsafeXML(java.io.PrintWriter pw, int indent)
<key1>value1</key1>The entire string will be indented by the given spaces
<singleton>singleton</singleton>
<key2>value2</key2>
public void writeXML(java.io.PrintWriter pw, int indent, boolean writeTypeMap, boolean usesUnicode)
public void writeXML(java.io.PrintWriter pw, int indent)
<Key1>value1</Key1> <Key2>value2</Key2>Singleton Terms will have the same Tag and inner text.
pw
- is the Writer to be filled with this resultindent
- is a number of spaces to prepend to every output line.public void writeXML(java.io.PrintWriter pw, int indent, boolean writeTypeMap)
public void writePropertyFile(java.io.PrintWriter ps)
public void writeEncryptedPropsFile(java.io.OutputStream os)
os
- the file to which the properties are writtenpublic void writeEncryptedPropsFile(java.io.PrintWriter ps)
( OutputStream )
public java.util.Iterator<Parameter> iterator()
iterator
in interface java.lang.Iterable<Parameter>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int capacity()
Copyright © 1998-2014 CA, Inc. All Rights Reserved.