public final class NodeBuilder extends Object
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.
Constructor and Description |
---|
NodeBuilder()
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
nu.xom.Attribute |
createAttribute(String qname,
String uri,
String value,
nu.xom.Attribute.Type type)
Contructs and returns a new attribute for the given qualified name and
namespace URI.
|
nu.xom.Element |
createElement(String qname,
String uri)
Contructs and returns a new element for the given qualified name and
namespace URI.
|
public nu.xom.Element createElement(String qname, String uri)
qname
- the qualified name of the element (must not be null)uri
- the namespace URI of the elementpublic nu.xom.Attribute createAttribute(String qname, String uri, String value, nu.xom.Attribute.Type type)
qname
- the qualified name of the attribute (must not be null)uri
- the namespace URI of the attributevalue
- the attribute value (must not be null)type
- the attribute type (must not be null)Copyright © 2018 JBoss by Red Hat. All rights reserved.