public class MDefaultAssocList extends java.lang.Object implements MAssocList
In the simple case each key in a path to a nested value is concatenated together with '.' separators such as "a.b.c". The name "a.b.c" identifies the an entry called "a" at the first level. The value in this entry must be another MAssoc. The next step is to find the entry named "b" in this MAssoc. Finally the entry named "c" of the last MAssoc is the one identifed by the key "a.b.c".
Since there can be multiple entries with the same name in an MAssoc there needs to be some way to identify values other than the first occurance of the named entry. An index like notation is used. The key "a.b[2].c" is an example of such a key. It identifes the third occurance of "b" in "a" and then looks for the "c" entry in the third "b" entry's MAssoc value. If the index portion is not specified then any entry with that name may be matched. Generally this is always the [0] entry unless a broader seach is indicated by the method (such as getCount).
The notion of wild card key specification are also supported. A "*" element of a key indicates it matches any named entry.
In general two types of keys are supported: either a String or an MAssocKey. The MAssocKey is more optimized but more importantly it has methods which make forming and pulling information out of the key easier.
Constructor and Description |
---|
MDefaultAssocList(MClassRegistry clsReg) |
Modifier and Type | Method and Description |
---|---|
void |
append(MAssocKey key,
java.lang.Object value)
Maps the specified key to the specified value in the association as an
additional value to any existing ones already in the association.
|
void |
append(java.lang.String key,
java.lang.Object value)
Maps 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.
|
java.lang.Object |
clone()
Creates a copy of the association and all the nested
associations.
|
boolean |
containsKey(MAssocKey key)
Returns true if this association contains a mapping for the
specified key.
|
boolean |
containsKey(java.lang.String key)
Returns true if this association contains a mapping for the
specified key.
|
boolean |
containsValue(java.lang.Object value)
Returns true if this association maps one or more keys to the
specified value.
|
boolean |
equals(java.lang.Object obj)
Compares the specified object with this instance for
equality.
|
java.lang.Object |
get(MAssocKey key)
Returns the value to which the key is mapped in this association.
|
java.lang.Object |
get(java.lang.String key)
Returns the value to which the key is mapped in this association.
|
MNameValuePair |
getAt(int index)
Returns the key and value of the nth element in this association.
|
MNameValuePair |
getAt(java.lang.String key,
int index)
Returns the nth value to which the key is mapped in this
association.
|
int |
getCategory() |
MClassDescription |
getClassDescription()
Return the class description from which this data is created
|
MClassRegistry |
getClassRegistry()
Internal method - DON'T DOCUMENT
|
int |
getCount()
Returns the number of keys in this MDefaultAssocList instance at the first
level.
|
int |
getCount(MAssocKey key)
Returns the number of keys in this MDefaultAssocList instance that match the
specified key.
|
int |
getCount(java.lang.String key)
Returns the number of keys in this MDefaultAssocList instance that match the
specified key.
|
java.lang.Object |
getNth(MAssocKey key,
int index)
Returns the nth value to which the key is mapped in this
association.
|
java.util.Vector |
getNullAttributesList() |
MTree |
getNullList() |
MTrackingInfo |
getTrackingInfo()
Retrieve the tracking information from the
MData object. |
int |
hashCode()
Returns the hash code value for this instance.
|
void |
insert(MAssocKey key,
java.lang.Object value,
int index)
Maps the specified key to the specified value in the association as an
additional value to any existing ones already in the association.
|
boolean |
isEmpty()
Tests if this association has no keys to value in it.
|
boolean |
isNullData(java.lang.String attributeName)
Check to see if the attribute is null
|
void |
list()
Lists all the keys and values of the association in indented format
to System.out.
|
void |
list(java.io.PrintStream ps)
Lists all the keys and values of the association in indented format
to the ps stream.
|
void |
list(java.io.PrintStream ps,
java.lang.String indent)
Lists all the keys and values of the association in indented format
to the ps stream with an initial indentation of the indent argument.
|
void |
list(java.io.PrintWriter pw)
Lists all the keys and values of the association in indented format
to the pw writer.
|
void |
list(java.io.PrintWriter pw,
java.lang.String indent)
Lists all the keys and values of the association in indented format
to the pw writer with an initial indentation of the indent
argument.
|
void |
list(java.io.PrintWriter pw,
java.lang.String indent,
boolean applyToFirst)
Lists all the keys and values of the association in indented format
to the pw writer with an initial indentation of the indent
argument.
|
void |
list(java.lang.String indent)
Lists all the keys and values of the association in indented format
to System.out with an initial indentation of the indent argument.
|
void |
put(MAssocKey key,
java.lang.Object value)
Maps the specified key to the specified value in this association.
|
java.lang.Object |
remove(MAssocKey key)
Removes the key (and its corresponding value) from this
association.
|
java.lang.Object |
remove(java.lang.String key)
Removes 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.
|
MTree |
serialize()
Serialize this MData into an MTree
|
MTree |
serialize(int formatHint)
Serialize this MData into an MTree
|
MTree |
serialize(MDataSerializer serializer,
int formatHint)
Serialize with specific serialier this MAssocList into an MTree
|
void |
set(java.lang.String key,
java.lang.Object value)
Maps the specified key to the specified value in this association.
|
void |
setAt(java.lang.String key,
java.lang.Object value,
int index)
Maps 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) |
void |
setTrackingInfo(MTrackingInfo data)
Forward the tracking info to a new
MData object. |
int |
size()
Returns the number of entries in this association and all the
contained or nested associations.
|
int |
size(MAssocKey key)
Returns the number of values in all the matching attributes or
MDefaultAssocList instances, including all nested attributes.
|
int |
size(java.lang.String key)
Returns the number of values in all the matching attributes or
MDefaultAssocList instances, including all nested attributes.
|
java.lang.String |
toString()
Returns a string representation of the Map.
|
java.lang.String |
toXML()
Returns XML representation of this
MAssocList . |
public MDefaultAssocList(MClassRegistry clsReg)
public void append(MAssocKey key, java.lang.Object value) throws MException
key
- the keyvalue
- the valuejava.lang.NullPointerException
- if the key is null.MException
public void append(java.lang.String key, java.lang.Object value) throws MException
append
in interface MAssocList
key
- the keyvalue
- the valueMException
- if the key is null.public void clear()
clear
in interface MAssocList
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
public boolean containsKey(MAssocKey key)
key
- key whose presence in this instance is to be tested.public boolean containsKey(java.lang.String key)
containsKey
in interface MAssocList
key
- key whose presence in this instance is to be tested.MAssocList.containsValue(Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface MAssocList
value
- value whose presence in this instance is to be tested.MAssocList.containsKey(String)
public boolean equals(java.lang.Object obj)
equals
in interface MAssocList
equals
in class java.lang.Object
obj
- object to be compared for equality with this instance.public java.lang.Object get(MAssocKey key) throws MException
key
- a key in this associationMException
public java.lang.Object get(java.lang.String key) throws MException
get
in interface MAssocList
get
in interface MData
key
- a key in this associationMException
public MNameValuePair getAt(int index) throws MException
getAt
in interface MAssocList
index
- index of the key and value pair to returnMException
public MNameValuePair getAt(java.lang.String key, int index) throws MException
getAt
in interface MAssocList
key
- a key in this associationindex
- the value for n (as in nth)MException
public MClassDescription getClassDescription()
getClassDescription
in interface MData
public MClassRegistry getClassRegistry()
MAssocList
getClassRegistry
in interface MAssocList
public int getCount()
getCount
in interface MAssocList
public int getCount(MAssocKey key) throws MException
key
- the key for matchingMException
public int getCount(java.lang.String key) throws MException
getCount
in interface MAssocList
key
- the key for matchingMException
public java.lang.Object getNth(MAssocKey key, int index) throws MException
key
- a key in this associationindex
- the value for n (as in nth)MException
public int hashCode()
hashCode
in interface MAssocList
hashCode
in interface MData
hashCode
in class java.lang.Object
public void insert(MAssocKey key, java.lang.Object value, int index) throws MException
key
- the keyvalue
- the valuejava.lang.NullPointerException
- if the key is null.MException
public boolean isEmpty()
isEmpty
in interface MAssocList
public void list()
public void list(java.io.PrintStream ps)
ps
- PrintStream to list the association topublic void list(java.io.PrintStream ps, java.lang.String indent)
ps
- PrintStream to list the association toindent
- initial indentationpublic void list(java.io.PrintWriter pw)
pw
- PrintWriter to list the association topublic void list(java.io.PrintWriter pw, java.lang.String indent)
pw
- PrintWriter to list the association toindent
- initial indentationpublic void list(java.io.PrintWriter pw, java.lang.String indent, boolean applyToFirst)
pw
- PrintWriter to list the association toindent
- initial indentationapplyToFirst
- the applyToFirst flagpublic void list(java.lang.String indent)
indent
- initial indentationpublic void put(MAssocKey key, java.lang.Object value) throws MException
The value can be retrieved by calling the get() method with a key that is equal to the original key.
key
- the keyvalue
- the valuejava.lang.NullPointerException
- if the key is null.MException
public java.lang.Object remove(MAssocKey key) throws MException
key
- the key to be removedMException
public java.lang.Object remove(java.lang.String key) throws MException
remove
in interface MAssocList
key
- the key to be removedMException
MAssocList.clear()
,
MAssocList.removeAt(int)
public java.lang.Object removeAt(int index) throws MException
MAssocList
removeAt
in interface MAssocList
index
- Occurrence of the attribute to remove from this association list..MException
public java.lang.Object removeAt(java.lang.String key, int index) throws MException
MAssocList
The method returns the value to which the attribute had been mapped, or null if the key did not have a mapping.
removeAt
in interface MAssocList
key
- The attribute name.index
- Occurrence of the attribute to remove from this association list.MException
public MTree serialize(int formatHint) throws MException
serialize
in interface MData
formatHint
- Required parameter specifying the message format.
Valid message format values are
MMessageFormat.AERV
- for AERv message format
MMessageFormat.XMLJMS
- for JMS XML message format
MMessageFormat.XMLRV
- for RV XML message formatMException
- On any error serializing this instance into an MTree objectpublic MTree serialize() throws MException
serialize
in interface MData
MException
- On any error serializing this instance into an MTree objectpublic MTree serialize(MDataSerializer serializer, int formatHint) throws MException
MException
- On any error encounteredpublic void set(java.lang.String key, java.lang.Object value) throws MException
The value can be retrieved by calling the get() method with a key that is equal to the original key.
set
in interface MAssocList
set
in interface MData
key
- the keyvalue
- the valuejava.lang.NullPointerException
- if the key is null.MException
- if the key is null.public void setAt(java.lang.String key, java.lang.Object value, int index) throws MException
setAt
in interface MAssocList
key
- the keyvalue
- the valueindex
- Position at which you want to insert the value.MException
- if the key is null.public void setClassRegistry(MClassRegistry clsReg)
MAssocList
setClassRegistry
in interface MAssocList
public int size()
size
in interface MAssocList
public int size(MAssocKey key) throws MException
key
- the key for matchingMException
public int size(java.lang.String key) throws MException
size
in interface MAssocList
key
- the key for matchingMException
public java.lang.String toString()
toString
in interface MAssocList
toString
in class java.lang.Object
public boolean isNullData(java.lang.String attributeName) throws MException
isNullData
in interface MAssocList
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 is not defined for this instanceMAssocList.setNullData(String)
public void setNullData(java.lang.String attributeName) throws MException
setNullData
in interface MAssocList
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
instanceMAssocList.clear()
,
MAssocList.set(String, Object)
,
"A Note on NULL Values, in TIBCO Adapter SDK Concepts"public void setNullList(java.lang.String nullListString)
setNullList
in interface MAssocList
public MTree getNullList() throws MException
getNullList
in interface MAssocList
MException
public java.util.Vector getNullAttributesList()
getNullAttributesList
in interface MAssocList
public final int getCategory()
getCategory
in interface MData
public void setTrackingInfo(MTrackingInfo data)
MData
MData
object.setTrackingInfo
in interface MData
data
- The information to forward.MData.getTrackingInfo()
public MTrackingInfo getTrackingInfo()
MData
MData
object.
If there isnt any tracking data available, create a new tracking data with "source undefined" as tracking information.
getTrackingInfo
in interface MData
MData.setTrackingInfo(MTrackingInfo)
public java.lang.String toXML() throws MException
MAssocList
MAssocList
.toXML
in interface MAssocList
MException