Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.novell.nds.dirxml.shimhost
Class NameMap

    java.lang.Object
      com.novell.nds.dirxml.shimhost.NameMap

All Implemented Interfaces:
  ConfigElement

    public class NameMap

extends Object
implements ConfigElement

Class encapsulating DirXML Mapping Rule functionality.

This class can read and write an XML representation of the DirXML Mapping Rule and can be examined and edited programmatically.

To map the class names and attribute names in an XML document use the `mapXML()` method.

Nested Class Summary
`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.

Field Summary
`static String` | `ANY_CLASS` Special class name used to specify "any class" for attributes that should be mapped regardless of class.
`static String` | `ATTR_ATTR_NAME` Name for XML attribute 'attr-name'.
`static 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 String` | `TAG_APP_NAME` Tag name for XML element 'app-name'.
`static String` | `TAG_ATTR_NAME` Tag name for XML element 'attr-name'.
`static String` | `TAG_ATTR_NAME_MAP` Tag name for XML element 'attr-name-map'.
`static String` | `TAG_CLASS_NAME` Tag name for XML element 'class-name'.
`static 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 Summary
`NameMap()` Create an empty `NameMap` instance.
`NameMap(Element element)` Construct a `NameMap` instance from an XML representation.

Method Summary
`void` | `addAttrMapping(String classNdsName, String attrNdsName, String attrAppName)` Add a mapping for an attribute.
`void` | `addClassMapping(String ndsName, String appName)` Add a mapping for a class.
`NameMap.ClassMap` | `getClassMap(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.
`Iterator` | `iterator()` Get an `Iterator` that will iterate through the class and attribute mappings in this instance.
`String` | `mapAppAttrName(String appAttrName, String appClassName)` Map an application attribute name into the corresponding name in the "nds" or "DirXML" namespace.
`String` | `mapAppClassName(String appClassName)` Map an application class name to the corresponding name in the "nds" or "DirXML" namespace.
`String` | `mapNdsAttrName(String ndsAttrName, String ndsClassName)` Map an attribute name in the "nds" or "DirXML" namespace into the corresponding name in application namespace.
`String` | `mapNdsClassName(String ndsClassName)` Map an nds or dirxml class name to the corresponding application class name.
`void` | `mapXML(Node parent, int direction)` Map an XML document subtree.
`void` | `removeAttrMapping(String classNdsName, String attrNdsName)` Remove an attribute mapping.
`void` | `removeClassMapping(String ndsName)` Remove a mapping for a class.
`void` | `resetModified()` Reset the modified flag for this instance such that `hasBeenModified()` will return `false`.
`Element` | `toXML(Node parent)` Create an XML representation of this `NameMap` instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TO_APP

    public static final int TO_APP

  Parameter for `mapXML()`, specifying document to be mapped is being sent to the application shim.

  See Also:
    `mapXML(org.w3c.dom.Node, int)`, Constant Field Values

### FROM_APP

    public static final int FROM_APP

  Parameter for `mapXML()`, specifying document to be mapped is being received from the application shim.

  See Also:
    `mapXML(org.w3c.dom.Node, int)`, Constant Field Values

### TAG_ATTR_NAME_MAP

    public static final String TAG_ATTR_NAME_MAP

  Tag name for XML element 'attr-name-map'.

  See Also:
    Constant Field Values

### TAG_CLASS_NAME

    public static final String TAG_CLASS_NAME

  Tag name for XML element 'class-name'.

  See Also:
    Constant Field Values

### TAG_ATTR_NAME

    public static final String TAG_ATTR_NAME

  Tag name for XML element 'attr-name'.

  See Also:
    Constant Field Values

### TAG_NDS_NAME

    public static final String TAG_NDS_NAME

  Tag name for XML element 'nds-name'.

  See Also:
    Constant Field Values

### TAG_APP_NAME

    public static final String TAG_APP_NAME

  Tag name for XML element 'app-name'.

  See Also:
    Constant Field Values

### ATTR_CLASS_NAME

    public static final String ATTR_CLASS_NAME

  Name for XML attribute 'class-name'.

  See Also:
    Constant Field Values

### ATTR_ATTR_NAME

    public static final String ATTR_ATTR_NAME

  Name for XML attribute 'attr-name'.

  See Also:
    Constant Field Values

### ANY_CLASS

    public static final String ANY_CLASS

  Special class name used to specify "any class" for attributes that should be mapped regardless of class.

  See Also:
    Constant Field Values

Constructor Detail

### NameMap

    public NameMap()

  Create an empty `NameMap` instance.

### NameMap

    public NameMap(Element element)
            throws XMLException

  Construct a `NameMap` instance from an XML representation.

  Parameters:
    `element` - <attr-name-map> element containing XML representation
  Throws:
    `XMLException` - if the XML representation is somehow invalid.

Method Detail

### hasBeenModified

    public boolean hasBeenModified()

  Return `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:

  1. The instance was constructed from an XML representation.
  2. `resetModified()` was last called

  Specified by:
    `hasBeenModified` in interface `ConfigElement`
  Returns:
    `true` or `false`
  See Also:
    `resetModified()`, `toXML(org.w3c.dom.Node)`

### resetModified

    public void resetModified()

  Reset the modified flag for this instance such that `hasBeenModified()` will return `false`.

  Specified by:
    `resetModified` in interface `ConfigElement`
  See Also:
    `hasBeenModified()`

