|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.exist.fluent.ElementBuilder<K>
K
- the type of object returned upon completion of the builder,
depends on the context in which the builder is usedpublic class ElementBuilder<K>
A builder of DOM trees, meant to be either stand alone or be inserted into
pre-existing ones. Cannot remove nodes from the base tree. You must commit()
the builder to persist the recorded changes in the database.
All the nodes in the tree being built must be from the same implementation. If you attempt
to add foreign nodes -- for example, persistent nodes from the database -- using the
node(org.exist.fluent.Node)
or nodes(org.exist.fluent.ItemList.NodesFacet)
methods to a builder that already has temporary nodes
built using its other methods, they'll be imported. Importing nodes will usually make a deep
copy of the tree in memory, which could cause problems if you're trying to add a big stored
node tree.
Method Summary | |
---|---|
ElementBuilder<K> |
attr(String name,
Object value)
Add an attribute to the currently open element. |
ElementBuilder<K> |
attrIf(boolean condition,
String name,
Object value)
Add an attribute to the currently open element if the given condition holds. |
K |
commit()
Commit this element builder, persisting the recorded elements into the database. |
static ElementBuilder<Node> |
createScratch(NamespaceMap namespaceBindings)
Create a new element builder that creates an in-memory DOM tree and returns the top node (possibly a fragment node) upon commit. |
ElementBuilder<K> |
elem(String tag)
Open a new element with the given tag. |
ElementBuilder<K> |
end(String... tags)
Close the currently open element, matching it to one of the given tags. |
ElementBuilder<K> |
end(String tag)
Close the currently open element, matching it to the given tag. |
ElementBuilder<K> |
namespace(String key,
String uri)
Insert a namespace binding scoped to this builder only. |
ElementBuilder<K> |
node(Node node)
Insert a copy of the given node. |
ElementBuilder<K> |
node(Node node)
Insert a copy of the given node. |
ElementBuilder<K> |
nodes(ItemList.NodesFacet nodes)
Insert copies of the given nodes. |
ElementBuilder<K> |
text(Object text)
Insert text into the currenly open element. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ElementBuilder<Node> createScratch(NamespaceMap namespaceBindings)
namespaceBindings
- the namespace bindings to use, or null
for none
public ElementBuilder<K> namespace(String key, String uri)
key
- the prefix to binduri
- the namespace uri
public ElementBuilder<K> node(Node node)
node
- the node to insert
public ElementBuilder<K> nodes(ItemList.NodesFacet nodes)
nodes
- the nodes to insert
public ElementBuilder<K> node(Node node)
node
- the node to insert
public ElementBuilder<K> elem(String tag)
end(String)
before the builder is committed.
tag
- the tag of the element to insert
public ElementBuilder<K> end(String tag)
tag
- the tag of the element to be ended
public ElementBuilder<K> end(String... tags)
tags
- the possible tags of the element to be ended
public ElementBuilder<K> attr(String name, Object value)
name
- the name of the attribute to addvalue
- the value of the attribute, will be converted to a string using DataUtils.toXMLString(Object)
public ElementBuilder<K> attrIf(boolean condition, String name, Object value)
condition
is true, this behaves as attr(String, Object)
, otherwise it does nothing.
condition
- the condition to satisfy before adding the attributename
- the name of the attribute to addvalue
- the value of the attribute
public ElementBuilder<K> text(Object text)
text
- the text to insert
public K commit()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |