|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface OMElement
A particular kind of node that represents an element infoset information item.
An element has a collection of children, attributes, and namespaces.
In contrast with DOM, this interface exposes namespaces separately from the attributes.
Field Summary |
---|
Fields inherited from interface org.apache.axiom.om.OMNode |
---|
CDATA_SECTION_NODE, COMMENT_NODE, DTD_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, PI_NODE, SPACE_NODE, TEXT_NODE |
Method Summary | |
---|---|
OMAttribute |
addAttribute(OMAttribute attr)
Adds an attribute to this element. |
OMAttribute |
addAttribute(java.lang.String attributeName,
java.lang.String value,
OMNamespace ns)
Adds an attribute to the current element. |
OMElement |
cloneOMElement()
Clones this element. |
OMNamespace |
declareDefaultNamespace(java.lang.String uri)
This will declare a default namespace for this element explicitly |
OMNamespace |
declareNamespace(OMNamespace namespace)
Declares a namespace with the element as its scope. |
OMNamespace |
declareNamespace(java.lang.String uri,
java.lang.String prefix)
Creates a namespace in the current element scope. |
OMNamespace |
findNamespace(java.lang.String uri,
java.lang.String prefix)
Finds a namespace with the given uri and prefix, in the scope of the hierarchy. |
OMNamespace |
findNamespaceURI(java.lang.String prefix)
Checks for a namespace in the context of this element with the given prefix and returns the relevant namespace object, if available. |
java.util.Iterator |
getAllAttributes()
Returns a list of OMAttributes. |
java.util.Iterator |
getAllDeclaredNamespaces()
Returns an iterator for all of the namespaces declared on this element. |
OMAttribute |
getAttribute(javax.xml.namespace.QName qname)
Returns a named attribute if present. |
java.lang.String |
getAttributeValue(javax.xml.namespace.QName qname)
Returns a named attribute's value, if present. |
OMXMLParserWrapper |
getBuilder()
Returns the builder object. |
java.util.Iterator |
getChildElements()
Returns a filtered list of children - just the elements. |
OMNamespace |
getDefaultNamespace()
This will retrieve the default namespace of this element, if available. |
OMElement |
getFirstElement()
Returns the first child element of the element. |
int |
getLineNumber()
|
java.lang.String |
getLocalName()
Returns the local name of the element. |
OMNamespace |
getNamespace()
|
javax.xml.namespace.QName |
getQName()
Gets the QName of this node. |
java.lang.String |
getText()
Returns the non-empty text children as a string. |
javax.xml.namespace.QName |
getTextAsQName()
OMText can contain its information as a QName as well. |
javax.xml.stream.XMLStreamReader |
getXMLStreamReader()
Returns the pull parser that will generate the pull events relevant to THIS element. |
javax.xml.stream.XMLStreamReader |
getXMLStreamReaderWithoutCaching()
Returns the pull parser that will generate the pull events relevant to THIS element. |
void |
removeAttribute(OMAttribute attr)
Method removeAttribute |
javax.xml.namespace.QName |
resolveQName(java.lang.String qname)
Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context. |
void |
setBuilder(OMXMLParserWrapper wrapper)
Method setBuilder. |
void |
setFirstChild(OMNode node)
Deprecated. This method should not be called, un-intentionally. When some one randomly set the first child, all the links handling will not happen inside this method. So we have moved this method to the less visible interface, OMContainerEx. |
void |
setLineNumber(int lineNumber)
|
void |
setLocalName(java.lang.String localName)
Method setLocalName |
void |
setNamespace(OMNamespace namespace)
Sets the Namespace. |
void |
setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
This will not search the namespace in the scope nor will declare in the current element, as in setNamespace(OMNamespace). |
void |
setText(javax.xml.namespace.QName text)
|
void |
setText(java.lang.String text)
|
java.lang.String |
toString()
This is a convenience method only. |
java.lang.String |
toStringWithConsume()
This is a convenience method only. |
Methods inherited from interface org.apache.axiom.om.OMNode |
---|
build, buildWithAttachments, close, detach, discard, getNextOMSibling, getOMFactory, getParent, getPreviousOMSibling, getType, insertSiblingAfter, insertSiblingBefore, isComplete, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume |
Methods inherited from interface org.apache.axiom.om.OMContainer |
---|
addChild, buildNext, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getFirstChildWithName, getFirstOMChild, isComplete |
Method Detail |
---|
java.util.Iterator getChildElements()
OMContainer.getChildren()
,
OMContainer.getChildrenWithName(javax.xml.namespace.QName)
OMNamespace declareNamespace(java.lang.String uri, java.lang.String prefix)
uri
- The namespace to declare in the current scope. The caller is expected to
ensure that the URI is a valid namespace name.prefix
- The prefix to associate with the given namespace. The caller is expected to
ensure that this is a valid XML prefix. If "" is given, first this will check
for an existing namespace with the same uri. If not found, a prefix will be
auto-generated.
declareNamespace(OMNamespace)
,
findNamespace(String, String)
,
getAllDeclaredNamespaces()
OMNamespace declareDefaultNamespace(java.lang.String uri)
uri
- OMNamespace getDefaultNamespace()
OMNamespace declareNamespace(OMNamespace namespace)
namespace
- The namespace to declare.
declareNamespace(String, String)
,
findNamespace(String, String)
,
getAllDeclaredNamespaces()
OMNamespace findNamespace(java.lang.String uri, java.lang.String prefix)
Searches from the current element and goes up the hiararchy until a match is found. If no match is found, returns null.
Either prefix or uri should be null. Results are undefined if both are specified.
uri
- The namespace to look for. If this is specified, prefix should be
null.prefix
- The prefix to look for. If this is specified, uri should be null.
declareNamespace(String, String)
,
declareNamespace(OMNamespace)
,
getAllDeclaredNamespaces()
OMNamespace findNamespaceURI(java.lang.String prefix)
prefix
- java.util.Iterator getAllDeclaredNamespaces() throws OMException
If you're interested in all namespaces in scope, you need to call this function for all parent elements as well. Note that the iterator may be invalidated by any call to either declareNamespace function.
OMNamespace
items declared on the current
element.
OMException
findNamespace(String, String)
,
declareNamespace(String, String)
,
declareNamespace(OMNamespace)
java.util.Iterator getAllAttributes()
Note that the iterator returned by this function will be invalidated by any addAttribute call.
Iterator
of OMAttribute
items associated with the
element.getAttribute(javax.xml.namespace.QName)
,
addAttribute(OMAttribute)
,
addAttribute(String, String, OMNamespace)
OMAttribute getAttribute(javax.xml.namespace.QName qname)
qname
- the qualified name to search for
java.lang.String getAttributeValue(javax.xml.namespace.QName qname)
qname
- the qualified name to search for
OMAttribute addAttribute(OMAttribute attr)
There is no order implied by added attributes.
attr
- The attribute to add.
OMAttribute addAttribute(java.lang.String attributeName, java.lang.String value, OMNamespace ns)
This function does not check to make sure that the given attribute value can be serialized directly as an XML value. The caller may, for example, pass a string with the character 0x01.
attributeName
- The "local name" for the attribute.value
- The string value of the attribute.ns
- The namespace has to be one of the in scope namespace. i.e. the passed
namespace must be declared in the parent element of this attribute or
ancestors of the parent element of the attribute.
void removeAttribute(OMAttribute attr)
attr
- void setBuilder(OMXMLParserWrapper wrapper)
wrapper
- OMXMLParserWrapper getBuilder()
void setFirstChild(OMNode node)
node
- OMElement getFirstElement()
javax.xml.stream.XMLStreamReader getXMLStreamReader()
Caching is on.
javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
Caching is off.
void setText(java.lang.String text)
text
- void setText(javax.xml.namespace.QName text)
java.lang.String getText()
This method iterates over all the text children of the element and concatenates them to a single string. Only direct children will be considered, i.e. the text is not extracted recursively. For example the return value for <element>A<child>B</child>C</element> will be AC.
All whitespace will be preserved.
javax.xml.namespace.QName getTextAsQName()
java.lang.String getLocalName()
void setLocalName(java.lang.String localName)
localName
- OMNamespace getNamespace() throws OMException
OMException
void setNamespace(OMNamespace namespace)
namespace
- void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
namespace
- javax.xml.namespace.QName getQName()
QName
for the element.java.lang.String toString()
toString
in class java.lang.Object
java.lang.String toStringWithConsume() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
javax.xml.namespace.QName resolveQName(java.lang.String qname)
qname
- prefixed qname string to resolve
OMElement cloneOMElement()
void setLineNumber(int lineNumber)
int getLineNumber()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |