|
|||||||||
Home >> All >> org >> apache >> xerces >> [ tree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
org.apache.xerces.tree
Class SimpleElementFactory

java.lang.Objectorg.apache.xerces.tree.SimpleElementFactory
- All Implemented Interfaces:
- ElementFactory
- public class SimpleElementFactory
- extends java.lang.Object
- implements ElementFactory
- extends java.lang.Object
This is a convenience class for creating application-specific elements associated with specified (or default) XML namespaces. It maintains tables mapping element tag names to classes, and uses them as needed to instantiate classes. The string *Element, which is not a legal XML element name, may be used to map otherwise unrecognized tags to a particular class. If this factory is not configured, then all mappings are to the ElementNode class. Erroneous mappings are fatal errors.
A suggested XML syntax for recording these bindings, which may in the future be explicitly supported, is:
<bindings xmlns="..."> <!-- first, bindings for the "default" namespace --> <binding tag="..." class="..."/> <binding tag="*Element" class="..."/> ... <!-- then bindings for other namespaces --> <namespace uri="..."> <binding tag="..." class="..."/> ... </namespace> <!-- can specify JAR files for namespaces --> <namespace uri="..." jar="..."> <binding tag="..." class="..."/> ... </namespace> ... </bindings>
Note that while most URIs used to identify namespaces will be URLs, such as http://www.example.com/xml/purchasing, some may also be URNs like urn:uuid:221ffe10-ae3c-11d1-b66c-00805f8a2676. You can't assume that the URIs are associated with web-accessible data; they must be treated as being no more than distinguishable strings.
Applications classes configuring an element factory will need to
provide their own class loader (this.class.getClassLoader
)
to get the desired behavior in common cases. Classes loaded via some
URL will similarly need to use a network class loader.
- Version:
- $Revision: 1.1.1.1 $
Field Summary | |
private java.lang.ClassLoader |
defaultLoader
|
private java.util.Dictionary |
defaultMapping
|
private java.lang.String |
defaultNs
|
private java.util.Locale |
locale
|
private java.util.Dictionary |
nsLoaders
|
private java.util.Dictionary |
nsMappings
|
Constructor Summary | |
SimpleElementFactory()
Constructs an unconfigured element factory. |
Method Summary | |
void |
addMapping(java.util.Dictionary dict,
java.lang.ClassLoader loader)
Records a default element name to namespace mapping, for use by namespace-unaware DOM construction and when a specific namespace mapping is not available. |
void |
addMapping(java.lang.String namespace,
java.util.Dictionary dict,
java.lang.ClassLoader loader)
Records a namespace-specific mapping between element names and classes. |
ElementEx |
createElementEx(java.lang.String tag)
Creates an element by using the default mapping. |
ElementEx |
createElementEx(java.lang.String namespace,
java.lang.String tag)
Creates an element by using the mapping associated with the specified namespace, or the default namespace as appropriate. |
private ElementNode |
doMap(java.lang.String tagName,
java.util.Dictionary node2class,
java.lang.ClassLoader loader)
|
(package private) java.lang.String |
getMessage(java.lang.String messageId)
|
(package private) java.lang.String |
getMessage(java.lang.String messageId,
java.lang.Object[] parameters)
|
private java.lang.Class |
map2Class(java.lang.String key,
java.util.Dictionary node2class,
java.lang.ClassLoader loader)
|
void |
setDefaultNamespace(java.lang.String ns)
Defines a URI to be treated as the "default" namespace. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
defaultMapping
private java.util.Dictionary defaultMapping
defaultLoader
private java.lang.ClassLoader defaultLoader
defaultNs
private java.lang.String defaultNs
nsMappings
private java.util.Dictionary nsMappings
nsLoaders
private java.util.Dictionary nsLoaders
locale
private java.util.Locale locale
Constructor Detail |
SimpleElementFactory
public SimpleElementFactory()
- Constructs an unconfigured element factory.
Method Detail |
addMapping
public void addMapping(java.util.Dictionary dict, java.lang.ClassLoader loader)
- Records a default element name to namespace mapping, for use
by namespace-unaware DOM construction and when a specific
namespace mapping is not available.
addMapping
public void addMapping(java.lang.String namespace, java.util.Dictionary dict, java.lang.ClassLoader loader)
- Records a namespace-specific mapping between element names and
classes.
setDefaultNamespace
public void setDefaultNamespace(java.lang.String ns)
- Defines a URI to be treated as the "default" namespace. This
is used only when choosing element classes, and may not be
visible when instances are asked for their namespaces.
map2Class
private java.lang.Class map2Class(java.lang.String key, java.util.Dictionary node2class, java.lang.ClassLoader loader)
doMap
private ElementNode doMap(java.lang.String tagName, java.util.Dictionary node2class, java.lang.ClassLoader loader)
createElementEx
public ElementEx createElementEx(java.lang.String namespace, java.lang.String tag)
- Creates an element by using the mapping associated with the
specified namespace, or the default namespace as appropriate.
If no mapping associated with that namespace is defined, then
the default mapping is used.
- Specified by:
createElementEx
in interfaceElementFactory
createElementEx
public ElementEx createElementEx(java.lang.String tag)
- Creates an element by using the default mapping.
- Specified by:
createElementEx
in interfaceElementFactory
getMessage
java.lang.String getMessage(java.lang.String messageId)
getMessage
java.lang.String getMessage(java.lang.String messageId, java.lang.Object[] parameters)
|
|||||||||
Home >> All >> org >> apache >> xerces >> [ tree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |