Methods Summary |
---|
public synchronized void | addProperty(java.lang.String key, java.lang.String value)Store multiple key:value pair. Provided for parallelism with the
getProperty method. Enforces use of strings for
property keys and values.
if (keys == null) {
convertInitPropsToVectors();
}
keys.addElement(key);
vals.addElement(value);
return;
|
private void | convertInitPropsToVectors()Convert the init property String array to vectors for changing
properties.
int numberOfProps;
numberOfProps = initProps.length / 2;
keys = new Vector(numberOfProps + INITIAL_SIZE);
vals = new Vector(numberOfProps + INITIAL_SIZE);
for (int i = 0; i < initProps.length; i += 2) {
keys.addElement(initProps[i]);
vals.addElement(initProps[i + 1]);
}
// The initial properties are no longer needed.
initProps = null;
|
public java.lang.String | getKeyAt(int index)Gets a property key by index. Used by the JadWriter as part of the
JAD Tool.
if (keys == null) {
return initProps[index * 2];
}
return (String)keys.elementAt(index);
|
public java.lang.String | getProperty(java.lang.String key)Searches for the property with the specified key in this property list.
The method returns null if the property is not found.
String rv = null;
if (key == null) {
throw new NullPointerException();
}
if (keys == null) {
for (int i = 0; i < initProps.length; i += 2) {
if (initProps[i].equals(key)) {
rv = initProps[i + 1];
break;
}
}
} else {
int idx = keys.indexOf(key);
if (idx > -1) {
rv = (String)vals.elementAt(idx);
}
}
return rv;
|
public java.lang.String | getPropertyIgnoreCase(java.lang.String key)This method is very similar to getproperty() except with a difference
that the keys are searched in case-insensitive manner. This is needed in
certain situations like HTTP header names.
String rv = null;
if (key == null) {
throw new NullPointerException();
}
if (keys == null) {
for (int i = 0; i < initProps.length; i += 2) {
if (initProps[i].equalsIgnoreCase(key)) {
rv = initProps[i + 1];
break;
}
}
} else {
int idx = -1;
for (int count = 0; count < keys.size(); count++) {
if (((String)keys.elementAt(count)).equalsIgnoreCase(key)) {
idx = count;
}
}
if (idx > -1) {
rv = (String)vals.elementAt(idx);
}
}
return rv;
|
public java.lang.String | getValueAt(int index)Gets a property value by index. Used by the JadWriter as part of the
JAD Tool.
if (keys == null) {
return initProps[(index * 2) + 1];
}
return (String)vals.elementAt(index);
|
public synchronized java.lang.String | removeProperty(java.lang.String key)Removes a property (key:value pair) from the property
list based on the key string.
int idx;
String rv = null;
if (keys == null) {
convertInitPropsToVectors();
}
idx = keys.indexOf(key);
if (idx > -1) {
rv = (String)vals.elementAt(idx);
keys.removeElementAt(idx);
vals.removeElementAt(idx);
}
return rv;
|
public synchronized java.lang.String | setProperty(java.lang.String key, java.lang.String value)Store a single key:value pair. Provided for parallelism with the
getProperty method. Enforces use of strings for
property keys and values. If a key already exists in storage,
the value corresponding to that key will be replaced and returned.
int idx;
String rv = null;
if (keys == null) {
convertInitPropsToVectors();
}
idx = keys.indexOf(key);
if (idx == -1) { // If I don't have this, add it and return null
keys.addElement(key);
vals.addElement(value);
} else { // Else replace it and return the old one.
rv = (String)vals.elementAt(idx);
vals.setElementAt(value, idx);
}
return rv;
|
public synchronized java.lang.String | setPropertyAt(int index, java.lang.String value)Replace the value of the property at the given index.
String rv;
if (keys == null) {
convertInitPropsToVectors();
}
rv = (String)vals.elementAt(index);
vals.setElementAt(value, index);
return rv;
|
public synchronized java.lang.String | setPropertyIgnoreCase(java.lang.String key, java.lang.String value)Store a single key:value pair.
This method is very similar to setproperty() except with a difference
that the keys are stored in case-insensitive manner. This is needed in
certain situations like HTTP header names.
int idx = -1;
String rv = null;
if (keys == null) {
convertInitPropsToVectors();
}
for (int count = 0; count < keys.size(); count++) {
if (((String)keys.elementAt(count)).equalsIgnoreCase(key)) {
idx = count;
}
}
if (idx == -1) { // If I don't have this, add it and return null
keys.addElement(key);
vals.addElement(value);
} else { // Else replace it and return the old one.
rv = (String)vals.elementAt(idx);
vals.setElementAt(value, idx);
/*
* Also replace the key at idx in case there is change in case
* for the key
*/
keys.setElementAt(key, idx);
}
return rv;
|
public int | size()Gets the number of properties.
if (keys == null) {
return initProps.length / 2;
}
return keys.size();
|