org.mmbase.bridge.util.xml
Class Generator

java.lang.Object
  extended by org.mmbase.bridge.util.xml.Generator

public class Generator
extends Object

Uses the XML functions from the bridge to construct a DOM document representing MMBase data structures.

Since:
MMBase-1.6
Version:
$Id: Generator.java,v 1.48 2007/04/09 19:10:27 michiel Exp $
Author:
Michiel Meeuwissen, Eduard Witteveen

Field Summary
static String NAMESPACE
           
 
Constructor Summary
Generator(Document doc)
           
Generator(DocumentBuilder documentBuilder)
           
Generator(DocumentBuilder documentBuilder, Cloud cloud)
          To create documents representing structures from the cloud, it needs a documentBuilder, to contruct the DOM Document, and the cloud from which the data to be inserted will come from.
 
Method Summary
 void add(List<? extends Node> nodes)
          Adds a whole MMBase bridge NodeList to the DOM Document.
 Element add(Node node)
          Adds one Node to a DOM Document.
 Element add(Node node, Field fieldDefinition)
          Adds a field to the DOM Document.
 Element add(Relation relation)
          Adds one Relation to a DOM Document.
protected  Element createElement(String name)
           
protected  String getAttribute(Element element, String name)
           
 long getCost()
          Returns an estimation on how long it took to construct the document.
 Document getDocument()
          Returns the working DOM document.
 int getSize()
          The number of presented MMBase nodes in the document.
 boolean isNamespaceAware()
           
protected  void setAttribute(Element element, String name, String value)
           
 void setNamespaceAware(boolean n)
          If namespace aware, element are created with the namespace http://www.mmbase.org/objects, otherwise, without namespace.
 String toString()
          Returns the document as a String.
 String toString(boolean ident)
          Returns the document as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAMESPACE

public static final String NAMESPACE
See Also:
Constant Field Values
Constructor Detail

Generator

public Generator(DocumentBuilder documentBuilder,
                 Cloud cloud)
To create documents representing structures from the cloud, it needs a documentBuilder, to contruct the DOM Document, and the cloud from which the data to be inserted will come from.

Parameters:
documentBuilder - The DocumentBuilder which will be used to create the Document.
cloud - The cloud from which the data will be.
See Also:
DocumentReader.getDocumentBuilder()

Generator

public Generator(DocumentBuilder documentBuilder)

Generator

public Generator(Document doc)
Method Detail

getCost

public long getCost()
Returns an estimation on how long it took to construct the document.

Returns:
a duration in nanoseconds.
Since:
MMBase-1.9

getSize

public int getSize()
The number of presented MMBase nodes in the document.

Since:
MMBase-1.9

getDocument

public Document getDocument()
Returns the working DOM document.

Returns:
The document, build with the operations done on the generator class

setNamespaceAware

public void setNamespaceAware(boolean n)
If namespace aware, element are created with the namespace http://www.mmbase.org/objects, otherwise, without namespace.

Since:
MMBase-1.8

isNamespaceAware

public boolean isNamespaceAware()
Since:
MMBase-1.8

createElement

protected Element createElement(String name)
Since:
MMBase-1.8

setAttribute

protected final void setAttribute(Element element,
                                  String name,
                                  String value)

getAttribute

protected final String getAttribute(Element element,
                                    String name)

toString

public String toString()
Returns the document as a String.

Overrides:
toString in class Object
Returns:
the xml generated as an string

toString

public String toString(boolean ident)
Returns the document as a String.

Parameters:
ident - if the string has to be idented
Returns:
the generated xml as a (formatted) string

add

public Element add(Node node,
                   Field fieldDefinition)
Adds a field to the DOM Document. This means that there will also be added a Node if this is necessary.

Parameters:
node - An MMbase bridge Node.
fieldDefinition - An MMBase bridge Field.

add

public Element add(Node node)
Adds one Node to a DOM Document.

Parameters:
node - An MMBase bridge Node.

add

public Element add(Relation relation)
Adds one Relation to a DOM Document.

Parameters:
relation - An MMBase bridge Node.

add

public void add(List<? extends Node> nodes)
Adds a whole MMBase bridge NodeList to the DOM Document.

Parameters:
nodes - An MMBase bridge NodeList.


MMBase build 1.9.0.20081107