com.novell.nds.dirxml.shimhost
Class ShimConfigParams

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

public class ShimConfigParams
extends Object
implements ConfigElement

Encapsulation of XML shim parameters for shim init() methods defined by shim authors. There are two types of these shim parameters: "old-style" parameters and GCV-style parameters. This class hides the difference when possible.

When GCV-style parameters reference actual GCVs, there are two ways of handling the references:

  1. The default behavior of this class is to resolve all references, regardless of name or type, with the string "placeholder-value".
  2. setGCVResolver() can be called to set a resolver object that will be used instead of the default behavior.


Field Summary
static String ATTR_NAME
          Name of the XML 'name' attribute.
static int DRIVER_OPTIONS
          Constant specifying the options for the DriverShim.init() method.
static int PUBLISHER_OPTIONS
          Constant specifying the options for the PublicationShim.init() method.
static int SUBSCRIBER_OPTIONS
          Constant specifying the options for the SubscriptionShim.init() method.
static String TAG_DRIVER_CONFIG
          Tag name of the <driver-config> element.
static String TAG_DRIVER_OPTIONS
          Tag name of the <driver-options> element.
static String TAG_PUBLISHER_OPTIONS
          Tag name of the <publisher-options> element.
static String TAG_SUBSCRIBER_OPTIONS
          Tag name of the <subscriber-options> element.
 
Constructor Summary
ShimConfigParams()
          Construct an empty ShimConfigParams instance.
ShimConfigParams(Element driverConfig)
          Construct a new ShimConfigParams instance from an XML <driver-config> element.
 
Method Summary
 String getName()
          Get name of these parameters
 ConfigElement getParams(int type)
          Return the parameter set for a particular shim (driver, subscriber, publisher).
 boolean hasBeenModified()
          Return true if this instance has been modified.
 void resetModified()
          Reset the modified flag for this instance such that hasBeenModified() will return false.
 void setGCVResolver(ShimParams.ReferenceResolver resolver)
          Set a resolver object for resolving GCV references in GCV-style configuration parameters.
 void setName(String newName)
          Set name of these parameters
 Element toInitDoc(Node parent, int shimType)
          Create an XML representation of one of the sets of parameters suitable for use with a shim init document.
 Element toXML(Node parent)
          Create an XML representation of the shim configuration parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_DRIVER_CONFIG

public static final String TAG_DRIVER_CONFIG
Tag name of the <driver-config> element.

See Also:
Constant Field Values

TAG_DRIVER_OPTIONS

public static final String TAG_DRIVER_OPTIONS
Tag name of the <driver-options> element.

See Also:
Constant Field Values

TAG_SUBSCRIBER_OPTIONS

public static final String TAG_SUBSCRIBER_OPTIONS
Tag name of the <subscriber-options> element.

See Also:
Constant Field Values

TAG_PUBLISHER_OPTIONS

public static final String TAG_PUBLISHER_OPTIONS
Tag name of the <publisher-options> element.

See Also:
Constant Field Values

ATTR_NAME

public static final String ATTR_NAME
Name of the XML 'name' attribute.

See Also:
Constant Field Values

DRIVER_OPTIONS

public static final int DRIVER_OPTIONS
Constant specifying the options for the DriverShim.init() method. Used as a parameter toInitDoc(). Value of 0.

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

SUBSCRIBER_OPTIONS

public static final int SUBSCRIBER_OPTIONS
Constant specifying the options for the SubscriptionShim.init() method. Used as a parameter toInitDoc(). Value of 1.

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

PUBLISHER_OPTIONS

public static final int PUBLISHER_OPTIONS
Constant specifying the options for the PublicationShim.init() method. Used as a parameter toInitDoc(). Value of 2.

See Also:
toInitDoc(org.w3c.dom.Node, int), Constant Field Values
Constructor Detail

ShimConfigParams

public ShimConfigParams()
Construct an empty ShimConfigParams instance.


ShimConfigParams

public ShimConfigParams(Element driverConfig)
                 throws XMLException
Construct a new ShimConfigParams instance from an XML <driver-config> element.

Parameters:
driverConfig - Element containing XML representation
Throws:
XMLException - if the XML representation is incorrect
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()

getParams

public ConfigElement getParams(int type)
                        throws IllegalArgumentException
Return the parameter set for a particular shim (driver, subscriber, publisher).

Parameters:
type - one of DRIVER_OPTIONS, SUBSCRIBER_OPTIONS, PUBLISHER_OPTIONS
Returns:
null, an OldStyleParams instance, or a ShimParams instance.
Throws:
IllegalArgumentException - thrown if type parameter is incorrect

toXML

public Element toXML(Node parent)
Create an XML representation of the shim configuration parameters.

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 the XML representation
Returns:
the created <driver-config> Element
See Also:
hasBeenModified(), resetModified()

toInitDoc

public Element toInitDoc(Node parent,
                         int shimType)
                  throws IllegalArgumentException
Create an XML representation of one of the sets of parameters suitable for use with a shim init document.

Parameters:
parent - Node under which to construct the XML representation
shimType - one of DRIVER_OPTIONS, SUBSCRIBER_OPTIONS, or PUBLISHER_OPTIONS
Returns:
created Element
Throws:
IllegalArgumentException

getName

public String getName()
Get name of these parameters

Returns:
name

setName

public void setName(String newName)
Set name of these parameters

Parameters:
newName - name

setGCVResolver

public void setGCVResolver(ShimParams.ReferenceResolver resolver)
Set a resolver object for resolving GCV references in GCV-style configuration parameters. If null is passed then a default (fake) GCV resolver is used which will resolve all GCVs, but not necessarily to the type expected (all resolutions are to string-type GCVs with the same value).

Parameters:
resolver - implementation to resolve <gcv-ref> elements in GCV-style init params