### addClassMapping

    public void addClassMapping(String ndsName,
                                String appName)
                         throws IllegalArgumentException

  Add a mapping for a class. If the mapping already exists nothing is changed.

  Parameters:
    `ndsName` - name of class in "nds" or "DirXML" space
    `appName` - name of class in application space
  Throws:
    `IllegalArgumentException` - if the parameter `ndsName` is `null`, empty, or equal to `ANY_CLASS`.

### removeClassMapping

    public void removeClassMapping(String ndsName)
                            throws IllegalArgumentException

  Remove a mapping for a class. If the mapping does not exist no action is taken.

  Parameters:
    `ndsName` - name of class in "nds" or "DirXML" space
  Throws:
    `IllegalArgumentException` - if the parameter `ndsName` is `null`, empty, or equal to `ANY_CLASS`.

### addAttrMapping

    public void addAttrMapping(String classNdsName,
                               String attrNdsName,
                               String attrAppName)
                        throws IllegalArgumentException,
                               IllegalStateException

  Add a mapping for an attribute. The mapping may be class-specific, or may apply to all classes. To create a non-class-specific mapping, pass `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.

  Parameters:
    `classNdsName` - name of class in "nds" or "DirXML" space, or `ANY_CLASS`
    `attrNdsName` - name of attribute in "nds" or "DirXML" space
    `attrAppName` - name of attribute in application space
  Throws:
    `IllegalArgumentException` - if `classNdsName` is `null` or empty, or either `attrNdsName` or `attrAppName` is `null` or empty
    `IllegalStateException` - if a class mapping for `classNdsName` doesn't exist

### removeAttrMapping

    public void removeAttrMapping(String classNdsName,
                                  String attrNdsName)
                           throws IllegalArgumentException

  Remove an attribute mapping. If the specified mapping doesn't exist, no action is taken.

  To remove a non-class-specific mapping use `ANY_CLASS` as the `classNdsName` value.

  Parameters:
    `classNdsName` - name of class in "nds" or "DirXML" space, or `ANY_CLASS`
    `attrNdsName` - name of attribute in "nds" or "DirXML" space
  Throws:
    `IllegalArgumentException` - if `classNdsName` is `null` or empty, or `attrNdsName` is `null` or empty

### getClassMap

    public NameMap.ClassMap getClassMap(String ndsName)
                                 throws IllegalArgumentException

  Get a read-only object for a class that indicates the class and attribute name mappings.

  To get the non-class-specific attribute mappings specify `ANY_CLASS` for the ndsName parameter value.

  Parameters:
    `ndsName` - name of class in "nds" or "DirXML" space, or `ANY_CLASS`
  Returns:
    object containing mappings, or `null` if there is no mapping for the passed name
  Throws:
    `IllegalArgumentException` - if `ndsName` is null or empty

### mapAppClassName

    public String mapAppClassName(String appClassName)
                           throws IllegalArgumentException

  Map an application class name to the corresponding name in the "nds" or "DirXML" namespace.

  Parameters:
    `appClassName` - name of application class (may not be `null`)
  Returns:
    name of class in nds or DirXML space, or null if no mapping exists.
  Throws:
    `IllegalArgumentException` - if `appClassName` is `null` or empty

### mapAppAttrName

    public String mapAppAttrName(String appAttrName,
                                 String appClassName)

  Map an application attribute name into the corresponding name in the "nds" or "DirXML" namespace.

  If `appClassName` is `null` or empty then `ANY_CLASS` is used as the class name.

  Parameters:
    `appAttrName` - attribute name in the application namespace
    `appClassName` - class name to use for class-specific mapping (may be `null`)
  Returns:
    attribute name in "nds" or "DirXML" namespace, or `null` if no mapping exists

### mapNdsClassName

    public String mapNdsClassName(String ndsClassName)
                           throws IllegalArgumentException

  Map an nds or dirxml class name to the corresponding application class name.

  Parameters:
    `ndsClassName` - name of application class (may not be null)
  Returns:
    name of class in application space, or null if no mapping exists.
  Throws:
    `IllegalArgumentException` - if `ndsClassName` is null or empty

### mapNdsAttrName

    public String mapNdsAttrName(String ndsAttrName,
                                 String ndsClassName)

  Map an attribute name in the "nds" or "DirXML" namespace into the corresponding name in application namespace.

  If `ndsClassName` is `null` or empty then `ANY_CLASS` is used as the class name.

  Parameters:
    `ndsAttrName` - attribute name in the "nds" or "DirXML" namespace
    `ndsClassName` - class name to use for class-specific mapping (may be `null`)
  Returns:
    attribute name in application namespace, or `null` if no mapping exists

### iterator

    public Iterator iterator()

  Get an `Iterator` that will iterate through the class and attribute mappings in this instance.

  The `Iterator`'s `next()` method will return `ClassMap` instances.

  Returns:
    iterator
  See Also:
    `NameMap.ClassMap`

### toXML

    public Element toXML(Node parent)

  Create an XML representation of this `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()`.

  Specified by:
    `toXML` in interface `ConfigElement`
  Parameters:
    `parent` - `Node` under which to create XML representation
  Returns:
    created <attr-name-map> element
  See Also:
    `hasBeenModified()`, `resetModified()`

### mapXML

    public void mapXML(Node parent,
                       int direction)
                throws IllegalArgumentException

  Map an XML document subtree. This potentially maps all 'class-name' and 'attr-name' XML attribute values.

  Parameters:
    `parent` - root of subtree to map
    `direction` - `TO_APP` or `FROM_APP`
  Throws:
    `IllegalArgumentException` - if direction isn't one of `TO_APP` or `FROM_APP`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD