D - document type parameterpublic abstract class ElementLocator<D> extends Object
| Modifier and Type | Method and Description |
|---|---|
String |
attribute(String namespaceURI,
String localName)
Finds an attribute and returns its value.
|
ElementLocator<D> |
attribute(String namespaceURI,
String localName,
String value)
Sets or removes attribute's value.
|
ElementLocator<D> |
child(String localName)
Adds a child element and locate it.
|
ElementLocator<D> |
child(String localName,
int index)
Locates child element which has given
localName in no
name space at index. |
ElementLocator<D> |
child(String namespaceURI,
String localName)
Adds a child element and locate it.
|
ElementLocator<D> |
child(String namespaceURI,
String localName,
int index)
Locate a child element which has given
localName in given
namespaceURI at index. |
int |
count(String localName)
Returns the number of child elements which each has given
localName in no name space. |
int |
count(String namespaceURI,
String localName)
Returns the number of child elements which each has given
localName in specified namespaceURI. |
ElementLocator<D> |
parent()
Locates to the parent element.
|
ElementLocator<D> |
remove()
Removes currently located element and locate parent.
|
ElementLocator<D> |
root()
Locate to the root element.
|
String |
text()
Returns text value of currently located element.
|
ElementLocator<D> |
text(String text)
Sets the text value of currently located element.
|
abstract D |
toDocument(D document)
Prints contents to given
document. |
String |
toJSON()
Returns JSON representation of the contents.
|
public final int count(String localName)
localName in no name space.localName - local namepublic final int count(String namespaceURI, String localName)
localName in specified namespaceURI. En empty
string("") must be used for no(null) name space.namespaceURI - The name space URI.localName - The local name.#getCount(String)public final ElementLocator<D> root()
public final ElementLocator<D> parent()
IllegalStateException will
be thrown if there is no parent to locate (on the root).public final ElementLocator<D> child(String localName, int index)
localName in no
name space at index. An
IndexOutOfBoundsException will be thrown if there is no
child at specified index.localName - element's local nameindex - child element indexchild(java.lang.String, java.lang.String, int)public final ElementLocator<D> child(String namespaceURI, String localName, int index)
localName in given
namespaceURI at index. An
IndexOutOfBoundsException will be thrown if there is no
child at specified index.namespaceURI - element's name space URIlocalName - element's local nameindex - target index to locatechild(String, int)public final ElementLocator<D> child(String localName)
localName in no name space.localName - new child element's local name.public final ElementLocator<D> child(String namespaceURI, String localName)
localName in given namespaceURI.namespaceURI - child element's name space URIlocalName - child element's local namepublic final String text()
public final ElementLocator<D> text(String text)
text - new text valuepublic final String attribute(String namespaceURI, String localName)
namespaceURI - attribute's name space URIlocalName - attribute's local namepublic final ElementLocator<D> attribute(String namespaceURI, String localName, String value)
value is null mapped
attribute will be removed.namespaceURI - attribute's name space URIlocalName - attribute's local namevalue - attribute's value; null for removing attributepublic abstract D toDocument(D document)
document.document - an empty documentdocumentpublic final ElementLocator<D> remove()
IllegalStateException will be thrown if this locate is
currently locating the root element.public final String toJSON()
Copyright © 2010-2011. All Rights Reserved.