public class XmlDataCursorImpl extends java.lang.Object implements XmlDataCursor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INSTANCE |
static java.lang.String |
NAMESPACE |
Modifier and Type | Method and Description |
---|---|
XmlDataCursor |
copyCursor() |
int |
count()
Returns the number of items stored at the current cursor position.
|
IData |
data()
Returns the IData for which this cursor is defined.
|
boolean |
deleteItem(int... optionalIndex)
Removes a single item from the array of items stored at the current cursor position.
|
boolean |
deleteObject()
Removes the tag-object-pair (single value or array of repeating values) from the current position.
|
void |
destroy()
Release any resources associated with the current cursor.
|
boolean |
first()
Positions the cursor at the first tag-object-pair.
|
boolean |
first(XmlDataContentTag key)
Positions the cursor on the first tag-object-pair with the specified tag and returns true.
|
boolean |
firstPartial(XmlDataContentTag key)
Positions the cursor on the first tag-object-pair with a tag that partially matches the specified tag.
|
XmlDataContentTag |
getAnyTag(int... optionalIndex)
Returns a parsed-tag constructed from the *ncName and *namespace fields in the any-item.
|
XmlDataAttributeTag[] |
getAttributeNames(int... optionalIndex)
Returns a list of attribute-tags for a complex-value stored at the current cursor position.
|
IData |
getAttributes(int... optionalIndex)
Returns an IData list of attributes and values for the complex-value stored at the current cursor position.
|
java.lang.String |
getAttributeValue(XmlDataAttributeTag attribute,
int... optionalIndex)
Returns the value of an attribute for the complex-value at the current cursor position.
|
java.lang.Object |
getComplexValueContent(int... optionalIndex)
Returns the value paired with the *simple field or the solitary top-level group-tag.
|
java.lang.Object |
getContent(int... index)
Returns the content of the current value.
|
java.lang.String |
getInstanceProp(java.lang.String name,
int... optionalIndex)
Retrieves the value of an instance (xsi) attribute specified for the current value.
|
java.lang.Object |
getItem(int... optionalIndex)
Returns an item from the current-object.
|
java.lang.String |
getNamespaceDecl(java.lang.String prefix,
int... optionalIndex)
Returns the the namespace URI associated with the specified prefix.
|
IData |
getNamespaceDecls(int... optionalIndex)
Gets all of the namespace-prefix associations for the current value.
|
java.lang.Object |
getObject()
Returns the current-object, the object stored at the current-position.
|
XmlDataContentTag |
getTag()
Returns the current-tag as a parsed-tag.
|
java.lang.Object |
getValue(int... optionalIndex)
Returns a value from the current-object.
|
XmlDataCursor |
getValueCursor(int... optionalIndex)
Returns an XmlDataCursor positioned on the first child of the specified value in the current-object.
|
XmlDataContentTag |
getValueTag(int... optionalIndex)
|
boolean |
hasAttributes(int... index)
Determines if the value at the specified index has attributes.
|
void |
home()
The cursor becomes unpositioned as if newly created.
|
void |
insertItemAfter(java.lang.Object value,
int index)
Inserts an item after the specified index into the array of repeating values at the current-position.
|
void |
insertItemBefore(java.lang.Object value,
int index)
Inserts an item before the specified index into the array of repeating values at the current-position.
|
void |
insertObjectAfter(XmlDataContentTag key,
java.lang.Object value)
Inserts a tag-object-pair after the current-position.
|
void |
insertObjectBefore(XmlDataContentTag key,
java.lang.Object value)
Inserts a tag-object-pair before the current-position.
|
void |
insertValueAfter(XmlDataContentTag tag,
java.lang.Object value,
int index)
Inserts a value into an array of repeating values at the current-position, after the specified index.
|
void |
insertValueBefore(XmlDataContentTag tag,
java.lang.Object value,
int index)
Inserts a value into an array of repeating values at the current-position, before the specified index.
|
boolean |
isAny()
Determines if the current-tag is an any-tag.
|
boolean |
isComplexValue(int... index)
Determines if the value at the current-position is an IData with a single group tag, an *attribute tga, or a *simple tag.
|
boolean |
isEmpty(int... index)
Determines if the value at the current-position is empty (or non-existent complex content for complex-values).
|
boolean |
isGroup()
Determines if the current-tag is a group-tag.
|
boolean |
isGroupValue(int... index)
Determines if the value at the current-position is a group-value.
|
boolean |
isHome()
Indicates whether the cursor is unpositioned.
|
boolean |
isRecast()
Indicates if automatic recast is in effect.
|
boolean |
isRepeating()
Determines if the current-object is a repeating value.
|
boolean |
isSimpleValue(int... index)
Determines if the value at the current-position is a simple value.
|
boolean |
isSubstitution()
Determines if the current-tag is a substitution-tag
|
boolean |
last()
Positions the cursor at the last tag-object-pair.
|
boolean |
last(XmlDataContentTag key)
Positions the cursor on the last occurrence of the last tag-object-pairg with the specified tag and return true.
|
boolean |
lastPartial(XmlDataContentTag key)
Positiosn the cursor on the last tag-object-pair with a tag that partially matches the specified tag.
|
XmlDataCursor |
newCursor(IData data)
Creates a new XmlDataCuror instances from an existing cursor factory.
|
boolean |
next()
Positions the cursor on the next tag-object-pair.
|
boolean |
next(XmlDataContentTag key)
Positiona the cursor on the next tag-object-pair that has the specified tag and returns true.
|
boolean |
nextPartial(XmlDataContentTag key)
Positions the cursor on the next tag-object-pair with a tag that partially matches the specified tag.
|
boolean |
previous()
Positions the cursor on the previous tag-object-pair.
|
boolean |
previous(XmlDataContentTag key)
Positions the cursor on the previous tag-object-pair with the specified tag and return true.
|
boolean |
previousPartial(XmlDataContentTag key)
Positions the cursor on the previous tag-object-pair with a tag that partially matches the specified tag.
|
void |
recast(boolean mode)
Indicates whether existing String[] or IData[] arrays for repeating values should be automatically recreated as an Object[] when the inserted or set value type doesn't match
the type of the repeating item array that is already present.
|
boolean |
removeAttribute(XmlDataAttributeTag attribute,
int... optionalIndex)
Removes the specified attribute from an item value stored at the current cursor position.
|
void |
setAnyTag(XmlDataContentTag tag,
int... index)
Sets the *ncName and *namespace fields of an any-item.
|
void |
setAttributes(IData attributes,
int... index)
Sets the attribute-set for the current element
|
void |
setAttributeValue(XmlDataAttributeTag attribute,
java.lang.String value,
int... optionalIndex)
Sets the value for the specified attribute.
|
void |
setComplexValueContent(java.lang.Object content,
int... index)
Replaces the content of a complex-value at the current-position
while preserving any original associated attributes.
|
void |
setContent(java.lang.Object content,
int... optionalIndex)
Replaces the content of the value at the current-position.
|
void |
setInstanceProp(java.lang.String name,
java.lang.String value,
int... index)
Sets an XML instance property (xsi attribute) on the current item.
|
void |
setItem(java.lang.Object value,
int... optionalIndex)
Stores a value or an indirect-item at the current cursor position.
|
void |
setNamespaceDecl(java.lang.String prefix,
java.lang.String uri,
int... index)
Sets a namespace declaration for the current item.
|
void |
setNamespaceDecls(IData nsDecls,
int... optionalIndex)
Sets the namespace declarations for the current item.
|
void |
setObject(java.lang.Object object)
Sets the object stored at the current cursor position ( a value or array of repeating values).
|
void |
setTag(XmlDataContentTag tag)
Sets the tag of the current tag-object pair.
|
void |
setValue(java.lang.Object value,
int... optionalIndex)
Sets the value at the current cursor position (and index if repeating values are present).
|
void |
setValueTag(XmlDataContentTag key,
int... index)
Sets the tag of the value stored at the current cursor.
|
java.lang.String |
toString() |
public static final java.lang.String INSTANCE
public static final java.lang.String NAMESPACE
public int count()
XmlDataCursor
count
in interface XmlDataCursor
public IData data()
XmlDataCursor
data
in interface XmlDataCursor
public boolean deleteItem(int... optionalIndex)
XmlDataCursor
deleteItem
in interface XmlDataCursor
optionalIndex
- optional offset (starting at zero) into the array if repeating values presentpublic boolean deleteObject()
XmlDataCursor
deleteObject
in interface XmlDataCursor
public void destroy()
XmlDataCursor
destroy
in interface XmlDataCursor
public boolean first()
XmlDataCursor
first
in interface XmlDataCursor
public boolean first(XmlDataContentTag key)
XmlDataCursor
first
in interface XmlDataCursor
key
- the searched content-tagpublic boolean firstPartial(XmlDataContentTag key)
XmlDataCursor
firstPartial
in interface XmlDataCursor
key
- the searched content-tagpublic java.lang.Object getContent(int... index)
XmlDataCursor
XmlDataCursor.getComplexValueContent(int...)
is returned. If the complex-value has no content, null is returned; but if the complex-value
can be interpreted as an empty group-value, the empty group is returned (rather than null). If the content is a repeating group, an IData[] is returned.getContent
in interface XmlDataCursor
index
- offset into repeating valuespublic java.lang.Object getItem(int... optionalIndex)
XmlDataCursor
getItem
in interface XmlDataCursor
optionalIndex
- offset into the repeating values array (if repeating values are present)public XmlDataContentTag getAnyTag(int... optionalIndex)
XmlDataCursor
XmlDataElementTag
or XmlDataSubstitutionTag
.
This is a very specialized method. More typically, XmlDataCursor.getValueTag(int...)
is used to return the tag associated with the item. However, if the any-item
references a substitution group, the getValueTag() method returns the element tag present in the substitution group. This specialized method returns the
tag created from fields in the any-item which will be either be an element-tag or a substitution-tag.
This method is used only when it is necessary to distinguish between substitution tags and element tags in a any-item document.
Normally, XmlDataCursor.getValueTag(int...)
will be sufficient, and more general.getAnyTag
in interface XmlDataCursor
optionalIndex
- offset into the repeating item array (if repeating values are present)public XmlDataAttributeTag[] getAttributeNames(int... optionalIndex)
XmlDataCursor
XmlDataCursor.getValue(int...)
was invoked, and then attribute-tags extracted from the result.getAttributeNames
in interface XmlDataCursor
optionalIndex
- offset into the repeating value array (if repeating values are present)public IData getAttributes(int... optionalIndex)
XmlDataCursor
XmlDataCursor.getValue(int...)
was invoked, and then attribute-set
is retrieved from the value.getAttributes
in interface XmlDataCursor
optionalIndex
- the offset of the item of repeating values are presentpublic java.lang.String getAttributeValue(XmlDataAttributeTag attribute, int... optionalIndex)
XmlDataCursor
getAttributeValue
in interface XmlDataCursor
attribute
- the tag of the attribute XmlDataAttributeTag)optionalIndex
- offset into the list of repeating values (starting at 0)public java.lang.Object getComplexValueContent(int... optionalIndex)
XmlDataCursor
getComplexValueContent
in interface XmlDataCursor
optionalIndex
- the index of the repeating value that is a complex-valuepublic XmlDataCursor copyCursor()
copyCursor
in interface XmlDataCursor
public XmlDataCursor newCursor(IData data)
XmlDataCursor
newCursor
in interface XmlDataCursor
data
- an existing IData who's cursor factory is used to create a new XmlDataCursor instance.public java.lang.String getInstanceProp(java.lang.String name, int... optionalIndex)
XmlDataCursor
getInstanceProp
in interface XmlDataCursor
name
- the name of the xsi property (e.g. nil, type)optionalIndex
- offset into the repeating valuespublic java.lang.String getNamespaceDecl(java.lang.String prefix, int... optionalIndex)
XmlDataCursor
getNamespaceDecl
in interface XmlDataCursor
prefix
- the prefixoptionalIndex
- the namespace URI associated with the prefixpublic IData getNamespaceDecls(int... optionalIndex)
XmlDataCursor
getNamespaceDecls
in interface XmlDataCursor
optionalIndex
- the index of the repeating value for which prefixes are returnedpublic java.lang.Object getObject()
XmlDataCursor
getObject
in interface XmlDataCursor
public XmlDataContentTag getTag()
XmlDataCursor
XmlDataElementTag
, an XmlDataAnyTag
, an XmlDataGroupTag
, or an
XmlDataSubstitutionTag
. An exception is thrown if the cursor is not positioned.getTag
in interface XmlDataCursor
public java.lang.Object getValue(int... optionalIndex)
XmlDataCursor
getValue
in interface XmlDataCursor
optionalIndex
- the offset into repeating valuesXmlData.getAnyItemValueTag(IData)
,
XmlData.getSubstitutionItemValueTag(IData)
public XmlDataCursor getValueCursor(int... optionalIndex)
XmlDataCursor
getValueCursor
in interface XmlDataCursor
optionalIndex
- the index of the repeating valuepublic XmlDataContentTag getValueTag(int... optionalIndex)
XmlDataCursor
XmlDataElementTag
or XmlDataGroupTag
).
If the current-tag is an element-tag or a group-tag,
the current-tag is simply returned. The behavior is the same as that of XmlDataCursor.getTag()
.
If the current-tag is an any-tag or a substitution-tag,
an XmlDataElementTag is constructed from the associated indirect-item.getValueTag
in interface XmlDataCursor
optionalIndex
- the index of the repeating valueXmlData.getAnyItemValueTag(IData)
,
XmlData.getSubstitutionItemValueTag(IData)
public boolean hasAttributes(int... index)
XmlDataCursor
hasAttributes
in interface XmlDataCursor
index
- the index offset into repeating valuespublic void home()
XmlDataCursor
home
in interface XmlDataCursor
public void insertItemAfter(java.lang.Object value, int index)
XmlDataCursor
XmlData.createSubstitutionItem(XmlDataElementTag, Object)
or XmlData.createAnyItem(XmlDataContentTag, Object)
.
If the current-object is a scalar, it is promoted to an array prior to insertion of the new item. If the cursor has recast set to true, the new array is an Object[].insertItemAfter
in interface XmlDataCursor
value
- the scalar value inserted (must be simple-value, group-value, complex-value, or indirect-item)index
- The insert position after which the value is insertedpublic void insertItemBefore(java.lang.Object value, int index)
XmlDataCursor
XmlData.createSubstitutionItem(XmlDataElementTag, Object)
or XmlData.createAnyItem(XmlDataContentTag, Object)
.
If the current-object is a scalar, it is promoted to an array prior to insertion of the new item. If the cursor has recast set to true, the new array is an Object[].insertItemBefore
in interface XmlDataCursor
value
- the scalar value inserted (must be simple-value, group-value, complex-value, or indirect-item)index
- the index position before which the value is insertedpublic void insertObjectAfter(XmlDataContentTag key, java.lang.Object value)
XmlDataCursor
insertObjectAfter
in interface XmlDataCursor
key
- the tag of the tag/object pair to be inserted before the current cursor positionvalue
- the item or array of repeating values that is inserted (must be String, String[], IData, IData[], or Object[])public void insertObjectBefore(XmlDataContentTag key, java.lang.Object value)
XmlDataCursor
insertObjectBefore
in interface XmlDataCursor
key
- the tag of the tag/object pair to be inserted before the current cursor positionvalue
- the item or array of repeating values that is inserted (must be String, String[], IData, IData[], or Object[])public void insertValueAfter(XmlDataContentTag tag, java.lang.Object value, int index)
XmlDataCursor
insertValueAfter
in interface XmlDataCursor
tag
- the name of the repeating value for indirect-items (may be null if current tag is an element and group)value
- the value to insert (if the current tag is an any tag and the content tag is a substitution tag, value must be a substitution value).index
- the index of the repeating itempublic void insertValueBefore(XmlDataContentTag tag, java.lang.Object value, int index)
XmlDataCursor
insertValueBefore
in interface XmlDataCursor
tag
- the tag of the value for indirect-items (may be null if current tag is an element and group tag)value
- the value to insert (if the current tag is an any tag and the content tag is a substitution tag, value must be a substitution value).index
- the index of the repeating itempublic boolean isAny()
XmlDataCursor
isAny
in interface XmlDataCursor
public boolean isComplexValue(int... index)
XmlDataCursor
isComplexValue
in interface XmlDataCursor
index
- offset into repeating values.public boolean isEmpty(int... index)
XmlDataCursor
isEmpty
in interface XmlDataCursor
index
- offset into repeating valuespublic boolean isGroup()
XmlDataCursor
isGroup
in interface XmlDataCursor
XmlDataContentTag.isGroup()
public boolean isGroupValue(int... index)
XmlDataCursor
isGroupValue
in interface XmlDataCursor
index
- the offset into the repeating values arrayXmlData.isGroupValue(Object)
public boolean isHome()
XmlDataCursor
isHome
in interface XmlDataCursor
public boolean isRecast()
XmlDataCursor
isRecast
in interface XmlDataCursor
public boolean isRepeating()
XmlDataCursor
isRepeating
in interface XmlDataCursor
public boolean isSimpleValue(int... index)
XmlDataCursor
isSimpleValue
in interface XmlDataCursor
index
- the offset into the repeating values arraypublic boolean isSubstitution()
XmlDataCursor
isSubstitution
in interface XmlDataCursor
public boolean last()
XmlDataCursor
last
in interface XmlDataCursor
public boolean last(XmlDataContentTag key)
XmlDataCursor
last
in interface XmlDataCursor
key
- the searched content-tagpublic boolean lastPartial(XmlDataContentTag key)
XmlDataCursor
lastPartial
in interface XmlDataCursor
key
- the XmlDataContentTag to be searchedpublic boolean next()
XmlDataCursor
next
in interface XmlDataCursor
public boolean next(XmlDataContentTag key)
XmlDataCursor
next
in interface XmlDataCursor
key
- the searched content-tagpublic boolean nextPartial(XmlDataContentTag key)
XmlDataCursor
nextPartial
in interface XmlDataCursor
key
- the searched content-tagpublic boolean previous()
XmlDataCursor
previous
in interface XmlDataCursor
public boolean previous(XmlDataContentTag key)
XmlDataCursor
previous
in interface XmlDataCursor
key
- the searched content-tagpublic boolean previousPartial(XmlDataContentTag key)
XmlDataCursor
previousPartial
in interface XmlDataCursor
key
- the searched content-tagpublic void recast(boolean mode)
XmlDataCursor
recast
in interface XmlDataCursor
mode
- true causes automatic recast; default is falsepublic boolean removeAttribute(XmlDataAttributeTag attribute, int... optionalIndex)
XmlDataCursor
removeAttribute
in interface XmlDataCursor
attribute
- an XmlDataAttributeTag naming the attributeoptionalIndex
- the offset if the element is a repeating valuepublic void setAnyTag(XmlDataContentTag tag, int... index)
XmlDataCursor
XmlDataCursor.setValueTag(XmlDataContentTag, int...)
is used.
This method sets the any-item tag directly even if the value of the any-item is a substitution-item.
This method is typically used in conjunction with XmlDataCursor.getAnyTag(int...)
setAnyTag
in interface XmlDataCursor
tag
- the tag used to set ncName and namespace in the any-item.index
- offset into list of repeating valuespublic void setAttributes(IData attributes, int... index)
XmlDataCursor
setAttributes
in interface XmlDataCursor
attributes
- IData list of attributesindex
- position in repeating valuepublic void setAttributeValue(XmlDataAttributeTag attribute, java.lang.String value, int... optionalIndex)
XmlDataCursor
setAttributeValue
in interface XmlDataCursor
attribute
- an XmlDataAttributeTag naming the attributevalue
- the value to set (must be a String)optionalIndex
- optional offset into array of repeating valuespublic void setComplexValueContent(java.lang.Object content, int... index)
XmlDataCursor
setComplexValueContent
in interface XmlDataCursor
content
- the value that replaces the current contentindex
- optional offset when repeating values are present; a second index is required when repeating content is presentpublic void setContent(java.lang.Object content, int... optionalIndex)
XmlDataCursor
XmlDataCursor.setValue(Object, int...)
.
When the accessed value is complex, this method behaves like XmlDataCursor.setComplexValueContent(Object, int...)
.setContent
in interface XmlDataCursor
content
- the content of the current valueoptionalIndex
- the offset into a list of repeating valuespublic void setInstanceProp(java.lang.String name, java.lang.String value, int... index)
XmlDataCursor
setInstanceProp
in interface XmlDataCursor
name
- the name of the property(e.g. 'nil')value
- the value of the property (e.g. 'true')index
- the offset index into repeating valuespublic void setItem(java.lang.Object value, int... optionalIndex)
XmlDataCursor
It is always preferable to use one of the XmlData
methods to construct the value if it is not a String or String[]. For example, use
XmlData.createGroupValue(Object...)
if the content does not contain attributes and the top-level group does not contain repeating values. Otherwise
use XmlData.createComplexValue()
. When creating an indirect-item, use a methods such as XmlData.createAnyItem(XmlDataContentTag, Object)
to create an any-item or a method such as XmlData.createSubstitutionItem(XmlDataElementTag, Object)
to create
a substitution-item.
If an index is specified, the specified value in the array of repeating values is set and any associated attributes cleared. When no 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-tag. For example, substitution-tags, group-tags, and any-tags only accept an IData as value. If tag and content are not compatible, the TagAndContentConflict exception is thrown.
setItem
in interface XmlDataCursor
value
- the value to be replaced.optionalIndex
- the position in the list of repeating values to be set. When index is specified, the value may not be an array.public void setNamespaceDecl(java.lang.String prefix, java.lang.String uri, int... index)
XmlDataCursor
setNamespaceDecl
in interface XmlDataCursor
prefix
- the prefixuri
- the namespace URI.index
- the offset index into repeating valuespublic void setNamespaceDecls(IData nsDecls, int... optionalIndex)
XmlDataCursor
setNamespaceDecls
in interface XmlDataCursor
nsDecls
- IData list of prefix/namespace pairsoptionalIndex
- the index of the repeating itempublic void setObject(java.lang.Object object)
XmlDataCursor
setObject
in interface XmlDataCursor
object
- the offset to be stored at the current element.public void setTag(XmlDataContentTag tag)
XmlDataCursor
setTag
in interface XmlDataCursor
tag
- is one of the XmlDataContentTags mentioned above.public void setValue(java.lang.Object value, int... optionalIndex)
XmlDataCursor
setValue
in interface XmlDataCursor
value
- the IData or String object that ia assigned as the value of the current cursor position.optionalIndex
- the offset into the repeating values if the current item is an array.public void setValueTag(XmlDataContentTag key, int... index)
XmlDataCursor
XmlDataCursor.setTag(XmlDataContentTag)
. However, if the current value is an indirect-item,
the tag is stored in the indirect-item. If the indirect-item is an any-item, the tag is decomposed and stored
in the *ncName and *namespace fields of the any-item.
The current tag remains unchanged. If the current tag is a substitution-tag, the value tag is stored as the tag of the first and only child in
the substitution-item.
The index parameter only has meaning for substitution and any objects (names of repeated elements and groups are identical for all entries).setValueTag
in interface XmlDataCursor
key
- the tag assigned to the current valueindex
- the offset into the repeating value array.public java.lang.String toString()
toString
in class java.lang.Object