GXPARSE hosted by SourceForge.net Logo

ca.gorman.xml.parse.util
Class PackageNamespaceElementMapper.NamespaceEntry<T extends Parser>

java.lang.Object
  extended by ca.gorman.xml.parse.util.PackageNamespaceElementMapper.NamespaceEntry<T>
Enclosing class:
PackageNamespaceElementMapper<T extends Parser>

public static class PackageNamespaceElementMapper.NamespaceEntry<T extends Parser>
extends Object

Associates an XML namespace with a Java package and the information needed to map element names in that namespace to element handler classes in the package.

The element local name is mapped to a Java object identifier by replacing XML name characters when the characters are not valid as part of a Java identifier.

The replacement of a character is a string that begins with an escape character. The escape character must be a Java identifier start character, and defaults to the dollar sign ($). The mapping from an XML name character to a string is:

 If the character is the escape character, double it
 else if the character is a java identifier start character, copy it
 else if not at the start of the identifier and the character is a
                  java identifier part character, copy it
 else output the escape character, a lower case 'u', and a four-digit
              lower-case hexadecimal representation of the unicode number.
 
The mapping increases the length of the name, because escape characters in the XML name become two characters in the Java name, and XML characters that are not allowed in a Java name become six characters.

The concatenation of the package name and the new Java identifier are used as the Java class name of element handler. If the handler does not exist, the default handler for the namespace will be used instead.


Constructor Summary
  PackageNamespaceElementMapper.NamespaceEntry(QName namespace, String packageName, ElementListener<T> namespaceDefaultElementHandler, String classNamePrefix)
           Construct a package and default handler entry for a single namespace.
protected PackageNamespaceElementMapper.NamespaceEntry(QName namespace, String packageName, ElementListener<T> namespaceDefaultElementHandler, String classNamePrefix, char escapeChar)
           Construct a package and default handler entry for a single namespace.
 
Method Summary
 String getClassNamePrefix()
           
 ElementListener<T> getNamespaceDefaultElementHandler()
           
 String getNamespaceURI()
           
 String getPackageName()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackageNamespaceElementMapper.NamespaceEntry

protected PackageNamespaceElementMapper.NamespaceEntry(QName namespace,
                                                       String packageName,
                                                       ElementListener<T> namespaceDefaultElementHandler,
                                                       String classNamePrefix,
                                                       char escapeChar)

Construct a package and default handler entry for a single namespace.

Parameters:
namespace - XML namespace (only the URI is used).
packageName - the name of the package that holds the element handlers for the namespace
namespaceDefaultElementHandler - a default element handler with a public constructor that takes no parameters. The default handler is invoked when an element is in the namespace and the package does not have a specific handler for that element.
classNamePrefix - a prefix attached to all element names prior to constructing a Java class name, may be an empty String
escapeChar - Escape character to identify encoding of a element name character as a four-digit hexadecimal encoding. Must be a Java identifier start character.
Throws:
NullPointerException - if any reference parameter is null
IllegalArgumentException - if package packageName does not exist or is not accessible, or if escapeChar is not a Java identifier start character.

PackageNamespaceElementMapper.NamespaceEntry

public PackageNamespaceElementMapper.NamespaceEntry(QName namespace,
                                                    String packageName,
                                                    ElementListener<T> namespaceDefaultElementHandler,
                                                    String classNamePrefix)

Construct a package and default handler entry for a single namespace.

Uses the dollar symbol as the escape character to identify hexadecimal encoding of an element name character.

Parameters:
namespace - XML namespace (only the URI is used).
packageName - the name of the package that holds the element handlers for the namespace
namespaceDefaultElementHandler - a default element handler with a public constructor that takes no parameters. The default handler is invoked when an element is in the namespace and the package does not have a specific handler for that element.
classNamePrefix - a prefix attached to all element names prior to constructing a Java class name, may be an empty String
Throws:
NullPointerException - if any parameter is null
IllegalArgumentException - if package packageName does not exist or is not accessible.
Method Detail

getNamespaceURI

public String getNamespaceURI()

getPackageName

public String getPackageName()

getClassNamePrefix

public String getClassNamePrefix()

getNamespaceDefaultElementHandler

public ElementListener<T> getNamespaceDefaultElementHandler()

toString

public String toString()
Overrides:
toString in class Object

GXPARSE download

GXPARSE Generic XML Stream Parser API and supporting tools.   Release $Name: gxparse-sf-alpha-2_0 $
Copyright 2003-2004 Ian E. Gorman
Released under GNU Lesser General Public License