com.novell.nds.dirxml.shimhost
Class Filter

java.lang.Object
  extended bycom.novell.nds.dirxml.shimhost.Filter
All Implemented Interfaces:
ConfigElement

public class Filter
extends Object
implements ConfigElement

Class holding DirXML filter information for a shim.

Note that class names and attribute names are treated as case-insenstive.


Nested Class Summary
static class Filter.FilterAttr
          Class representing a <filter-attr> element.
static class Filter.FilterClass
          Class representing a <filter-class> element.
static class Filter.FilterItem
          Base class for FilterClass and FilterAttr classes.
 
Field Summary
static String ATTR_ATTR_NAME
          Name of the XML 'attr-name' attribute.
static String ATTR_CLASS_NAME
          Name of the XML 'class-name' attribute.
static String ATTR_MERGE_AUTHORITY
          Name of the XML 'merge-authority' attribute.
static String ATTR_PUBLISHER
          Name of the XML 'publisher' attribute.
static String ATTR_PUBLISHER_CREATE_HOMEDIR
          Name of the XML 'publisher-create-homedir' attribute.
static String ATTR_PUBLISHER_OPTIMIZE_MODIFY
          Name of the XML 'publisher-optimize-modify' attribute.
static String ATTR_PUBLISHER_TRACK_TEMPLATE_MEMBER
          Name of the XML 'publisher-track-template-member' attribute.
static String ATTR_SUBSCRIBER
          Name of the XML 'subscriber' attribute.
static int MERGE_APP
          Constant representing the "app" value for the 'merge-authority' attribute on <filter-attr> elements.
static int MERGE_DEFAULT
          Constant representing the "default" value for the 'merge-authority' attribute on <filter-attr> elements.
static int MERGE_EDIR
          Constant representing the "edir" value for the 'merge-authority' attribute on <filter-attr> elements.
static int MERGE_NONE
          Constant representing the "none" value for the 'merge-authority' attribute on <filter-attr> elements.
static int PUB
          Constant representing the Publisher channel.
static int SUB
          Constant representing the Subscriber channel.
static int SYNC_IGNORE
          Constant representing the "ignore" value for the 'subscriber' and 'publisher' attributes on <filter-class> and <filter-attr> elements.
static int SYNC_NOTIFY
          Constant representing the "notify" value for the 'subscriber' and 'publisher' attributes on <filter-attr> elements.
static int SYNC_RESET
          Constant representing the "reset" value for the 'subscriber' and 'publisher' attributes on <filter-attr> elements.
static int SYNC_SYNC
          Constant representing the "sync" value for the 'subscriber' and 'publisher' attributes on <filter-class> and <filter-attr> elements.
static String TAG_FILTER
          Tag name of the <filter> element.
static String TAG_FILTER_ATTR
          Tag name of the <filter-attr> element.
static String TAG_FILTER_CLASS
          Tag name of the <filter-class> element.
static String VAL_FALSE
          "false"
static String VAL_TRUE
          "true"
 
Constructor Summary
Filter()
          Create a new, empty Filter instance.
Filter(Element filterElement)
          Create a Filter object from an XML representation.
Filter(Filter source)
          Construct a new Filter based on an existing Filter.
 
Method Summary
static boolean getBoolean(String string)
          Get the boolean value corresponding to an XML attribute string value.
static String getBooleanString(boolean value)
          Get the XML attribute string value for a boolean value.
 Filter.FilterClass getFilterClass(String className)
          Get the FilterClass instance for a class in this Filter instance if it exists.
static int getMergeAuthorityInt(String string)
          Get the sync mode constant corresponding to the passed merge authority string (XML attribute value).
static String getMergeAuthorityString(int auth)
          Get the XML attribute value given a merge authority constant (MERGE_EDIR, MERGE_APP, etc.)
static int getSyncModeInt(String string)
          Get the sync mode constant corresponding to the passed sync mode string (XML attribute value).
static String getSyncModeString(int mode)
          Get the XML attribute value given a sync mode constant (SYNC_SYNC, SYNC_IGNORE, etc.)
 boolean hasBeenModified()
          Return true if this instance has been modified.
 Iterator iterator()
          Get an Iterator that returns the FilterClass instances in this Filter.
 Filter.FilterClass newFilterClass(String className)
          Create a new entry in this Filter instance for a class, if such an entry doesn't already exist.
 Filter.FilterClass removeFilterClass(String className)
          Remove the entry for a class from this Filter instance if it exists.
 void resetModified()
          Reset the modified flag for this instance such that hasBeenModified() will return false.
 Element toV1FilterXML(Node parent, int channel)
          Construct a DirXML 1.x representation of the filter for the passed channel.
 Element toXML(Node parent)
          Create an XML representation for this Filter object under the passed Node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUB

public static final int SUB
Constant representing the Subscriber channel. Used as a parameter to FilterItem.getSyncMode(), FilterItem.setSyncMode() and toV1FilterXML().

See Also:
Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), toV1FilterXML(org.w3c.dom.Node, int), Constant Field Values

PUB

public static final int PUB
Constant representing the Publisher channel. Used as a parameter to FilterItem.getSyncMode(), FilterItem.setSyncMode() and toV1FilterXML().

See Also:
Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), toV1FilterXML(org.w3c.dom.Node, int), Constant Field Values

SYNC_SYNC

public static final int SYNC_SYNC
Constant representing the "sync" value for the 'subscriber' and 'publisher' attributes on <filter-class> and <filter-attr> elements. Used with getSyncModeString(), getSyncModeInt(), FilterItem.getSyncMode(), and FilterItem.setSyncMode().

See Also:
getSyncModeString(int), getSyncModeInt(java.lang.String), Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), Constant Field Values

SYNC_RESET

public static final int SYNC_RESET
Constant representing the "reset" value for the 'subscriber' and 'publisher' attributes on <filter-attr> elements. Used with getSyncModeString(), getSyncModeInt(), FilterItem.getSyncMode(), and FilterItem.setSyncMode().

See Also:
getSyncModeString(int), getSyncModeInt(java.lang.String), Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), Constant Field Values

SYNC_NOTIFY

public static final int SYNC_NOTIFY
Constant representing the "notify" value for the 'subscriber' and 'publisher' attributes on <filter-attr> elements. Used with getSyncModeString(), getSyncModeInt(), FilterItem.getSyncMode(), and FilterItem.setSyncMode().

See Also:
getSyncModeString(int), getSyncModeInt(java.lang.String), Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), Constant Field Values

SYNC_IGNORE

public static final int SYNC_IGNORE
Constant representing the "ignore" value for the 'subscriber' and 'publisher' attributes on <filter-class> and <filter-attr> elements. Used with getSyncModeString(), getSyncModeInt(), FilterItem.getSyncMode(), and FilterItem.setSyncMode().

See Also:
getSyncModeString(int), getSyncModeInt(java.lang.String), Filter.FilterItem.getSyncMode(int), Filter.FilterItem.setSyncMode(int, int), Constant Field Values

MERGE_DEFAULT

public static final int MERGE_DEFAULT
Constant representing the "default" value for the 'merge-authority' attribute on <filter-attr> elements. Used with getMergeAuthorityString(), getMergeAuthorityInt(), FilterAttr.getMergeAuthority(), and FilterAttr.setMergeAuthority().

See Also:
getMergeAuthorityString(int), getMergeAuthorityInt(java.lang.String), Filter.FilterAttr.getMergeAuthority(), Filter.FilterAttr.setMergeAuthority(int), Constant Field Values

MERGE_EDIR

public static final int MERGE_EDIR
Constant representing the "edir" value for the 'merge-authority' attribute on <filter-attr> elements. Used with getMergeAuthorityString(), getMergeAuthorityInt(), FilterAttr.getMergeAuthority(), and FilterAttr.setMergeAuthority().

See Also:
getMergeAuthorityString(int), getMergeAuthorityInt(java.lang.String), Filter.FilterAttr.getMergeAuthority(), Filter.FilterAttr.setMergeAuthority(int), Constant Field Values

MERGE_APP

public static final int MERGE_APP
Constant representing the "app" value for the 'merge-authority' attribute on <filter-attr> elements. Used with getMergeAuthorityString(), getMergeAuthorityInt(), FilterAttr.getMergeAuthority(), and FilterAttr.setMergeAuthority().

See Also:
getMergeAuthorityString(int), getMergeAuthorityInt(java.lang.String), Filter.FilterAttr.getMergeAuthority(), Filter.FilterAttr.setMergeAuthority(int), Constant Field Values

MERGE_NONE

public static final int MERGE_NONE
Constant representing the "none" value for the 'merge-authority' attribute on <filter-attr> elements. Used with getMergeAuthorityString(), getMergeAuthorityInt(), FilterAttr.getMergeAuthority(), and FilterAttr.setMergeAuthority().

See Also:
getMergeAuthorityString(int), getMergeAuthorityInt(java.lang.String), Filter.FilterAttr.getMergeAuthority(), Filter.FilterAttr.setMergeAuthority(int), Constant Field Values

TAG_FILTER

public static final String TAG_FILTER
Tag name of the <filter> element.

See Also:
Constant Field Values

TAG_FILTER_CLASS

public static final String TAG_FILTER_CLASS
Tag name of the <filter-class> element.

See Also:
Constant Field Values

TAG_FILTER_ATTR

public static final String TAG_FILTER_ATTR
Tag name of the <filter-attr> element.

See Also:
Constant Field Values

ATTR_CLASS_NAME

public static final String ATTR_CLASS_NAME
Name of the XML 'class-name' attribute.

See Also:
Constant Field Values

ATTR_ATTR_NAME

public static final String ATTR_ATTR_NAME
Name of the XML 'attr-name' attribute.

See Also:
Constant Field Values

ATTR_PUBLISHER

public static final String ATTR_PUBLISHER
Name of the XML 'publisher' attribute.

See Also:
Constant Field Values

ATTR_SUBSCRIBER

public static final String ATTR_SUBSCRIBER
Name of the XML 'subscriber' attribute.

See Also:
Constant Field Values

ATTR_PUBLISHER_CREATE_HOMEDIR

