Extending Existing Plug-ins

Domain plug-ins for all of the root domain definitions (and a few others) are provided in the out-of-the-box Cúram application. Rather than write your own plug-in implementation from scratch, it is far easier to extend one of these existing plug-ins. The supplied plug-ins are suitable for the majority of uses, but all can be overridden in whole or in part as necessary, or used as the basis for new plug-ins that customize the processing of values in new domains. The details of these supplied plug-ins and the behavior of their operations are described in the sections below.

Abstract plug-in classes are also provided to be used as the basis of new plug-ins. These abstract classes are used by the Cúram plug-ins themselves and provide some useful functionality that is rarely necessary to override. The abstract classes you might use are:

Their behavior is as follows:

Table 1. Behavior of the Abstract Plug-in Classes
Abstract Plug-in Class Behavior

AbstractConverter

Returns the correct name for this type of plug-in: "converter".

Formats an object that is an instance of java.lang.Number using the standard Java locale-specific number format. Other object types are formatted by calling their toString method.

Pre-parses an object by trimming leading and trailing whitespace, compressing sequences of spaces, and converting to upper-case if specified by the UML domain definition options for the domain.

Does not implement any parse operation.

Pre-validates an object by checking its maximum and minimum values if these are specified by the UML domain definition options for the domain.

Validates an object by throwing a java.lang.NullPointerException if an object is null, but otherwise performs no validation.

Performs generic parsing by invoking the ordinary parse operation that must be implemented in the sub-class. See Generic Parse Operations for information on protecting the generic parse operation from side-effects.

Performs generic formatting by invoking the object's toString method.

Returns the correct value for the generic locale.

AbstractComparator

Returns the correct name for this type of plug-in: "comparator".

AbstractDefault

Returns the correct name for this type of plug-in: "default".

Defines constants with suitable assumed default values for each of the root domains.

Returns the displayed default value by looking up the default value defined in the UML domain definition options, or, if not found there, returns the assumed default value.

Does not implement getAssumedDefault.

These abstract classes are used by the Cúram plug-in classes and all extend the curam.util.common.domain.AbstractDomainPlugIn class. This class implements the locale and domain properties of the DomainPlugIn interface and also provides the plug-in instance management implementation that should be used by all plug-ins (see Plug-in Instance Management for details).

While it is possible to write plug-ins from scratch, you should follow the guidelines presented in this chapter and extend either the existing plug-in classes or their abstract base classes. Other approaches cannot be supported due to the complexity of some features, such as instance management and generic parsing, that are best avoided and the default implementations used. Reusing these classes will also ensure that your code will be protected from changes to the plug-in interfaces, as default implementations of new interface methods will be inherited during upgrades and no custom code changes should be necessary.