Nux 1.6

nux.xom.binary
Class NodeBuilder

java.lang.Object
  extended by nux.xom.binary.NodeBuilder

public final class NodeBuilder
extends Object

EXPERIMENTAL; Not part of published API; Subject to change or removal without notice. Wishing Java had "friends" to make select internal classes visible across package boundaries...

Small fast utility for efficient construction of elements and attributes. Implemented via a LRU cache of the most recent elements and attributes.

Avoids repeated XML reverification in XOM Element and Attribute constructor on cache hit, plus avoids generating new String objects by quasi "interning" localName and prefix, which in turn reduces memory consumption. Has overhead close to zero on cache miss.

This implementation is not thread-safe.

This class would become obsolete if the XOM Element and Attribute classes would have an internal LRU cache of QNames.

Author:
whoschek.AT.lbl.DOT.gov, $Author: hoschek3 $

Constructor Summary
NodeBuilder()
          Constructs a new instance.
 
Method Summary
 Attribute createAttribute(String qname, String uri, String value, Attribute.Type type)
          Contructs and returns a new attribute for the given qualified name and namespace URI.
 Element createElement(String qname, String uri)
          Contructs and returns a new element for the given qualified name and namespace URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeBuilder

public NodeBuilder()
Constructs a new instance.

Method Detail

createElement

public Element createElement(String qname,
                             String uri)
Contructs and returns a new element for the given qualified name and namespace URI.

Parameters:
qname - the qualified name of the element (must not be null)
uri - the namespace URI of the element
Returns:
a new element

createAttribute

public Attribute createAttribute(String qname,
                                 String uri,
                                 String value,
                                 Attribute.Type type)
Contructs and returns a new attribute for the given qualified name and namespace URI.

Parameters:
qname - the qualified name of the attribute (must not be null)
uri - the namespace URI of the attribute
value - the attribute value (must not be null)
type - the attribute type (must not be null)
Returns:
a new attribute

Nux 1.6