public class NameMap extends java.lang.Object implements ConfigElement
mapXML()
method.Modifier and Type | Class and Description |
---|---|
static class |
NameMap.AttrMap
"Read-only" class for examining a single attribute mapping.
|
static class |
NameMap.ClassMap
"Read-only" class for examining the class mappings
for a
NameMap instance. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANY_CLASS
Special class name used to specify "any class" for attributes that should
be mapped regardless of class.
|
static java.lang.String |
ATTR_ATTR_NAME
Name for XML attribute 'attr-name'.
|
static java.lang.String |
ATTR_CLASS_NAME
Name for XML attribute 'class-name'.
|
static int |
FROM_APP
Parameter for
mapXML() , specifying document to be mapped is being received
from the application shim. |
static java.lang.String |
TAG_APP_NAME
Tag name for XML element 'app-name'.
|
static java.lang.String |
TAG_ATTR_NAME
Tag name for XML element 'attr-name'.
|
static java.lang.String |
TAG_ATTR_NAME_MAP
Tag name for XML element 'attr-name-map'.
|
static java.lang.String |
TAG_CLASS_NAME
Tag name for XML element 'class-name'.
|
static java.lang.String |
TAG_NDS_NAME
Tag name for XML element 'nds-name'.
|
static int |
TO_APP
Parameter for
mapXML() , specifying document to be mapped is being sent
to the application shim. |
Constructor and Description |
---|
NameMap()
Create an empty
NameMap instance. |
NameMap(org.w3c.dom.Element element)
Construct a
NameMap instance from an XML representation. |
Modifier and Type | Method and Description |
---|---|
void |
addAttrMapping(java.lang.String classNdsName,
java.lang.String attrNdsName,
java.lang.String attrAppName)
Add a mapping for an attribute.
|
void |
addClassMapping(java.lang.String ndsName,
java.lang.String appName)
Add a mapping for a class.
|
NameMap.ClassMap |
getClassMap(java.lang.String ndsName)
Get a read-only object for a class that indicates the class and attribute name mappings.
|
boolean |
hasBeenModified()
Return
true if this instance has been modified. |
java.util.Iterator |
iterator()
Get an
Iterator that will iterate through the class and attribute mappings in
this instance. |
java.lang.String |
mapAppAttrName(java.lang.String appAttrName,
java.lang.String appClassName)
Map an application attribute name into the corresponding name in the "nds" or "DirXML"
namespace.
|
java.lang.String |
mapAppClassName(java.lang.String appClassName)
Map an application class name to the corresponding name in the "nds" or "DirXML"
namespace.
|
java.lang.String |
mapNdsAttrName(java.lang.String ndsAttrName,
java.lang.String ndsClassName)
Map an attribute name in the "nds" or "DirXML" namespace into the corresponding name in application
namespace.
|
java.lang.String |
mapNdsClassName(java.lang.String ndsClassName)
Map an nds or dirxml class name to the corresponding application class name.
|
void |
mapXML(org.w3c.dom.Node parent,
int direction)
Map an XML document subtree.
|
void |
removeAttrMapping(java.lang.String classNdsName,
java.lang.String attrNdsName)
Remove an attribute mapping.
|
void |
removeClassMapping(java.lang.String ndsName)
Remove a mapping for a class.
|
void |
resetModified()
Reset the modified flag for this instance such that
hasBeenModified()
will return false . |
org.w3c.dom.Element |
toXML(org.w3c.dom.Node parent)
Create an XML representation of this
NameMap instance. |
public static final int TO_APP
mapXML()
, specifying document to be mapped is being sent
to the application shim.public static final int FROM_APP
mapXML()
, specifying document to be mapped is being received
from the application shim.public static final java.lang.String TAG_ATTR_NAME_MAP
public static final java.lang.String TAG_CLASS_NAME
public static final java.lang.String TAG_ATTR_NAME
public static final java.lang.String TAG_NDS_NAME
public static final java.lang.String TAG_APP_NAME
public static final java.lang.String ATTR_CLASS_NAME
public static final java.lang.String ATTR_ATTR_NAME
public static final java.lang.String ANY_CLASS
public NameMap()
NameMap
instance.public NameMap(org.w3c.dom.Element element) throws XMLException
NameMap
instance from an XML representation.element
- <attr-name-map> element containing XML representationXMLException
- if the XML representation is somehow invalid.public boolean hasBeenModified()
true
if this instance has been modified.
The instance is considered to have been modified if a change was made
that affects the persistent representation since:
resetModified()
was last calledhasBeenModified
in interface ConfigElement
true
or false
resetModified()
,
toXML(org.w3c.dom.Node)
public void resetModified()
hasBeenModified()
will return false
.resetModified
in interface ConfigElement
hasBeenModified()
public void addClassMapping(java.lang.String ndsName, java.lang.String appName) throws java.lang.IllegalArgumentException
ndsName
- name of class in "nds" or "DirXML" spaceappName
- name of class in application spacejava.lang.IllegalArgumentException
- if the parameter ndsName
is null
, empty,
or equal to ANY_CLASS
.public void removeClassMapping(java.lang.String ndsName) throws java.lang.IllegalArgumentException
ndsName
- name of class in "nds" or "DirXML" spacejava.lang.IllegalArgumentException
- if the parameter ndsName
is null
, empty,
or equal to ANY_CLASS
.public void addAttrMapping(java.lang.String classNdsName, java.lang.String attrNdsName, java.lang.String attrAppName) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
ANY_CLASS
for
the classNdsName
parameter.
If the specified mapping already exists, no action is taken.
The if classNdsName
is not ANY_CLASS
the class mapping must already exist.classNdsName
- name of class in "nds" or "DirXML" space, or ANY_CLASS
attrNdsName
- name of attribute in "nds" or "DirXML" spaceattrAppName
- name of attribute in application spacejava.lang.IllegalArgumentException
- if classNdsName
is null
or empty,
or either attrNdsName
or attrAppName
is null
or emptyjava.lang.IllegalStateException
- if a class mapping for classNdsName
doesn't existpublic void removeAttrMapping(java.lang.String classNdsName, java.lang.String attrNdsName) throws java.lang.IllegalArgumentException
ANY_CLASS
as the classNdsName
value.classNdsName
- name of class in "nds" or "DirXML" space, or ANY_CLASS
attrNdsName
- name of attribute in "nds" or "DirXML" spacejava.lang.IllegalArgumentException
- if classNdsName
is null
or empty,
or attrNdsName
is null
or emptypublic NameMap.ClassMap getClassMap(java.lang.String ndsName) throws java.lang.IllegalArgumentException
ANY_CLASS
for the ndsName
parameter value.ndsName
- name of class in "nds" or "DirXML" space, or ANY_CLASS
null
if there is no mapping for the passed namejava.lang.IllegalArgumentException
- if ndsName
is null or emptypublic java.lang.String mapAppClassName(java.lang.String appClassName) throws java.lang.IllegalArgumentException
appClassName
- name of application class (may not be null
)java.lang.IllegalArgumentException
- if appClassName
is null
or emptypublic java.lang.String mapAppAttrName(java.lang.String appAttrName, java.lang.String appClassName)
appClassName
is null
or empty then ANY_CLASS
is used as the class name.appAttrName
- attribute name in the application namespaceappClassName
- class name to use for class-specific mapping (may be null
)null
if no mapping existspublic java.lang.String mapNdsClassName(java.lang.String ndsClassName) throws java.lang.IllegalArgumentException
ndsClassName
- name of application class (may not be null)java.lang.IllegalArgumentException
- if ndsClassName
is null or emptypublic java.lang.String mapNdsAttrName(java.lang.String ndsAttrName, java.lang.String ndsClassName)
ndsClassName
is null
or empty then ANY_CLASS
is used as the class name.ndsAttrName
- attribute name in the "nds" or "DirXML" namespacendsClassName
- class name to use for class-specific mapping (may be null
)null
if no mapping existspublic java.util.Iterator iterator()
Iterator
that will iterate through the class and attribute mappings in
this instance.
The Iterator
's next()
method will return ClassMap
instances.NameMap.ClassMap
public org.w3c.dom.Element toXML(org.w3c.dom.Node parent)
NameMap
instance.
Note that the act of creating an XML representation does not reset this instance's
modified flag. It must be reset by calling resetModified()
.toXML
in interface ConfigElement
parent
- Node
under which to create XML representationhasBeenModified()
,
resetModified()
public void mapXML(org.w3c.dom.Node parent, int direction) throws java.lang.IllegalArgumentException
parent
- root of subtree to mapdirection
- TO_APP
or FROM_APP
java.lang.IllegalArgumentException
- if direction isn't one of TO_APP
or FROM_APP