|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nu.staldal.xmltree.Node nu.staldal.xmltree.NodeWithChildren nu.staldal.xmltree.Element
public class Element
An XML Element.
Field Summary |
---|
Fields inherited from class nu.staldal.xmltree.Node |
---|
parent |
Constructor Summary | |
---|---|
Element(Element element)
Pseudo-copy constructor, do not copy the children, but allocate room for them. |
|
Element(java.lang.String namespaceURI,
java.lang.String localName)
Construct an element. |
|
Element(java.lang.String namespaceURI,
java.lang.String localName,
int numberOfAttributes)
Construct an element. |
|
Element(java.lang.String namespaceURI,
java.lang.String localName,
int numberOfAttributes,
int numberOfChildren)
Construct an element. |
Method Summary | |
---|---|
void |
addAttribute(java.lang.String name,
java.lang.String value)
Add an attribute to this element. |
void |
addNamespaceMapping(java.lang.String prefix,
java.lang.String URI)
Add a namespace mapping to this element. |
java.lang.String |
getAttribute(java.lang.String name)
Shortcut method for getting the value of an attribute. |
java.lang.String |
getAttributeOrNull(java.lang.String name)
Shortcut method for getting the value of an attribute. |
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Get the Map with attributes for this element. |
java.net.URL |
getBaseURI()
Returns the absolute base URI of this node. |
java.lang.String |
getInheritedAttribute(java.lang.String name)
Return the value of an inherited attribute. |
java.lang.String |
getLocalName()
Get the name of this element. |
java.lang.String |
getName()
Get the qualified name of this element. |
java.lang.String[] |
getNamespaceMapping(int index)
Return a namespace mapping at the specified index. |
java.lang.String |
getNamespaceURI()
Get the namespace URI for this element. |
boolean |
getPreserveSpace()
Return the value of any xml:space attribute in force for this node. |
java.lang.String |
getTextContent()
Shortcut method for getting the text content of an Element. |
java.lang.String |
getTextContentOrNull()
Shortcut method for getting the text content of an Element. |
java.lang.String |
lookupNamespacePrefix(java.lang.String URI)
Lookup a prefix which has been mapped to a namespace URI. |
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
Lookup the namespace URI which has been mapped to a prefix. |
int |
numberOfNamespaceMappings()
Return the number of namespace mappings for this element. |
void |
outputEndElement(org.xml.sax.ContentHandler sax)
Fire the endElement event to the given SAX2 ContentHandler. |
void |
outputStartElement(org.xml.sax.ContentHandler sax)
Fire the startElement event to the given SAX2 ContentHandler. |
void |
outputStartElement(org.xml.sax.ContentHandler sax,
java.util.Map<java.lang.String,java.lang.String> attributes)
Fire the startElement event to the given SAX2 ContentHandler. |
void |
setBaseURI(java.net.URL URI)
Set the baseURI property of this element. |
void |
toSAX(org.xml.sax.ContentHandler sax)
Serialize this node, and recursively the (sub)tree beneath, into SAX2 events. |
Methods inherited from class nu.staldal.xmltree.NodeWithChildren |
---|
add, add, addAll, addAll, clear, contains, containsAll, get, getChildElements, getFirstChildElement, getFirstChildElement, getFirstChildElementOrNull, getFirstChildElementOrNull, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray |
Methods inherited from class nu.staldal.xmltree.Node |
---|
getColumnNumber, getLineNumber, getParent, getPublicId, getSystemId, isWhitespaceNode, setColumn, setLine, setPublicId, setSystemId |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
equals, hashCode |
Constructor Detail |
---|
public Element(java.lang.String namespaceURI, java.lang.String localName)
namespaceURI
- the namespace URI for this element, may be the empty stringlocalName
- the element namepublic Element(java.lang.String namespaceURI, java.lang.String localName, int numberOfAttributes)
namespaceURI
- the namespace URI for this element, may be the empty stringlocalName
- the element namenumberOfAttributes
- the number of attributes this element should havepublic Element(java.lang.String namespaceURI, java.lang.String localName, int numberOfAttributes, int numberOfChildren)
namespaceURI
- the namespace URI for this element, may be the empty stringlocalName
- the name of this element (no namespace)numberOfAttributes
- the number of attributes this element should havenumberOfChildren
- the number of children this element should havepublic Element(Element element)
element
- the element to copyMethod Detail |
---|
public java.lang.String getNamespaceURI()
public java.lang.String getLocalName()
public java.lang.String getName()
public void addNamespaceMapping(java.lang.String prefix, java.lang.String URI)
prefix
- the prefixURI
- the namespace URIpublic int numberOfNamespaceMappings()
public java.lang.String[] getNamespaceMapping(int index) throws java.lang.IndexOutOfBoundsException
index
- the index
java.lang.IndexOutOfBoundsException
- if no such mapping exist.public java.lang.String lookupNamespaceURI(java.lang.String prefix)
Node
lookupNamespaceURI
in class Node
prefix
- the prefix, may be the empty string which denotes the default
namespace.
null
if the prefix is not
mapped to any namespace URI, or the empty string of prefix is the
empty string and there is no default namespace mapping.public java.lang.String lookupNamespacePrefix(java.lang.String URI)
Node
lookupNamespacePrefix
in class Node
URI
- the namespace URI
null
if no prefix is mapped to the namespace
URI.public void setBaseURI(java.net.URL URI)
URI
- the base URI, must be absolutepublic java.net.URL getBaseURI()
Node
getBaseURI
in class Node
null
if
unknown.public boolean getPreserveSpace()
Node
getPreserveSpace
in class Node
true
if an xml:space="preserve" is in effectpublic java.lang.String getInheritedAttribute(java.lang.String name)
Node
null
if the root is reached without
finding the attribute). Useful for e.g. xml:lang.
getInheritedAttribute
in class Node
name
- the attribute name
null
if no such attribute is foundpublic void outputStartElement(org.xml.sax.ContentHandler sax) throws org.xml.sax.SAXException
sax
- the ContentHandler
org.xml.sax.SAXException
- if any of the ContentHandler methods throw itpublic void outputStartElement(org.xml.sax.ContentHandler sax, java.util.Map<java.lang.String,java.lang.String> attributes) throws org.xml.sax.SAXException
sax
- the ContentHandlerattributes
- the attributes to use instead of the normal ones
org.xml.sax.SAXException
- if any of the ContentHandler methods throw itpublic void outputEndElement(org.xml.sax.ContentHandler sax) throws org.xml.sax.SAXException
sax
- the ContentHandler
org.xml.sax.SAXException
- if any of the ContentHandler methods throw itpublic void toSAX(org.xml.sax.ContentHandler sax) throws org.xml.sax.SAXException
Node
toSAX
in class Node
sax
- the SAX2 ContentHander to fire events on.
org.xml.sax.SAXException
- if any of the ContentHandler methods throw itpublic java.lang.String getTextContentOrNull()
null
if there are more
than one children or one non-Text childpublic java.lang.String getTextContent() throws org.xml.sax.SAXParseException
null
.
org.xml.sax.SAXParseException
- if there are more than one children or one non-Text childpublic void addAttribute(java.lang.String name, java.lang.String value)
name
- attribute namevalue
- attribute valuepublic java.lang.String getAttributeOrNull(java.lang.String name)
name
- the (qualified) name of the attribute
null
if the attribute doesn't existpublic java.lang.String getAttribute(java.lang.String name) throws org.xml.sax.SAXParseException
name
- the (qualified) name of the attribute
null
org.xml.sax.SAXParseException
- if the attribute doesn't existpublic java.util.Map<java.lang.String,java.lang.String> getAttributes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |