public class NameValuePairs extends java.lang.Object implements AttributeList, ExprValueSupplier
This class provides methods for setting and getting values either by index or by name.
Constructor and Description |
---|
NameValuePairs()
Creates an empty attribute list.
|
NameValuePairs(int size)
Constructs a new attribute list with a specified initial capacity.
|
NameValuePairs(java.lang.String[] nameArr,
java.lang.Object[] valArr) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
java.lang.Object |
getAttribute(int index)
Gets the value of an attribute identified by its index.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets the value of an attribute identified by name.
|
int |
getAttributeCount()
Counts the attributes.
|
int |
getAttributeIndexOf(java.lang.String name)
Gets the index of a named attribute.
|
java.lang.String[] |
getAttributeNames()
Returns an array of attribute names in this list.
|
java.lang.Object[] |
getAttributeValues()
Returns an array of attribute values in this list.
|
java.lang.Object |
getExprVarVal(java.lang.String varName) |
boolean |
hasExprVarVal(java.lang.String varName) |
boolean |
removeAttribute(java.lang.String name) |
void |
setAttribute(int index,
java.lang.Object value)
Sets the value for the specified attribute.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value for the named attribute.
|
void |
setExprVarVal(java.lang.String varName,
java.lang.Object val) |
public NameValuePairs()
public NameValuePairs(int size)
size
- the initial cacpacity.public NameValuePairs(java.lang.String[] nameArr, java.lang.Object[] valArr)
public java.lang.Object getAttribute(int index)
getAttribute
in interface AttributeList
index
- the attribute's index.null
if
index
is out of range.public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface AttributeList
name
- the attribute's name.null
if
index
is out of range.public void setAttribute(int index, java.lang.Object value)
setAttribute
in interface AttributeList
index
- the attribute index.value
- the attribute's new value.public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface AttributeList
name
- the attribute name.value
- the attribute's new value.public int getAttributeCount()
getAttributeCount
in interface AttributeList
public int getAttributeIndexOf(java.lang.String name)
getAttributeIndexOf
in interface AttributeList
name
- the attribute's name.public java.lang.String[] getAttributeNames()
AttributeList
getAttributeNames
in interface AttributeList
public java.lang.Object[] getAttributeValues()
AttributeList
getAttributeValues
in interface AttributeList
public void clear()
public java.lang.Object getExprVarVal(java.lang.String varName)
getExprVarVal
in interface ExprValueSupplier
public void setExprVarVal(java.lang.String varName, java.lang.Object val)
setExprVarVal
in interface ExprValueSupplier
public boolean hasExprVarVal(java.lang.String varName)
public boolean removeAttribute(java.lang.String name)