public interface XmlDataCursor
However, if you do not want to retrofit, to support any existing code that uses the 9.10 version of com.wm.data.XMLData, alter Java imports to reference the 9.10 definition. Specifically, change:
import com.wm.data.XmlData ---> to ---> import com.wm.data.obsolete.XmlData
import com.wm.data.XmlDataCursor ---> to ---> import com.wm.data.obsolete.XmlDataCursor
Software AG maintains this version for compatibility purposes only. Software AG will not provide fixes for this version.
Summary of difference between the 9.10 version of the com.wm.data.XmlDataCursor class and the 9.12 and higher version of the com.wm.data.XmlDataCursor class:
XmlDataCursor defines the behavior for manipulating XmlData element content. There is only one implementation of this interface. The XmlData concrete class is used to obtain an XmlDataCursor on an IData object.
The XMlDataCursor allows a program to iterate over the element content of an XmlData-formatted IData document. The content of XmlData-formated IData is a collection of key/value pairs. The key has a very specialized format. The key is comprised of several components: a particle ID, a local name, and an optional namespace. There are four different types of keys: element tags, wildcard (any) tags, group tags, and substitution tags. On a historical note, the legacy form of IData encoding for XML only had element tags. The values also have specialized structure. Element tags have either IData or String values which represent either simple or complex content. Wildcard (any) tags has special any object contents which in turn contain the name and actual value. This indirect representation allows Flow Maps to manipulate wildcard content. Substitution tags also have a specialized structure. They contain a substitution object which is an IData containing the actual key/value pair. Group tags contain nested complex content that mirrors the model groups of schema. Groups always contain an IData (or IData[] for repeating values).
Retrieving and updating the content of XmlData content is very similar to that of the legacy approach, but rather than obtaining an IDataCursor, the XmlData class is used to obtain an XmlDataCursor on an IData object. The XmlDataCursor is used to navigate through the element content. Navigation using XnlDataCursor is much more structured and constrained than using the legacy IDataCursor.
There are three different ways of accessing the content of the XmlDataCursor: object, value, or content. The getObject() and setObject() methods directly access the content associated with the key. For example, when an any object is present, getObject() returns the any object. On the other hand. getValue() returns the value referenced by the any object. In a similar way, getKey() returns the actual key (which would be the *any tag), while getValueKey() returns the key stored on the any object. While getValue() returns the fully element content (which includes the attributes), getContent() returns only the content content portion of the item. This will always be either a String (from simple content) or an IData (for complex content).
Attributes are also accessed through the XMlDataCursor. However, unlike the legacy IData structure, XmlData stores attributes separately from the element content. The attributes are not accessible as "peers" of the elements. Instead, there are explicit methods to get and set attributes values for the element at the current cursor position.
XmlData
Modifier and Type | Method and Description |
---|---|
int |
count()
Returns the number of values stored at the current cursor position.
|
boolean |
delete(int... index)
Removes the current item (key and value) from the content.
|
void |
destroy()
Release any resources associated with the current cursor.
|
boolean |
first()
Positions the cursor at the first item.
|
boolean |
first(XmlDataContentTag key)
Position the cursor on the first occurrence of the specified tag and return true.
|
XmlDataAttributeTag[] |
getAttributeNames(int... index)
Returns a list of attribute names for the current element.
|
IData |
getAttributes(int... index)
Returns an IData list of attributes and values at the current cursor location.
|
java.lang.String |
getAttributeValue(XmlDataAttributeTag attribute,
int... index)
Returns the value of an attribute for the current item.
|
java.lang.Object |
getContent(int... index)
Returns the content associated with the current item.
|
XmlDataCursor |
getCopy() |
XmlDataContentTag |
getKey()
Returns the key of the content item.
|
java.lang.Object |
getObject(int... index)
Returns the value stored at the cursor.
|
java.lang.Object |
getValue(int... index)
Returns the value of the object at the current cursor position.
|
XmlDataElementTag |
getValueKey(int... index)
Returns the key associated with the current item.
|
boolean |
hasAttributes(int... index)
Determines if the current entry has attributes.
|
void |
home()
The cursor becomes unpositioned as if newly created.
|
void |
insertAfter(XmlDataContentTag tag,
java.lang.Object value)
A content item (a key and value pair) is inserted into the content after the current cursor position.
|
void |
insertBefore(XmlDataContentTag tag,
java.lang.Object value)
A content item (a key and value pair) is inserted into the content before the current cursor position.
|
void |
insertValueAfter(java.lang.Object value,
int index)
Inserts a repeating value for the current key in the array of recurring values after the specified index.
|
void |
insertValueBefore(java.lang.Object value,
int index)
Inserts a repeating value for the current key in the array of repeating values before the specified index.
|
boolean |
isAny()
Determines if the cursor is positioned on an element wildcard item
|
boolean |
isGroup()
Determines if the cursor is positioned on a Group item
|
boolean |
isHome()
Indicates whether the cursor is unpositioned.
|
boolean |
isRepeating()
Indicates if the current item is a repeating key.
|
boolean |
isSubstitution()
Determines if the cursor is positioned on a Substitution head item
|
boolean |
last()
Positions the cursor at the last item.
|
boolean |
last(XmlDataContentTag key)
Position the cursor on the last occurrence of the specified tag and return true.
|
boolean |
next()
Positions the cursor on the next content item.
|
boolean |
next(XmlDataContentTag key)
Position the cursor on the next occurrence of the specified tag and return true.
|
boolean |
previous()
Positions the cursor on the previous item.
|
boolean |
previous(XmlDataContentTag key)
Position the cursor on the previous occurrence of the specified tag and return true.
|
boolean |
removeAttribute(XmlDataAttributeTag attribute,
int... index)
Removes the specified attribute from the current element.
|
void |
setAttributes(IData attributes,
int... index) |
void |
setAttributeValue(XmlDataAttributeTag attribute,
java.lang.String value,
int... index)
Sets the value for the specified attribute.
|
void |
setContent(java.lang.Object data,
int... index)
Replace the value of the current element while preserving any original associated attributes.
|
void |
setKey(XmlDataContentTag tag)
Sets the key of the current content item.
|
void |
setObject(java.lang.Object object,
int... index)
Set the object stored at the current cursor position.
|
void |
setValue(java.lang.Object object,
int... index)
Sets the value stored at the current cursor.
|
void |
setValueKey(XmlDataContentTag key,
int... index)
Sets the key of the value of the current cursor.
|
int count()
boolean delete(int... index)
index
- - optional offset into the array if repeating content is presentXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesvoid destroy()
boolean first()
boolean first(XmlDataContentTag key)
key
- - the XmlDataContentTag to be searchedXmlDataAttributeTag[] getAttributeNames(int... index)
index
- - offset into the repeating content array (if repeating content is present)XmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentIData getAttributes(int... index)
index
- - the offset of the item if repeating values are presentjava.lang.String getAttributeValue(XmlDataAttributeTag attribute, int... index)
attribute
- - the key of the attribute XmlDataAttributeTag)index
- - offset into the list of repeating values (starting at 0)XmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentjava.lang.Object getContent(int... index)
For an element, content is one of:
index
- - the index of the repeating valueXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataCursor getCopy()
XmlDataContentTag getKey()
XmlDataException.UnpositionedCursor
- - when cursor is not positionedjava.lang.Object getObject(int... index)
index
- - the index of the repeating valueXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesjava.lang.Object getValue(int... index)
index
- - the offset into repeating contentXmlDataElementTag getValueKey(int... index)
index
- - the index of the repeating valueXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesboolean hasAttributes(int... index)
index
- - the index of the repeating valueXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesvoid home()
void insertAfter(XmlDataContentTag tag, java.lang.Object value)
tag
- - the key of the key/value pair to be inserted after the current cursor positionvalue
- - the value (must be String, String[], IData, IData[], or Object[])void insertBefore(XmlDataContentTag tag, java.lang.Object value)
tag
- - the key of the key/value pair to be inserted before the current cursor positionvalue
- - the value (must be String, String[], IData, IData[], or Object[])void insertValueAfter(java.lang.Object value, int index)
index
- The insert position after which the item is inserted)value
- the value inserted (must be String or IData)XmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.UnsupportedType
- - value is not a String or IDatavoid insertValueBefore(java.lang.Object value, int index)
index
- - the index position before which the value is insertedvalue
- - he value inserted (must be STring or IData)XmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.UnsupportedType
- - when value is not String or IDataboolean isAny()
XmlDataException.UnpositionedCursor
- - when cursor is not positionedboolean isGroup()
XmlDataException.UnpositionedCursor
- - when cursor is not positionedboolean isHome()
boolean isRepeating()
XmlDataException.UnpositionedCursor
- - when cursor is not positionedtboolean isSubstitution()
XmlDataException.UnpositionedCursor
- - when cursor is not positionedboolean last()
boolean last(XmlDataContentTag key)
key
- - the XmlDataContentTag to be searchedboolean next()
boolean next(XmlDataContentTag key)
key
- = the key to search forboolean previous()
boolean previous(XmlDataContentTag key)
key
- = the key to search forboolean removeAttribute(XmlDataAttributeTag attribute, int... index)
attribute
- - an XmlDataATtrubteTag naming the attributeindex
- - the offset if the element is a repeating valueXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentvoid setAttributes(IData attributes, int... index)
void setAttributeValue(XmlDataAttributeTag attribute, java.lang.String value, int... index)
attribute
- - an XmlDqtaAttributeTag naming the attributevalue
- - the value to set (must be a String)index
- - optional offset into array of repeating valuesXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentXmlDataException.UnsupportedType
- - value is not a Stringvoid setContent(java.lang.Object data, int... index)
data
- - the value that replaces the current contentindex
- - optional offset when repeating values are presentXmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesXmlDataException.IndexRequired
- - when an index is not specified and repeating values are presentvoid setKey(XmlDataContentTag tag)
tag
- is one of the XmlDataContentTags mentioned above.XmlDataException.UnpositionedCursor
- - when cursor is not positionedvoid setObject(java.lang.Object object, int... index)
It is always preferable to use of the XmlData methods to construct the value if it is not a String or String[]. Use createGroupValue() if the content does not contain attributes and the top-level group does not contain repeating values. Otherwise using createComplexValue().
When no index is specified, the specified value completely replaces the existing value and all existing attributes for the element are cleared. If an index is specified, the specified value in the array of repeating values is set and any associated attributes cleared. The array is enlarged if necessary. When an index is specified, the object must be scalar String or IData object. An index of -1 is equivalent to the index of the last repeating item. It is an error if the value is incompatible with the current key. For example, *substitution, *group, and *any tags only accept an IData as value. If tag and content are not compatible, the TagAndContentConflict exception is thrown.
object
- - the value to be replaced.index
- - the position in the list of repeating values to be set. When index is specified, the value may not be an array.XmlDataException.UnpositionedCursor
- - when cursor is not positionedXmlDataException.UnsupportedType
- - value is not a String, String[], IData[], IData[], or Object[]XmlDataException.TagAndContentConflict
- - the object is not appropriate for the current tag typeXmlDataException.IndexOutOfRange
- - when index exceeds number of repeating valuesvoid setValue(java.lang.Object object, int... index)
object
- - the IData or String object that ia assigned as the value of the current cursor position.index
- - the offset into the repeating values if the current item is an array.void setValueKey(XmlDataContentTag key, int... index)
key
- - the key assigned to the current valueindex
- - the offset into the repeating value array.