|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.staldal.xtree.Node
nu.staldal.xtree.NodeWithChildren
nu.staldal.xtree.Element
public class Element
An XML Element.
Field Summary |
---|
Fields inherited from class nu.staldal.xtree.Node |
---|
parent, XML_NS |
Constructor Summary | |
---|---|
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 namespaceURI,
java.lang.String localName,
java.lang.String type,
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 |
getAttributeLocalName(int index)
Get the name of the attribute at the specified index. |
java.lang.String |
getAttributeNamespaceURI(int index)
Get the namespace URI for the attribute at the specified index. |
java.lang.String |
getAttributeType(int index)
Get the type of the attribute at the specified index. |
java.lang.String |
getAttributeValue(int index)
Get the value of the attribute at the specified index. |
java.lang.String |
getAttrValue(java.lang.String localName)
Shortcut method for getting the value of an attribute without namespace. |
java.lang.String |
getAttrValue(java.lang.String namespaceURI,
java.lang.String localName)
Shortcut method for getting the value of an attribute with namespace. |
java.lang.String |
getAttrValueOrNull(java.lang.String localName)
Shortcut method for getting the value of an attribute without namespace. |
java.lang.String |
getAttrValueOrNull(java.lang.String namespaceURI,
java.lang.String localName)
Shortcut method for getting the value of an attribute with namespace. |
java.net.URL |
getBaseURI()
Returns the absolute base URI of this node. |
Element |
getFirstChildElement()
Shortcut method for getting the first Element children with any name. |
Element |
getFirstChildElement(java.lang.String namespaceURI,
java.lang.String localName)
Shortcut method for getting the first Element child with a specified name. |
Element |
getFirstChildElementOrNull()
Shortcut method for getting the first Element children with any name. |
Element |
getFirstChildElementOrNull(java.lang.String namespaceURI,
java.lang.String localName)
Shortcut method for getting the first Element child with a specified name. |
java.lang.String |
getInheritedAttribute(java.lang.String namespaceURI,
java.lang.String localName)
Return the value of an inherited attribute. |
java.lang.String |
getLocalName()
Get the 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. |
int |
lookupAttribute(java.lang.String namespaceURI,
java.lang.String localName)
Lookup the index of an attribute to this 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 |
numberOfAttributes()
Return the number of attributes this element have. |
int |
numberOfNamespaceMappings()
Return the number of namespace mapping 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 |
removeAttribute(int index)
Remove an attribute at the specified index. |
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.xtree.NodeWithChildren |
---|
addChild, getChild, insertChild, numberOfChildren, removeChild, replaceChild |
Methods inherited from class nu.staldal.xtree.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 |
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 haveMethod Detail |
---|
public java.lang.String getNamespaceURI()
public java.lang.String getLocalName()
public int lookupAttribute(java.lang.String namespaceURI, java.lang.String localName)
namespaceURI
- the namespace URI, may be the empty stringlocalName
- the name
getAttributeValue(int)
,
getAttributeType(int)
,
removeAttribute(int)
public void addAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String type, java.lang.String value)
namespaceURI
- the namespace URI, may be the empty stringlocalName
- the nametype
- the type (use "CDATA" if the type is irrelevant)value
- the valuepublic void removeAttribute(int index) throws java.lang.IndexOutOfBoundsException
index
- the index as returned from lookupAttribute(java.lang.String, java.lang.String)
IndexOutOfBoundException
- if no such attribute exist.
java.lang.IndexOutOfBoundsException
public int numberOfAttributes()
public java.lang.String getAttributeNamespaceURI(int index) throws java.lang.IndexOutOfBoundsException
index
- the index as returned from lookupAttribute(java.lang.String, java.lang.String)
null
if index is -1
java.lang.IndexOutOfBoundsException
- if no such attribute exist.public java.lang.String getAttributeLocalName(int index) throws java.lang.IndexOutOfBoundsException
index
- the index as returned from lookupAttribute(java.lang.String, java.lang.String)
null
if index is -1
java.lang.IndexOutOfBoundsException
- if no such attribute exist.public java.lang.String getAttributeType(int index) throws java.lang.IndexOutOfBoundsException
index
- the index as returned from lookupAttribute(java.lang.String, java.lang.String)
null
if index is -1
java.lang.IndexOutOfBoundsException
- if no such attribute exist.public java.lang.String getAttributeValue(int index) throws java.lang.IndexOutOfBoundsException
index
- the index as returned from lookupAttribute(java.lang.String, java.lang.String)
null
if index is -1
java.lang.IndexOutOfBoundsException
- if no such attribute exist.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
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 namespaceURI, java.lang.String localName)
Node
null
if the root is
reached without finding the attribute). Useful for e.g. xml:lang.
getInheritedAttribute
in class Node
namespaceURI
- the namespace URI, may be the empty stringlocalName
- the attribute name
null
if no such attribute is foundpublic void outputStartElement(org.xml.sax.ContentHandler sax) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void outputEndElement(org.xml.sax.ContentHandler sax) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public 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
public java.lang.String getAttrValueOrNull(java.lang.String localName)
null
if the attribute doesn't existpublic java.lang.String getAttrValue(java.lang.String localName) throws org.xml.sax.SAXParseException
null
org.xml.sax.SAXParseException
- if the attribute doesn't existpublic java.lang.String getAttrValueOrNull(java.lang.String namespaceURI, java.lang.String localName)
null
if the attribute doesn't existpublic java.lang.String getAttrValue(java.lang.String namespaceURI, java.lang.String localName) throws org.xml.sax.SAXParseException
null
org.xml.sax.SAXParseException
- if the attribute doesn't existpublic 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 Element getFirstChildElementOrNull(java.lang.String namespaceURI, java.lang.String localName)
null
if there is no such child.public Element getFirstChildElement(java.lang.String namespaceURI, java.lang.String localName) throws org.xml.sax.SAXParseException
null
.
org.xml.sax.SAXParseException
- if there is no such child.public Element getFirstChildElementOrNull()
null
if there are no Element children.public Element getFirstChildElement() throws org.xml.sax.SAXParseException
null
.
org.xml.sax.SAXParseException
- if there are no Element children.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |