public class ElementImpl extends ParentNode implements Element, IElement, OMConstants
Modifier and Type | Field and Description |
---|---|
protected OMXMLParserWrapper |
builder |
protected String |
localName |
protected OMNamespace |
namespace
The namespace of this element.
|
protected int |
state |
firstChild, lastChild
factory, FIRSTCHILD, flags, HAS_PARENT, SPECIFIED
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
COMPLETE, DISCARDED, INCOMPLETE
DTD_NODE, PI_NODE, SPACE_NODE
ARRAY_ITEM_LOCALNAME, ARRAY_ITEM_NS_PREFIX, ARRAY_ITEM_NSURI, ARRAY_ITEM_QNAME, DATA_HANDLER, DEFAULT_CHAR_SET_ENCODING, DEFAULT_DEFAULT_NAMESPACE, DEFAULT_XML_VERSION, IS_BINARY, IS_DATA_HANDLERS_AWARE, PULL_TYPE_BUILDER, PUSH_TYPE_BUILDER, XMLATTRTYPE_CDATA, XMLATTRTYPE_ENTITIES, XMLATTRTYPE_ENTITY, XMLATTRTYPE_ID, XMLATTRTYPE_IDREF, XMLATTRTYPE_IDREFS, XMLATTRTYPE_NMTOKEN, XMLATTRTYPE_NMTOKENS, XMLATTRTYPE_NOTATION, XMLNS_NS_PREFIX, XMLNS_NS_URI, XMLNS_PREFIX, XMLNS_URI
Constructor and Description |
---|
ElementImpl(ParentNode parentNode,
String localName,
OMNamespace ns,
OMXMLParserWrapper builder,
OMFactory factory,
boolean generateNSDecl) |
Modifier and Type | Method and Description |
---|---|
OMAttribute |
addAttribute(OMAttribute attr)
Adds an attribute to this element.
|
OMAttribute |
addAttribute(String localName,
String value,
OMNamespace ns)
Adds an attribute to this element.
|
OMNamespace |
addNamespaceDeclaration(String uri,
String prefix)
Adds a namespace declaration without doing any additional checks.
|
void |
build()
Builds itself.
|
void |
buildWithAttachments()
Parses this node and builds the object structure in memory.
|
OMElement |
cloneOMElement()
Clones this element and its descendants using default options.
|
protected OMElement |
createClone(OMCloneOptions options,
ParentNode targetParent,
boolean generateNSDecl) |
OMNamespace |
declareDefaultNamespace(String uri)
Add a namespace declaration for the default namespace to this element.
|
OMNamespace |
declareNamespace(OMNamespace namespace)
Allows overriding an existing declaration if the same prefix was used.
|
OMNamespace |
declareNamespace(String uri,
String prefix)
Add a namespace declaration for the given namespace URI to this element, optionally
generating a prefix for that namespace.
|
void |
discard()
Discards a node.
|
void |
discarded() |
OMNamespace |
findNamespace(String uri,
String prefix)
Finds a namespace with the given uri and prefix, in the scope of the hierarchy.
|
OMNamespace |
findNamespaceURI(String prefix)
Checks for a namespace in the context of this element with the given prefix and returns the
relevant namespace object, if available.
|
Iterator |
getAllAttributes()
Returns a list of OMAttributes.
|
Iterator |
getAllDeclaredNamespaces()
Returns an iterator for all of the namespaces declared on this element.
|
OMAttribute |
getAttribute(QName qname)
Returns a named attribute if present.
|
String |
getAttribute(String name)
Looks in the local list of attributes and returns if found.
|
Attr |
getAttributeNode(String name)
Retrieves an attribute node by name.
|
Attr |
getAttributeNodeNS(String namespaceURI,
String localName)
Retrieves an attribute node by local name and namespace URI.
|
String |
getAttributeNS(String namespaceURI,
String localName)
Retrieves an attribute value by local name and namespace URI.
|
NamedNodeMap |
getAttributes()
Returns the set of attributes of this node and the namespace declarations available.
|
String |
getAttributeValue(QName qname)
Returns a named attribute's value, if present.
|
OMXMLParserWrapper |
getBuilder()
Returns the builder object.
|
Iterator |
getChildElements()
Returns a filtered list of children - just the elements.
|
OMNamespace |
getDefaultNamespace()
Get the default namespace in scope on this element.
|
NodeList |
getElementsByTagName(String name) |
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName) |
OMElement |
getFirstElement()
Returns the first Element node.
|
IParentNode |
getIParentNode() |
int |
getLineNumber() |
String |
getLocalName()
Returns the local name of this element node
|
OMNamespace |
getNamespace()
Returns the namespace of this element.
|
NamespaceContext |
getNamespaceContext(boolean detached)
Get the namespace context of this element, as determined by the namespace declarations
present on this element and its ancestors.
|
Iterator |
getNamespacesInScope()
Get an iterator that returns all namespaces in scope for this element.
|
String |
getNamespaceURI()
Returns the value of the namespace URI.
|
String |
getNamespaceURI(String prefix)
Returns the namespace uri, given the prefix.
|
OMNode |
getNextOMSibling()
Returns the next sibling in document order.
|
Node |
getNextSibling() |
String |
getNodeName() |
short |
getNodeType() |
String |
getPrefix()
Returns the namespace prefix of this element node
|
QName |
getQName()
Returns the QName of this element.
|
TypeInfo |
getSchemaTypeInfo() |
int |
getState() |
String |
getTagName() |
String |
getText()
Returns the non-empty text children as a string.
|
QName |
getTextAsQName()
Resolve the content of this element to a
QName . |
Reader |
getTextAsStream(boolean cache)
Returns a stream representing the concatenation of the text nodes that are children of a
this element.
|
int |
getType()
Returns the type of node.
|
boolean |
hasAttribute(String name) |
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Returns whether the given attribute is available or not.
|
boolean |
hasAttributes()
Returns whether this element contains any attribute or not.
|
void |
internalSerialize(XMLStreamWriter writer,
boolean cache)
Serializes the node.
|
void |
internalSetNamespace(OMNamespace namespace)
Set the namespace of the node without adding a corresponding namespace declaration.
|
boolean |
isComplete()
Indicates whether parser has parsed this information item completely or not.
|
String |
lookupNamespaceURI(String specifiedPrefix) |
void |
removeAttribute(OMAttribute attr)
Removes the given attribute from this element.
|
void |
removeAttribute(String name)
Removes an attribute by name.
|
Attr |
removeAttributeNode(Attr oldAttr)
Removes the specified attribute node.
|
void |
removeAttributeNS(String namespaceURI,
String localName) |
void |
removeChildren()
Remove all children from this container.
|
QName |
resolveQName(String qname)
Resolves a QName literal in the namespace context defined by this element and produces a
corresponding
QName object. |
void |
setAttribute(String name,
String value) |
Attr |
setAttributeNode(Attr attr)
Adds a new attribute node.
|
Attr |
setAttributeNodeNS(Attr attr) |
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
Adds a new attribute.
|
void |
setBuilder(OMXMLParserWrapper wrapper)
Sets the OM builder.
|
void |
setComplete(boolean complete) |
void |
setIdAttribute(String name,
boolean isId) |
void |
setIdAttributeNode(Attr idAttr,
boolean isId) |
void |
setIdAttributeNS(String namespaceURI,
String localName,
boolean isId) |
void |
setLineNumber(int lineNumber) |
void |
setLocalName(String localName)
Sets the local name.
|
void |
setNamespace(OMNamespace namespace)
Set the namespace for this element.
|
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 |
setPrefix(String prefix) |
void |
setText(QName qname)
Set the content of this element to the given
QName . |
void |
setText(String text)
Creates a text node with the given value and adds it to the element.
|
String |
toString()
Overridden toString() for ease of debugging.
|
String |
toStringWithConsume()
Convenience method to serialize the element to a string without caching.
|
void |
undeclarePrefix(String prefix)
Add a namespace declaration that undeclares a given prefix.
|
void |
writeTextTo(Writer out,
boolean cache)
Write the content of the text nodes that are children of a given element to a
Writer . |
addChild, addChild, appendChild, getChildNodes, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getDescendants, getFirstChild, getFirstChildWithName, getFirstOMChild, getFirstOMChildIfAvailable, getLastChild, getLastKnownOMChild, getLength, getSAXSource, getTextContent, getXMLStreamReader, getXMLStreamReader, getXMLStreamReader, getXMLStreamReaderWithoutCaching, hasChildNodes, insertBefore, item, removeChild, replaceChild, setFirstChild, setLastChild, setTextContent
clone, cloneNode, close, compareDocumentPosition, detach, getBaseURI, getFeature, getNextOMSiblingIfAvailable, getNodeValue, getOMFactory, getOwnerDocument, getParent, getParentNode, getPreviousOMSibling, getPreviousSibling, getUserData, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupPrefix, normalize, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setNextOMSibling, setNodeValue, setParent, setParent, setPreviousOMSibling, setUserData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendChild, cloneNode, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setTextContent, setUserData
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
getLastKnownOMChild, setFirstChild, setLastChild
addChild
addChild, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getDescendants, getFirstChildWithName, getFirstOMChild, getSAXSource, getXMLStreamReader, getXMLStreamReader, getXMLStreamReader, getXMLStreamReaderWithoutCaching
getFirstOMChildIfAvailable
getNextOMSiblingIfAvailable, internalSerialize, internalSerializeAndConsume, setNextOMSibling, setParent, setPreviousOMSibling
detach, getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBefore
close, serialize, serialize, serializeAndConsume
clone, getOMFactory
protected OMXMLParserWrapper builder
protected int state
protected OMNamespace namespace
null
(if the element has no namespace)
OMNamespace
instance, with the following exceptions:
OMNamespace
instance with a null
prefix
OMNamespace
instance with both prefix and namespace URI set to the empty
string
protected String localName
public ElementImpl(ParentNode parentNode, String localName, OMNamespace ns, OMXMLParserWrapper builder, OMFactory factory, boolean generateNSDecl)
public short getNodeType()
getNodeType
in interface Node
public String getNodeName()
getNodeName
in interface Node
public String getNamespaceURI()
getNamespaceURI
in interface OMNamedInformationItem
getNamespaceURI
in interface Node
getNamespaceURI
in class NodeImpl
null
if the information
item has no namespacepublic int getType() throws OMException
OMNode
getType
in interface OMNode
OMNode.ELEMENT_NODE
, OMNode.TEXT_NODE
, OMNode.CDATA_SECTION_NODE
,
OMNode.COMMENT_NODE
, OMNode.DTD_NODE
, OMNode.PI_NODE
, OMNode.ENTITY_REFERENCE_NODE
or OMNode.SPACE_NODE
.OMException
public String getTagName()
getTagName
in interface Element
public void removeAttribute(String name) throws DOMException
removeAttribute
in interface Element
name
- The name of the attribute to removeDOMException
Element.removeAttribute(String)
public void removeAttributeNS(String namespaceURI, String localName) throws DOMException
removeAttributeNS
in interface Element
DOMException
public Attr removeAttributeNode(Attr oldAttr) throws DOMException
removeAttributeNode
in interface Element
DOMException
Element.removeAttributeNode(org.w3c.dom.Attr)
public boolean hasAttribute(String name)
hasAttribute
in interface Element
public boolean hasAttributeNS(String namespaceURI, String localName)
hasAttributeNS
in interface Element
Element.hasAttributeNS(String, String)
public String getAttribute(String name)
getAttribute
in interface Element
Element.getAttribute(String)
public Attr getAttributeNode(String name)
getAttributeNode
in interface Element
Element.getAttributeNode(String)
public String getAttributeNS(String namespaceURI, String localName)
getAttributeNS
in interface Element
Element.getAttributeNS(String, String)
public Attr getAttributeNodeNS(String namespaceURI, String localName)
getAttributeNodeNS
in interface Element
Element.getAttributeNodeNS(String, String)
public Attr setAttributeNode(Attr attr) throws DOMException
setAttributeNode
in interface Element
DOMException
Element.setAttributeNode(org.w3c.dom.Attr)
public void setAttribute(String name, String value) throws DOMException
setAttribute
in interface Element
DOMException
public Attr setAttributeNodeNS(Attr attr) throws DOMException
setAttributeNodeNS
in interface Element
DOMException
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException
setAttributeNS
in interface Element
DOMException
Element.setAttributeNS(String, String, String)
public boolean hasAttributes()
hasAttributes
in interface Node
hasAttributes
in class NodeImpl
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
getElementsByTagNameNS
in interface Element
public NodeList getElementsByTagName(String name)
getElementsByTagName
in interface Element
public OMAttribute addAttribute(OMAttribute attr)
OMElement
If the attribute already has an owner, the attribute is cloned (i.e. its name, value and
namespace are copied to a new attribute) and the new attribute is added to the element.
Otherwise the existing instance specified by the attr
parameter is added to
the element. In both cases the owner of the added attribute is set to be the particular
OMElement
.
If there is already an attribute with the same name and namespace URI, it will be replaced
and its owner set to null
.
In the particular case where the attribute specified by attr
is already owned
by the element, calling this method has no effect.
Attributes are not stored in any particular order. In particular, there is no guarantee
that the added attribute will be returned as the last item by the iterator produced by
a subsequent call to OMElement.getAllAttributes()
.
If the attribute being added has a namespace, but no corresponding namespace declaration is in scope for the element (i.e. declared on the element or one of its ancestors), a new namespace declaration is added to the element. Note that both the namespace prefix and URI are taken into account when looking for an existing namespace declaration.
addAttribute
in interface OMElement
attr
- The attribute to add.attr
, depending on whether the attribute specified
by this parameter already has an owner or not.(org.apache.axiom.om.OMAttribute)
public OMAttribute addAttribute(String localName, String value, OMNamespace ns)
OMElement
If the element already has an attribute with the same local name and namespace URI, then this
existing attribute will be removed from the element, i.e. this method will always create a
new OMAttribute
instance and never update an existing one.
addAttribute
in interface OMElement
localName
- The local name for the attribute.value
- The string value of the attribute. 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.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.public OMNamespace addNamespaceDeclaration(String uri, String prefix)
OMElementEx
In contrast to OMElement.declareNamespace(String, String)
this method can be used to
declare the default namespace.
addNamespaceDeclaration
in interface OMElementEx
uri
- the namespace to declare; must not be null
prefix
- the prefix to associate with the given namespace; must not be null
public OMNamespace declareNamespace(OMNamespace namespace)
declareNamespace
in interface OMElement
namespace
- The namespace to declare. If the prefix specified by the OMNamespace
object is null
, then a prefix will be generated.OMNamespace
object passed
as parameter, except if the prefix was null
, in which case the return
value contains the generated prefix.(org.apache.axiom.om.OMNamespace)
public void undeclarePrefix(String prefix)
OMElement
A namespace declaration with empty namespace name will be added even if no existing namespace declaration for the given prefix is in scope in the context of the current element. If a namespace declaration for the given prefix is already defined on this element, it will be replaced.
The namespace declaration created by this method will be returned by
OMElement.getAllDeclaredNamespaces()
. It is represented as an OMNamespace
object for
which OMNamespace.getNamespaceURI()
returns an empty string.
undeclarePrefix
in interface OMElement
prefix
- the prefix to undeclarepublic OMNamespace declareNamespace(String uri, String prefix)
OMElement
Note that this method can't be used to declare a default namespace. For that purpose use
OMElement.declareDefaultNamespace(String)
or OMElement.declareNamespace(OMNamespace)
.
declareNamespace
in interface OMElement
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 null
or the empty string is
given, a prefix will be auto-generated. Please note that using the empty string
for this purpose is deprecated and will no longer be supported in Axiom 1.3.OMElement.declareNamespace(OMNamespace)
,
OMElement.findNamespace(String, String)
,
OMElement.getAllDeclaredNamespaces()
public OMNamespace declareDefaultNamespace(String uri)
OMElement
Note that this method will never change the namespace of the element itself. If an attempt is made to add a namespace declaration that conflicts with the namespace information of the element, an exception is thrown.
declareDefaultNamespace
in interface OMElement
uri
- The default namespace to declare in the current scope. The caller is expected to
ensure that the URI is a valid namespace name.public OMNamespace getDefaultNamespace()
OMElement
getDefaultNamespace
in interface OMElement
null
if no default namespace is in scope. This
method never returns an OMNamespace
object with an empty namespace URI; if
the element or one of its ancestors has a xmlns="" declaration, then
null
is returned. Note that if the method returns an OMNamespace
object, then its prefix will obviously be the empty string.public OMNamespace findNamespace(String uri, String prefix)
OMElement
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.
findNamespace
in interface OMElement
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.OMElement.findNamespace(String, String)
public OMNamespace findNamespaceURI(String prefix)
OMElement
findNamespaceURI
in interface OMElement
public OMAttribute getAttribute(QName qname)
getAttribute
in interface OMElement
qname
- the qualified name to search for(javax.xml.namespace.QName)
public String getAttributeValue(QName qname)
getAttributeValue
in interface OMElement
qname
- the qualified name to search forpublic OMElement getFirstElement()
getFirstElement
in interface OMElement
OMElement.getFirstElement()
public OMNamespace getNamespace()
getNamespace
in interface OMNamedInformationItem
null
if the information item
has no namespace. Note that this implies that the method never returns an
OMNamespace
object with both prefix and namespace URI set to the empty
string. In addition, the prefix of the returned OMNamespace
object (if any)
is never null
: if a null
prefix was specified when creating
this information item, then a prefix has been automatically assigned and the assigned
prefix is returned.OMNamedInformationItem.getNamespace()
public QName getQName()
getQName
in interface OMNamedInformationItem
QName
for the information itemOMNamedInformationItem.getQName()
public String getText()
OMElement
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.
public Reader getTextAsStream(boolean cache)
OMElement
new StringReader(element.getText())
The difference is that the stream implementation returned by this method is optimized for performance and is guaranteed to have constant memory usage, provided that:
OMElement
, i.e.
cache
is false
or the element is an OMSourcedElement
that
is backed by a non destructive OMDataSource
.
XMLStreamReader
in
the case of an OMSourcedElement
) is non coalescing. Note that this is not the default
in Axiom and it may be necessary to configure the parser with
StAXParserConfiguration.NON_COALESCING
.
getTextAsStream
in interface OMElement
cache
- whether to enable caching when accessing the elementOMElement.getText()
public QName getTextAsQName()
OMElement
QName
. The QName is interpreted in a way
that is compatible with the XML schema specification. In particular, surrounding whitespace
is ignored.getTextAsQName
in interface OMElement
null
if the element is empty or the QName could
not be resolvedpublic void writeTextTo(Writer out, boolean cache) throws IOException
OMElement
Writer
.
If cache
is true, this method has the same effect as the following instruction:
out.write(element.getText())
The difference is that this method is guaranteed to have constant memory usage and is
optimized for performance (with the same restrictions that apply to
OMElement.getTextAsStream(boolean)
).
The method does not call Writer.close()
.
writeTextTo
in interface OMElement
out
- the stream to write the content tocache
- whether to enable caching when accessing the elementIOException
- if an error occurs when writing to the streamOMElement.getText()
public void removeAttribute(OMAttribute attr)
OMElement
removeAttribute
in interface OMElement
attr
- the attribute to removepublic void setBuilder(OMXMLParserWrapper wrapper)
setBuilder
in interface OMElement
(org.apache.axiom.om.OMXMLParserWrapper)
public void setLocalName(String localName)
setLocalName
in interface OMNamedInformationItem
localName
- the new local name of the information itemOMNamedInformationItem.setLocalName(String)
public void internalSetNamespace(OMNamespace namespace)
public void setNamespace(OMNamespace namespace)
OMElement
setNamespace
in interface OMElement
namespace
- The new namespace for this element, or null
to remove the namespace
from this element. If an OMNamespace
instance with a null
prefix is given, then a prefix will be generated automatically. In this case, the
generated prefix can be determined using OMNamedInformationItem.getNamespace()
.public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
OMElement
setNamespaceWithNoFindInCurrentScope
in interface OMElement
public void setText(String text)
setText
in interface OMElement
text
- the new text content for the elementOMElement.setText(String)
public void setText(QName qname)
OMElement
QName
. If no matching namespace
declaration for the QName
is in scope, then this method will add one. If the
QName
specifies a namespace URI but no prefix, then a prefix will be generated. If
the element has children, then all these children are detached before the content is set. If
the parameter is not null
, then the element will have a single child of type
OMText
after the method returns. If the parameter is null
, then the
element will have no children.public void internalSerialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException
OMNodeEx
OMSerializable.serialize(XMLStreamWriter, boolean)
instead.internalSerialize
in interface OMNodeEx
internalSerialize
in class NodeImpl
cache
- indicates if caching should be enabledXMLStreamException
public String toStringWithConsume() throws XMLStreamException
OMElement
As for OMElement.toString()
, this method may cause high memory consumption for object model
trees containing optimized binary data and should therefore be used with care.
toStringWithConsume
in interface OMElement
XMLStreamException
public String toString()
toString
in interface OMElement
toString
in class Object
Object.toString()
public Iterator getChildElements()
OMElement
getChildElements
in interface OMElement
OMContainer.getChildren()
,
OMContainer.getChildrenWithName(javax.xml.namespace.QName)
public Iterator getAllDeclaredNamespaces() throws OMException
OMElement
OMElement.getNamespacesInScope()
or OMElement.getNamespaceContext(boolean)
to calculate the
namespace context for the element.
OMElement.findNamespace(String, String)
and OMElement.findNamespaceURI(String)
to resolve a
namespace prefix or to find a namespace prefix for a given URI.
OMElement.resolveQName(String)
to resolve a QName literal.
AXIOMXPath.AXIOMXPath(OMElement, String)
or
AXIOMXPath.AXIOMXPath(OMAttribute)
to create an XPath expression using the namespace
context of a given element.
It is expected that applications only rarely use OMElement.getAllDeclaredNamespaces()
directly.
The iterator returned by this method supports Iterator.remove()
and that method can
be used to remove a namespace declaration from this element.
getAllDeclaredNamespaces
in interface OMElement
OMNamespace
items declared on this element. Note that
the iterator may be invalidated by a call to OMElement.declareNamespace(OMNamespace)
,
OMElement.declareNamespace(String, String)
, OMElement.declareDefaultNamespace(String)
or any other method that modifies the namespace declarations of this element.OMException
OMElement.getAllDeclaredNamespaces()
public Iterator getNamespacesInScope()
OMElement
OMNamespace
object with that prefix, and this object specifies
the namespace URI bound to the prefix. The iterator returns an OMNamespace
object
with an empty prefix if and only if there is a default namespace. It will never return an
OMNamespace
object with both the prefix and the namespace URI set to the empty
string, even if the element or one of its ancestors has a namespace declaration of the form
xmlns="".
The order in which the iterator returns the namespaces is undefined, and invoking the
Iterator.remove()
method on the returned iterator is not supported. The iterator may
be a "live" object, which means that results are undefined if the document is modified (in a
way that would modify the namespace context for the element) while the iterator is in use.
getNamespacesInScope
in interface OMElement
public NamespaceContext getNamespaceContext(boolean detached)
OMElement
The method supports two different NamespaceContext
implementation variants:
NamespaceContext
.
Typically, creating a live NamespaceContext
is cheaper, but the lookup performance of
a detached NamespaceContext
is better. The detached variant should always be used if
the reference to the NamespaceContext
is kept longer than the object model itself,
because in this case a live NamespaceContext
would prevent the object model from
being garbage collected.
getNamespaceContext
in interface OMElement
detached
- true
if the method should return a detached implementation,
false
if the method should return a live objectpublic Iterator getAllAttributes()
OMElement
Note that the iterator returned by this function will be invalidated by any addAttribute call.
getAllAttributes
in interface OMElement
Iterator
of OMAttribute
items associated with the
element.OMElement.getAllAttributes()
public String getLocalName()
getLocalName
in interface OMNamedInformationItem
getLocalName
in interface Node
getLocalName
in class NodeImpl
Node.getLocalName()
public String getPrefix()
getPrefix
in interface OMNamedInformationItem
getPrefix
in interface Node
getPrefix
in class NodeImpl
null
if the information item has
no prefixNode.getPrefix()
public void setPrefix(String prefix) throws DOMException
setPrefix
in interface Node
setPrefix
in class NodeImpl
DOMException
public QName resolveQName(String qname)
OMElement
QName
object. The implementation uses the algorithm defined by the XML
Schema specification. In particular, the namespace for an unprefixed QName is the default
namespace (not the null namespace), i.e. QNames are resolved in the same way as element
names.resolveQName
in interface OMElement
qname
- the QName literal to resolveQName
object, or null
if the QName can't be resolved, i.e.
if the prefix is not bound in the namespace context of this elementpublic OMElement cloneOMElement()
OMElement
OMInformationItem.clone(OMCloneOptions)
with default options.cloneOMElement
in interface OMElement
protected OMElement createClone(OMCloneOptions options, ParentNode targetParent, boolean generateNSDecl)
public void setLineNumber(int lineNumber)
setLineNumber
in interface OMElement
public int getLineNumber()
getLineNumber
in interface OMElement
public NamedNodeMap getAttributes()
getAttributes
in interface Node
getAttributes
in class NodeImpl
ElementImpl
public String getNamespaceURI(String prefix)
prefix
- public void discard() throws OMException
OMNode
discard
in interface OMNode
OMException
public void setIdAttribute(String name, boolean isId) throws DOMException
setIdAttribute
in interface Element
DOMException
public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException
setIdAttributeNS
in interface Element
DOMException
public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException
setIdAttributeNode
in interface Element
DOMException
public TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo
in interface Element
public void buildWithAttachments()
NodeImpl
buildWithAttachments
in interface OMNode
buildWithAttachments
in class NodeImpl
public final OMXMLParserWrapper getBuilder()
OMContainer
getBuilder
in interface IParentNode
getBuilder
in interface OMContainer
getBuilder
in class NodeImpl
public final int getState()
getState
in interface IParentNode
public final boolean isComplete()
OMSerializable
isComplete
in interface IParentNode
isComplete
in interface OMSerializable
isComplete
in class NodeImpl
public final void setComplete(boolean complete)
setComplete
in interface OMContainerEx
setComplete
in interface OMNodeEx
setComplete
in class NodeImpl
public final void discarded()
discarded
in interface OMContainerEx
public final void build()
OMSerializable
build
in interface OMSerializable
public final OMNode getNextOMSibling() throws OMException
OMNode
getNextOMSibling
in interface OMNode
OMException
public final Node getNextSibling()
getNextSibling
in interface Node
public final IParentNode getIParentNode()
getIParentNode
in interface IChildNode
public final void removeChildren()
OMContainer
for (Iterator it = container.getChildren(); it.hasNext(); ) { it.next(); it.remove(); }However, the implementation may do this in an optimized way. In particular, if the node is incomplete, it may choose not to instantiate child node that would become unreachable anyway.
removeChildren
in interface OMContainer
public final String lookupNamespaceURI(String specifiedPrefix)
lookupNamespaceURI
in interface Node
Copyright © 2004–2019 The Apache Software Foundation. All rights reserved.