|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.knipp.rritoolkit.XmlBuilder
public class XmlBuilder
helper class to simplify building DOM trees
Field Summary | |
---|---|
private org.w3c.dom.Node |
baseNode
the base node |
private org.w3c.dom.Node |
curNode
the current node, either the document node, document fragment node or an element |
private java.lang.String |
defaultPrefix
the default namespace prefix |
private java.lang.String |
defaultURI
the default namespace URI |
Constructor Summary | |
---|---|
XmlBuilder(org.w3c.dom.Document doc)
constructor. |
|
XmlBuilder(org.w3c.dom.DocumentFragment frag)
constructor. |
|
XmlBuilder(org.w3c.dom.Node node)
constructor. |
Method Summary | |
---|---|
XmlBuilder |
attf(javax.xml.namespace.QName qName,
boolean value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attf(java.lang.String name,
boolean value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attf(java.lang.String uri,
java.lang.String qName,
boolean value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attf(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
boolean value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attr(javax.xml.namespace.QName qName,
java.lang.Object value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attr(java.lang.String name,
java.lang.Object value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attr(java.lang.String uri,
java.lang.String qName,
java.lang.Object value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
attr(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
java.lang.Object value)
add an attribute to the current node, if it is an element node. |
XmlBuilder |
clearNS()
clear the default namespace used for subsequent calls of the "simple" element creation methods. |
XmlBuilder |
comment(java.lang.String text)
add a comment node to the current node |
XmlBuilder |
ee()
finish an element. |
XmlBuilder |
elt(javax.xml.namespace.QName qName,
java.lang.Object value)
convenience method that adds an element with the given value as text. |
XmlBuilder |
elt(java.lang.String name,
java.lang.Object value)
convenience method that adds an element with the given value as text. |
XmlBuilder |
elt(java.lang.String uri,
java.lang.String qName,
java.lang.Object value)
convenience method that adds an element with the given value as text. |
XmlBuilder |
elt(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
java.lang.Object value)
convenience method that adds an element with the given value as text. |
XmlBuilder |
es(javax.xml.namespace.QName qName)
create an element. |
XmlBuilder |
es(java.lang.String localName)
create an element. |
XmlBuilder |
es(java.lang.String uri,
java.lang.String qName)
create an element. |
XmlBuilder |
es(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName)
create an element. |
org.w3c.dom.Node |
getBase()
return the base node |
org.w3c.dom.Node |
getCurrent()
return the current node to which attributes, elements and texts are added to. |
XmlBuilder |
inc(XmlBuilder xb)
include the subtree created by the specified other instance. |
XmlBuilder |
ns(java.lang.String uri)
set the default namespace used for subsequent calls of the "simple" element creation methods. |
XmlBuilder |
ns(java.lang.String uri,
java.lang.String prefix)
set the default namespace used for subsequent calls of the "simple" element creation methods. |
XmlBuilder |
t(java.lang.Object text)
add a text node to the current node. |
XmlBuilder |
ttf(boolean value)
add a text node to the current node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private org.w3c.dom.Node baseNode
private org.w3c.dom.Node curNode
private java.lang.String defaultURI
private java.lang.String defaultPrefix
Constructor Detail |
---|
public XmlBuilder(org.w3c.dom.Document doc) throws org.w3c.dom.DOMException
getBaseNode
.
doc
- the document
org.w3c.dom.DOMException
- if the creation of the fragment failedpublic XmlBuilder(org.w3c.dom.Node node)
node
- the nodepublic XmlBuilder(org.w3c.dom.DocumentFragment frag)
frag
- the fragmentMethod Detail |
---|
public org.w3c.dom.Node getCurrent()
public org.w3c.dom.Node getBase()
public XmlBuilder ns(java.lang.String uri, java.lang.String prefix)
uri
- the URI; if null
, no namespace
is assigned to the subsequent elementsprefix
- the prefix, may be null
public XmlBuilder ns(java.lang.String uri)
uri
- the URI; if null
, no namespace
is assigned to the subsequent elements
public XmlBuilder clearNS()
public XmlBuilder es(java.lang.String localName) throws org.w3c.dom.DOMException
localName
- the local part of the element name
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(java.lang.String uri, java.lang.String qName) throws org.w3c.dom.DOMException
uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefix
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(java.lang.String uri, java.lang.String prefix, java.lang.String localName) throws org.w3c.dom.DOMException
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element name
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(javax.xml.namespace.QName qName) throws org.w3c.dom.DOMException
qName
- the qualified name (as an object)
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder ee()
public XmlBuilder attr(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".
name
- the name of the attributevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String name, boolean value) throws org.w3c.dom.DOMException
name
- the name of the attributevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(java.lang.String uri, java.lang.String qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".
uri
- the name space URIqName
- the qualified name, i.e. a name with orvalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String uri, java.lang.String qName, boolean value) throws org.w3c.dom.DOMException
uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefixvalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(java.lang.String uri, java.lang.String prefix, java.lang.String localName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String uri, java.lang.String prefix, java.lang.String localName, boolean value) throws org.w3c.dom.DOMException
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(javax.xml.namespace.QName qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".
qName
- the qualified namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(javax.xml.namespace.QName qName, boolean value) throws org.w3c.dom.DOMException
qName
- the qualified namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder t(java.lang.Object text) throws org.w3c.dom.DOMException
toString
. The mnemnonic "t" stands
for "text".
text
- the text to add. If null
no node is created
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder ttf(boolean value) throws org.w3c.dom.DOMException
value
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder comment(java.lang.String text) throws org.w3c.dom.DOMException
text
- the text
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".
name
- the name of the elementvalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String uri, java.lang.String qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".
uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefixvalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String uri, java.lang.String prefix, java.lang.String localName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(javax.xml.namespace.QName qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".
qName
- the qualified namevalue
- the value
org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder inc(XmlBuilder xb) throws org.w3c.dom.DOMException
xb
- the other builder
org.w3c.dom.DOMException
- if the creation failed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |