public interface MAssocList extends MData, java.lang.Cloneable, java.io.Serializable
MAssocList
object can be used in a similar fashion
to a map or a hash table. It holds key-value pairs. Values can be
any other MData
object such as MInstance
,
MSequence
, MAssocList
or a basic type encapsulated by a Java integer or string class.
An MAssocList
consists of ordered key/value (attribute/value)
pairs; the same key may be repeated multiple times. You can form nested trees
by making an MAssocList
the value of an MAssocList
attribute.
The interface supports accessing key-value pairs either by key and key index or by global position inside the association list.
MAssocList
behaves in a similar fashion to an MTree
,
but the major difference between these two classes is that
MAssocList
is part of the MData
class hierarchy and
therefore can also be used in conjunction with other metadata driven
objects. For example, an MAssocList
object may be used as
an attribute of an MInstance
or as a member of an MSequence
.
MAssocList
is particularly useful when a highly dynamic
data structure needs to be shipped and no class description can be
available or only partial class description is available.
You create an MAssocList
by calling the
MDataFactory.newAssocList()
method.
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.String key,
java.lang.Object value)
Map the specified key to the specified value in the association as an
additional value to any existing ones already in the association.
|
void |
clear()
Removes all mappings from this association.
|
boolean |
containsKey(java.lang.String key)
Determine whether this association contains a mapping for the
specified key.
|
boolean |
containsValue(java.lang.Object value)
Determine whether this association maps one or more keys to the specified value.
|
boolean |
equals(java.lang.Object obj)
Compare the specified object with this instance for equality.
|
java.lang.Object |
get(java.lang.String key)
Return the value to which the key is mapped in this association.
|
MNameValuePair |
getAt(int index)
Return the name and value of the specified element as an
MNameValuePair . |
MNameValuePair |
getAt(java.lang.String key,
int index)
Return the name and value of the specified element as an
MNameValuePair . |
MClassRegistry |
getClassRegistry()
Internal method - DON'T DOCUMENT
|
int |
getCount()
Return the number of name and value pairs in this association list.
|
int |
getCount(java.lang.String key)
Return the number of keys in this
MAssocList instance that match the
specified key. |
java.util.Vector |
getNullAttributesList() |
MTree |
getNullList() |
int |
hashCode()
Returns the hash code value for this instance.
|
boolean |
isEmpty()
Determine whether this association has any keys to which you can assign
a value by calling
append(String, Object) . |
boolean |
isNullData(java.lang.String attributeName)
Determine whether the value of the named attribute has been explicitly set to null.
|
java.lang.Object |
remove(java.lang.String key)
Remove the key (and its corresponding value) from this
association.
|
java.lang.Object |
removeAt(int index)
Remove an attribute (and its value) based on position from this
association.
|
java.lang.Object |
removeAt(java.lang.String key,
int index)
Remove an attribute (and its value) based on position.
|
void |
set(java.lang.String key,
java.lang.Object value)
Assign the specified value to the attribute specified by key
in this association.
|
void |
setAt(java.lang.String key,
java.lang.Object value,
int index)
Map the specified key to the specified value in the association as an
additional value to any existing ones already in the association.
|
void |
setClassRegistry(MClassRegistry clsReg)
Internal method - DON'T DOCUMENT
|
void |
setNullData(java.lang.String attributeName)
Set the value of the named attribute to null.
|
void |
setNullList(java.lang.String nullListString) |
int |
size()
Return the number of entries in this association and all the
contained or nested associations.
|
int |
size(java.lang.String key)
Returns the number of entries in all the attributes matching the
specified key, including all nested attributes of those attributes.
|
java.lang.String |
toString()
Returns a string representation of the Map.
|
java.lang.String |
toXML()
Returns XML representation of this
MAssocList . |
clone, getCategory, getClassDescription, getTrackingInfo, serialize, serialize, setTrackingInfo
void append(java.lang.String key, java.lang.Object value) throws MException
key
- The attribute you want to append to this association list. The key cannot be null.value
- Value of the attribute you want to append to this MAssocList
.MException
- if the key is null.void set(java.lang.String key, java.lang.Object value) throws MException
You can retrieve the value by calling the get(String)
method
with a key that is equal to the original key.
set
in interface MData
key
- Attribute for which you want to set the value.value
- Value to assign to this attribute.MException
- if the key is null.java.lang.Object get(java.lang.String key) throws MException
get
in interface MData
key
- Name of the attribute for which you want to find the mapping.MException
void setAt(java.lang.String key, java.lang.Object value, int index) throws MException
key
- Attribute to which you want to assign a value. The key cannot be null.value
- Value to assign.index
- Position at which you want to insert the value.MException
- if the key is null.MNameValuePair getAt(int index) throws MException
MNameValuePair
.
This method lets you specify the index, that is, the position in the list.
index
- The position of the key and value pair.MNameValuePair
.MException
MNameValuePair getAt(java.lang.String key, int index) throws MException
MNameValuePair
.
This method is useful if multiple values are mapped to one name; it returns the nth occurrence of that name.
key
- Name of attribute to search in this association list.index
- The position of the key and value pair.MNameValuePair
.MException
void clear()
java.lang.Object remove(java.lang.String key) throws MException
key
- The name of the attribute(s) to be removed.MException
clear()
,
removeAt(int)
java.lang.Object removeAt(int index) throws MException
index
- Occurrence of the attribute to remove from this association list..MException
java.lang.Object removeAt(java.lang.String key, int index) throws MException
The method returns the value to which the attribute had been mapped, or null if the key did not have a mapping.
key
- The attribute name.index
- Occurrence of the attribute to remove from this association list.MException
int getCount() throws MException
MException
int getCount(java.lang.String key) throws MException
MAssocList
instance that match the
specified key.key
- The key for matching.MException
int size() throws MException
MException
int size(java.lang.String key) throws MException
key
- The attribute for which you want to know the size.
This is especially useful if the value of the attribute is, in turn, an association list.MException
boolean isEmpty()
append(String, Object)
.true
if this MAssocList
maps no keys to
values. Otherwise, return false
.boolean containsKey(java.lang.String key)
key
- The key that are looking for in this instance.true
if this instance contains a mapping for the
specified key.containsValue(Object)
boolean containsValue(java.lang.Object value)
More formally, returns true
if and only if this map contains at
least one mapping to a value v such that
(value==null ?
v==null
: value.equals(v)
).
If this map is large, this method will require proportionally more time.
value
- Value that you are looking for in this association list instance.true
if this association maps one or more keys to the
specified value.containsKey(String)
boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- object to be compared for equality with this instance.true
if the given object is also an MAssocList
and the
two MAssocList
instances have the same mappings in the same order.int hashCode()
java.lang.String toString()
toString
in class java.lang.Object
void setClassRegistry(MClassRegistry clsReg)
MClassRegistry getClassRegistry()
boolean isNullData(java.lang.String attributeName) throws MException
attributeName
- Name of the attribute in this instance that you want to check.true
if the value of the named attribute has been explicitly set to null.
Return false
if no value has been explicitly set.MException
- if the named attribute does not exist in this instance.setNullData(String)
void setNullData(java.lang.String attributeName) throws MException
attributeName
- Name of the attribute in this instance that you want to set to null.MException
- If the named attribute is not defined for this instanceclear()
,
set(String, Object)
,
"A Note on NULL Values, in TIBCO Adapter SDK Concepts"java.lang.String toXML() throws MException
MAssocList
.MException
MTree getNullList() throws MException
MException
void setNullList(java.lang.String nullListString)
java.util.Vector getNullAttributesList()