Methods Summary |
---|
public void | add(NameValue nv)Adds a name value pair to the list.
if (nv == null)
throw new NullPointerException("null nv");
nvList.put(nv.getName(), nv.getValue());
|
public void | add(java.lang.String name, java.lang.Object obj)Adds a name value record to this list.
if (name == null)
throw new NullPointerException("name in null ! ");
NameValue nv = new NameValue(name, obj);
add(nv);
|
public java.lang.Object | clone()Makes a copy of the current instance.
NameValueList retval = new NameValueList();
retval.separator = this.separator;
Enumeration enumNames = nvList.keys();
String currKey;
while (enumNames.hasMoreElements()) {
currKey = (String)enumNames.nextElement();
retval.add(currKey, nvList.get(currKey));
}
return retval;
|
public boolean | delete(java.lang.String name)Removes the element corresponding to this name.
if (name == null) {
return true;
}
String name1 = name.toLowerCase();
nvList.remove(name1);
return true;
|
public java.lang.String | encode()Encodes the contenst as a string.
if (nvList.size() == 0)
return "";
StringBuffer encoding = new StringBuffer();
Enumeration enumNames = nvList.keys();
String currKey;
Object currValue;
while (enumNames.hasMoreElements()) {
currKey = (String)enumNames.nextElement();
encoding.append(currKey);
currValue = nvList.get(currKey);
if (currValue != null) {
if (currValue instanceof GenericObject) {
GenericObject gobj = (GenericObject) currValue;
encoding.append(Separators.EQUALS + gobj.encode());
} else {
String s = currValue.toString();
if (s.length() > 0) {
encoding.append(Separators.EQUALS + s);
}
}
}
if (enumNames.hasMoreElements()) // not last
encoding.append(separator);
}
return encoding.toString();
|
public java.lang.String | encodeWithSep()Encodes the contenst as a string followd by separator.
String retVal = encode();
if (retVal.length() > 0) {
retVal = separator + retVal;
}
return retVal;
|
public boolean | equals(java.lang.Object otherObject)Compares if two NameValue lists are equal.
if (!otherObject.getClass().equals
(this.getClass())) {
return false;
}
NameValueList other = (NameValueList) otherObject;
if (this.nvList.size() != other.nvList.size()) {
return false;
}
Enumeration enumNames = nvList.keys();
String currKey;
Object currValue, currValueOther;
while (enumNames.hasMoreElements()) {
currKey = (String)enumNames.nextElement();
currValue = this.nvList.get(currKey);
currValueOther = other.nvList.get(currKey);
if (
(currValueOther == null) || !currValue.equals(currValueOther)) {
return false;
}
}
return true;
|
public java.util.Enumeration | getKeys()Gets the enumeration of key names.
return nvList.keys();
|
public NameValue | getNameValue(java.lang.String name)Gets the NameValue record given a name.
if (name == null)
throw new NullPointerException("null arg!");
String name1 = name.toLowerCase();
NameValue returnValue = null;
Object value = getValue(name1);
if (value != null)
returnValue = new NameValue(name1, value);
return returnValue;
|
public java.util.Vector | getNames()Gets a list of key names.
Vector names = new Vector();
Enumeration enumNames = nvList.keys();
while (enumNames.hasMoreElements()) {
names.addElement(enumNames.nextElement());
}
return names;
|
public java.lang.String | getParameter(java.lang.String name)Gets the parameter as a String.
Object val = this.getValue(name);
if (val == null)
return null;
if (val instanceof GenericObject)
return ((GenericObject)val).encode();
else return val.toString();
|
public java.lang.Object | getValue(java.lang.String name)Do a lookup on a given name and return value associated with it.
return nvList.get(name.toLowerCase());
|
public java.lang.String | getValueDefault(java.lang.String name, java.lang.String nameDefault)Do a lookup on a given name and return value associated with it.
String returnValue = (String)nvList.get(name.toLowerCase());
if (returnValue == null) returnValue = nameDefault;
return returnValue;
|
public boolean | hasNameValue(java.lang.String name)Returns a boolean telling if this NameValueList
has a record with this name.
return nvList.containsKey(name.toLowerCase());
|
public boolean | isEmpty()Checks if the listis empty.
return this.nvList.size() == 0;
|
public void | set(NameValue nv)Sets a namevalue object in this list.
this.add(nv);
|
public void | set(java.lang.String name, java.lang.Object value)Sets a namevalue object in this list.
NameValue nv = new NameValue(name, value);
this.set(nv);
|
public void | setSeparator(java.lang.String separator)Sets the separator string to be used in formatted contents.
this.separator = separator;
|
public int | size()Gets the size of the list.
return nvList.size();
|
public java.lang.String | toString()Converts contenets to a string.
return this.encode();
|