public static final String ATTR_PUBLISHER_CREATE_HOMEDIR
Name of the XML 'publisher-create-homedir' attribute.

See Also:
Constant Field Values

ATTR_PUBLISHER_TRACK_TEMPLATE_MEMBER

public static final String ATTR_PUBLISHER_TRACK_TEMPLATE_MEMBER
Name of the XML 'publisher-track-template-member' attribute.

See Also:
Constant Field Values

ATTR_MERGE_AUTHORITY

public static final String ATTR_MERGE_AUTHORITY
Name of the XML 'merge-authority' attribute.

See Also:
Constant Field Values

ATTR_PUBLISHER_OPTIMIZE_MODIFY

public static final String ATTR_PUBLISHER_OPTIMIZE_MODIFY
Name of the XML 'publisher-optimize-modify' attribute.

See Also:
Constant Field Values

VAL_TRUE

public static final String VAL_TRUE
"true"

See Also:
Constant Field Values

VAL_FALSE

public static final String VAL_FALSE
"false"

See Also:
Constant Field Values
Constructor Detail

Filter

public Filter()
Create a new, empty Filter instance.


Filter

public Filter(Filter source)
Construct a new Filter based on an existing Filter.

Parameters:
source - Filter on which to base new instance

Filter

public Filter(Element filterElement)
       throws XMLException
Create a Filter object from an XML representation.

Parameters:
filterElement - <filter> element containing representation
Throws:
XMLException - if XML representation is incorrect in some way
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()

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()

iterator

public Iterator iterator()
Get an Iterator that returns the FilterClass instances in this Filter.

Returns:
Iterator that returns FilterClass instances

getFilterClass

public Filter.FilterClass getFilterClass(String className)
Get the FilterClass instance for a class in this Filter instance if it exists.

Parameters:
className - name of class
Returns:
FilterClass instance, or null

newFilterClass

public Filter.FilterClass newFilterClass(String className)
Create a new entry in this Filter instance for a class, if such an entry doesn't already exist.

Parameters:
className - name of class
Returns:
new or existing FilterClass instance

removeFilterClass

public Filter.FilterClass removeFilterClass(String className)
Remove the entry for a class from this Filter instance if it exists.

Parameters:
className - name of class
Returns:
FilterClass instance or null

toXML

public Element toXML(Node parent)
Create an XML representation for this Filter object under the passed Node.

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 construct XML representation.
Returns:
created <filter> element
See Also:
hasBeenModified(), resetModified()

toV1FilterXML

public Element toV1FilterXML(Node parent,
                             int channel)
Construct a DirXML 1.x representation of the filter for the passed channel. Designed primarily for use in building shim initialization documents.

Parameters:
parent - Node under which to construct XML representation
channel - SUB or PUB
Returns:
created <>driver-filter> element

getSyncModeString

public static String getSyncModeString(int mode)
                                throws IllegalArgumentException
Get the XML attribute value given a sync mode constant (SYNC_SYNC, SYNC_IGNORE, etc.)

Parameters:
mode - SYNC_SYNC, SYNC_NOTIFY, SYNC_RESET, SYNC_IGNORE
Returns:
String containing the XML attribute value corresponding to the passed constant ("sync", "notify", "reset", "ignore")
Throws:
IllegalArgumentException - if mode isn't a correct value

getSyncModeInt

public static int getSyncModeInt(String string)
                          throws IllegalArgumentException
Get the sync mode constant corresponding to the passed sync mode string (XML attribute value).

Parameters:
string - XML attribute value ("sync", "notify", "reset", "ignore")
Returns:
SYNC_SYNC, SYNC_NOTIFY, SYNC_RESET, SYNC_IGNORE
Throws:
IllegalArgumentException - if string parameter is incorrect

getMergeAuthorityString

public static String getMergeAuthorityString(int auth)
                                      throws IllegalArgumentException
Get the XML attribute value given a merge authority constant (MERGE_EDIR, MERGE_APP, etc.)

Parameters:
auth - MERGE_DEFAULT, MERGE_NONE, MERGE_EDIR, MERGE_APP
Returns:
String containing the XML attribute value corresponding to the passed constant ("default", "none", "edir", "app")
Throws:
IllegalArgumentException - if auth isn't a correct value

getMergeAuthorityInt

public static int getMergeAuthorityInt(String string)
                                throws IllegalArgumentException
Get the sync mode constant corresponding to the passed merge authority string (XML attribute value).

Parameters:
string - XML attribute value ("default", "none", "edir", "app")
Returns:
MERGE_DEFAULT, MERGE_NONE, MERGE_EDIR, MERGE_APP
Throws:
IllegalArgumentException - if string parameter is incorrect

getBooleanString

public static String getBooleanString(boolean value)
Get the XML attribute string value for a boolean value.

Parameters:
value - true or false
Returns:
"true" or "false"

getBoolean

public static boolean getBoolean(String string)
                          throws IllegalArgumentException
Get the boolean value corresponding to an XML attribute string value.

Parameters:
string - "true" or "false"
Returns:
true or false
Throws:
IllegalArgumentException - if string parameter isn't one of "true" or "false"