IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.patterns.framework.uml2
Class AbstractPatternParameter

java.lang.Object
  extended bycom.ibm.xtools.patterns.framework.AbstractPatternElement
      extended bycom.ibm.xtools.patterns.framework.AbstractPatternParameter
          extended bycom.ibm.xtools.patterns.framework.uml2.AbstractPatternParameter
All Implemented Interfaces:
Comparable, IParameterDescriptor, ITransformationDescriptor, ITransformationItem, Visitable

public class AbstractPatternParameter
extends AbstractPatternParameter

An abstract pattern parameter specific for UML2 patterns that provides more default behavior than the core framework's abstract pattern parameter. UML2 patterns are patterns that use UML2 types for their parameter types. The framework supports non-UML2 types as parameter types but in that case the author should extend from the core framework's abstract pattern parameter instead of this class. This implementation provides default behavior for a few of the hot-spot methods defined in the core framewok's abstract pattern parameter.


Field Summary
 
Fields inherited from interface com.ibm.xtools.patterns.core.IParameterDescriptor
BINDABLE
 
Fields inherited from interface com.ibm.xtools.transform.core.ITransformationDescriptor
AUTHOR, DESCRIPTION, DOCUMENT, EXTENSIBLE, GROUP_PATH, GROUP_PATH_DELIMITERS, ICON, ID, KEYWORDS, KEYWORDS_DELIMITERS, NAME, PROFILES, PROFILES_DELIMITERS, PROVIDER, PUBLIC, SOURCE_MODEL_TYPE, SOURCE_MODEL_TYPE_DELIMITERS, TARGET_MODEL_TYPE, TARGET_MODEL_TYPE_DELIMITERS, TRANSFORM_GUI, VERSION
 
Constructor Summary
AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity)
          Constructs a UML2 pattern parameter given just the parameter identity; the rest of the parameter description is assumed (and must) be specified via a statically described method offered by the pattern service.
 
Method Summary
protected  Object[] create(AbstractPatternInstance instance, IPatternMetatype metatype)
          If this parameter supports creation of prototypical instances then this method will be implemented.
protected  Object[] create(AbstractPatternInstance instance, IPatternMetatype metatype, String scopeQualifiedName)
          If this parameter supports creation of prototypical instances then this method will be implemented.
protected  Object getDerivedScope(AbstractPatternInstance instance)
          Retrieves the derived scope which in turn can be used to resolve parameter values and create parameter values within.
protected  EClass getSubstituteType()
          This method takes the current type of this parameter and then potentially changes the type to a more concrete type if possible (if not concrete already).
 IPatternMetatype getType()
          Retrieves the type of the parameter represented by this descriptor.
protected static boolean isDistinguishable(String candidateName, NamedElement namedElementA, NamedElement namedElementB)
          Determines if two named elements are distinguishable using the rules defined by the UML2 specification.
protected  boolean isRetrievable()
          A hot-spot method that indicates if a parameter value, given a name within a scope, can be retrieved.
protected  boolean isScopeDerivable()
          Determines if this parameter has a scope that can be derived, also known as a default context or namespace for resolving elements and/or creating new parameter values.
protected  boolean isTypeSubstitutable()
          Indicates if the type of this parameter can be made more concrete and subtituted for various operations that requires a concrete type in lieu of an abstract type.
protected  boolean isValid(PatternParameterValue.Unresolved unresolved)
          Determines if the unresolved value is valid.
protected  boolean isValid(PatternParameterValue.Unresolved unresolved, PatternParameterValue.Unresolved.Directive directive)
          Determines if the unresolved value is valid.
 boolean isValidArgumentType(IPatternMetatype metatype)
          Checks whether the object of the given metatype is accepted as an argument of the parameter represented by this descriptor.
protected  Object resolve(PatternParameterValue.Unresolved unresolved)
          The resolve method is called if an unresolved value is attempting to be bound to this parameter.
protected  Object resolve(PatternParameterValue.Unresolved unresolved, PatternParameterValue.Unresolved.Directive directive)
          The resolve method extends upon the resolve method that does not take a directive.
protected  Object retrieve(AbstractPatternInstance instance, String valueName)
          A hot-spot method that retrieves a parameter value, given a name
protected  IStatus validToAddArgument(PatternParameterValue.Unresolved unresolved)
          This method is a hotspot that is overridden to add custom pattern specific argument validation logic.
 IStatus validToCreateArguments(AbstractPatternInstance instance, IPatternMetatype metatype)
          This is a hotspot method used in conjunction with the create method.
protected  IStatus validToReplaceArgument(PatternParameterValue.Unresolved unresolved)
          This method is a hotspot that is overridden to add custom pattern specific argument validation logic.
 
Methods inherited from class com.ibm.xtools.patterns.framework.AbstractPatternParameter
accept, compareTo, createArgumentsUsingPairs, equals, expand, expand, expand, expand, expand, getAlternateTypes, getDescription, getFirstArgumentCandidates, getId, getMultiplicity, getName, getOrdinal, getOwningDefinition, getPatternIdentity, getProperties, getProperty, getPropertyIds, getSecondArgumentCandidates, getSecondArgumentCandidatesForFirstValue, getValue, getValues, hashCode, hasValue, hasValues, initialize, isBindable, isPublic, isValid, isValid, isValid, isValidParameterTarget, usesPairsToCreateArguments, validToAddArgument, validToReplaceArgument
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPatternParameter

public AbstractPatternParameter(AbstractPatternDefinition owningDefinition,
                                PatternParameterIdentity parameterIdentity)
Constructs a UML2 pattern parameter given just the parameter identity; the rest of the parameter description is assumed (and must) be specified via a statically described method offered by the pattern service.

Parameters:
owningDefinition - definition that owns and helps define this parameter
parameterIdentity - the identity of the parameter; used internally to locate the matching parameter descriptor as provided by the associated static pattern provider for this parameter.
Method Detail

isDistinguishable

protected static boolean isDistinguishable(String candidateName,
                                           NamedElement namedElementA,
                                           NamedElement namedElementB)
Determines if two named elements are distinguishable using the rules defined by the UML2 specification. Does not use the UML2 implementation of this method since both elements already exist in the same namespace and that method would already return false.

Parameters:
candidateName - the name that is potentially used to distinguish the named element A
namedElementA - the element that is try to distinguish itself
namedElementB - another one of the named elements in the same namespace
Returns:
true if the elements can co-exist within the same namespace and still retain a distinguishable identity

create

protected Object[] create(AbstractPatternInstance instance,
                          IPatternMetatype metatype)
Description copied from class: AbstractPatternParameter
If this parameter supports creation of prototypical instances then this method will be implemented. It is determined whether or not a parameter support prototypical instance creation by implementing the is creatable method so it returns true. This is a hot-spot method that is used in conjunction with the is creatable method. This method must just create values; the eventual adding of this values to the pattern instance are handled by the framework. The same is true for the resolve hot-spot method found on this class.

Specified by:
create in class AbstractPatternParameter
Parameters:
instance - the instance that defines context for creating new prototypical instances of suggested arguments of this parameter
metatype - the proposed metatype for the new prototypical arguments of this parameter; if the metatype is null then the parameter may choose an appropriate metatype
Returns:
an object array that holds all new values that were created; the types of the returned objects need to conform with the is valid checks defined by this parameter. Before the new values are added, an validation will be performed by invoking the is valid proposed value method variant.

create

protected Object[] create(AbstractPatternInstance instance,
                          IPatternMetatype metatype,
                          String scopeQualifiedName)
Description copied from class: AbstractPatternParameter
If this parameter supports creation of prototypical instances then this method will be implemented. It is determined whether or not a parameter support prototypical instance creation by implementing the is creatable method so it returns true. This is a hot-spot method that is used in conjunction with the is creatable method. This method must just create values; the eventual adding of this values to the pattern instance are handled by the framework. The same is true for the resolve hot-spot method found on this class.

Specified by:
create in class AbstractPatternParameter
Parameters:
instance - the instance that defines context for creating new prototypical instances of suggested arguments of this parameter
metatype - the proposed metatype for the new prototypical arguments of this parameter; if the metatype is null then the parameter may choose an appropriate metatype
scopeQualifiedName - the qualified name that specifies the scope.
Returns:
an object array that holds all new values that were created; the types of the returned objects need to conform with the is valid checks defined by this parameter. Before the new values are added, an validation will be performed by invoking the is valid proposed value method variant.

getDerivedScope

protected Object getDerivedScope(AbstractPatternInstance instance)
Description copied from class: AbstractPatternParameter
Retrieves the derived scope which in turn can be used to resolve parameter values and create parameter values within. A scope can also be thought of as a namespace or a context for values that need some direction as to where they are attached. A null indicates that the derived scope could not be retrieved. Normally this method should only return null if the has derived scope method returns false. This method along with the has derived scope method should be overridden in tandem. For parameter values that have no concept of being attached to a container the scope is undefined and not used.

Overrides:
getDerivedScope in class AbstractPatternParameter
Parameters:
instance - the pattern instance of interest for determining if a default scope is available
Returns:
the object that is the default scope, for example for UML2 this might be a UML2 package that contains the values which are UML2 classes

getSubstituteType

protected EClass getSubstituteType()
Description copied from class: AbstractPatternParameter
This method takes the current type of this parameter and then potentially changes the type to a more concrete type if possible (if not concrete already). If the resultant type returned from this method is still abstract then it cannot be created by this parameter in the create method since it is not concrete. This is a hot-spot method that can be implemented to supply the correct substitute type given the real type of the parameter.

Overrides:
getSubstituteType in class AbstractPatternParameter
Returns:
the most concrete type available for this parameter's type; an example of using this method to get the desired behavior would be to return a UML2 interface if a UML2 classifier is the current parameter type. This would allow an interface to be created since its concrete as the default create behavior.

getType

public IPatternMetatype getType()
Description copied from interface: IParameterDescriptor

Retrieves the type of the parameter represented by this descriptor.

Use the Pair method to retrieve the argument pairs used as parameter arguments. Use the isValidArgumentType method to retrieve whether the object of a specific metatype is accepted as an argument of the parameter. Use the getAlternateTypes method to retrieve the types accepted for parameter arguments.

Specified by:
getType in interface IParameterDescriptor
Overrides:
getType in class AbstractPatternParameter

isRetrievable

protected boolean isRetrievable()
Description copied from class: AbstractPatternParameter
A hot-spot method that indicates if a parameter value, given a name within a scope, can be retrieved.

Overrides:
isRetrievable in class AbstractPatternParameter
Returns:
true if a parameter value is retrievable from the derived scope

isScopeDerivable

protected boolean isScopeDerivable()
Description copied from class: AbstractPatternParameter
Determines if this parameter has a scope that can be derived, also known as a default context or namespace for resolving elements and/or creating new parameter values. If this hot-spot method is not implemented then the get derived scope method will not be used to determine where to find or create model elements. This method and the get default scope method work together with the is creatable and create parameter methods. For parameter values that have no immediate container or owner, those that make sense to create detached, are not associated with the concept of a scope

Overrides:
isScopeDerivable in class AbstractPatternParameter
Returns:
true if a scope for finding and creating new parameter values is derivable from the current state of the parameter, instance, etc
See Also:
AbstractPatternParameter.getDerivedScope(AbstractPatternInstance), AbstractPatternParameter.create(AbstractPatternInstance, IPatternMetatype)

isTypeSubstitutable

protected boolean isTypeSubstitutable()
Description copied from class: AbstractPatternParameter
Indicates if the type of this parameter can be made more concrete and subtituted for various operations that requires a concrete type in lieu of an abstract type. For example, the create hot-spot, etc. If this method is overridden then the complementary get substitute type should also be overridden.

Overrides:
isTypeSubstitutable in class AbstractPatternParameter
Returns:
indicates if this type is substitutable with a more concrete type

isValid

protected boolean isValid(PatternParameterValue.Unresolved unresolved)
Description copied from class: AbstractPatternParameter
Determines if the unresolved value is valid. By default false is returned, this can be overridden in pattern parameter implementation subclasses. This method is invoked according to whatever validation strategy is plugged in for this parameter. It could be that this method is never invoked because the governing strategy does some initial checks that first must be true before an additional invocation into the hot-spot is valid is called.

Overrides:
isValid in class AbstractPatternParameter
Parameters:
unresolved - the unresolved value
Returns:
true if it is valid to bind the given unresolved value to this parameter once it has been properly resolved

isValid

protected boolean isValid(PatternParameterValue.Unresolved unresolved,
                          PatternParameterValue.Unresolved.Directive directive)
Description copied from class: AbstractPatternParameter
Determines if the unresolved value is valid. By default false is returned, this can be overridden in pattern parameter implementation subclasses. This method is invoked according to whatever validation strategy is plugged in for this parameter. It could be that this method is never invoked because the governing strategy does some initial checks that first must be true before an additional invocation into the hot-spot is valid is called. The additional directive parameter allows the validity logic to be altered.

Overrides:
isValid in class AbstractPatternParameter
Parameters:
unresolved - the unresolved value
directive - the additional directive to alter the validity logic
Returns:
true if it is valid to bind the given unresolved value to this parameter once it has been properly resolved (factoring in the directive implications)

isValidArgumentType

public boolean isValidArgumentType(IPatternMetatype metatype)
Description copied from interface: IParameterDescriptor

Checks whether the object of the given metatype is accepted as an argument of the parameter represented by this descriptor.

Use the getAlternateTypes method to retrieve the types accepted for parameter arguments.

Returns:
Returns a Boolean value of True if the object of the given metatype can be an argument for the parameter. Otherwise, it returns a value of False.

resolve

protected Object resolve(PatternParameterValue.Unresolved unresolved)
Description copied from class: AbstractPatternParameter
The resolve method is called if an unresolved value is attempting to be bound to this parameter. If the is valid method for unresolved values return true then the resolve method on this parameter is subsequently invoked. This is a framework hot-spot method. Typically both the resolve and isValid(Unresolved) methods for a parameter would either be overridden or not overridden.

Overrides:
resolve in class AbstractPatternParameter
Parameters:
unresolved - the value that is in the unresolved state
Returns:
null is returned if no resolution occurs or can occur, a call to is valid for unresolves values should be made before making this call; a non-null return value indicates that the resolution took place in this parameter successfully and the native resolved value is returned, native in this context just means it is not wrapped by some pattern parameter value object

resolve

protected Object resolve(PatternParameterValue.Unresolved unresolved,
                         PatternParameterValue.Unresolved.Directive directive)
Description copied from class: AbstractPatternParameter
The resolve method extends upon the resolve method that does not take a directive. The directive indicates any additional instructions or restrictions that clients of the resolution action specify.

Overrides:
resolve in class AbstractPatternParameter
Parameters:
unresolved - the value that is in the unresolved state
directive - an additional directive that modifies behavior
Returns:
the resolved object
See Also:
AbstractPatternParameter.resolve(PatternParameterValue.Unresolved)

retrieve

protected Object retrieve(AbstractPatternInstance instance,
                          String valueName)
Description copied from class: AbstractPatternParameter
A hot-spot method that retrieves a parameter value, given a name

Overrides:
retrieve in class AbstractPatternParameter
Parameters:
instance - the instance that gives context to the retrieval
valueName - the name of the parameter value to retrieve
Returns:
the object that is the value of the specified parameter

validToAddArgument

protected IStatus validToAddArgument(PatternParameterValue.Unresolved unresolved)
Description copied from class: AbstractPatternParameter
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. The logic is augmented by the default logic of the appropriately selected validation strategy.

Overrides:
validToAddArgument in class AbstractPatternParameter
Parameters:
unresolved - the unresolved value to determine if resolution into a valid argument is possible
Returns:
a status true if valid

validToCreateArguments

public IStatus validToCreateArguments(AbstractPatternInstance instance,
                                      IPatternMetatype metatype)
Description copied from class: AbstractPatternParameter
This is a hotspot method used in conjunction with the create method. These two methods are complementary just as the isRetrievable and retrieve methods are. This method determines if it is valid to create default arguments of the given type for the specified pattern instance.

Overrides:
validToCreateArguments in class AbstractPatternParameter
Parameters:
instance - the pattern instance of interest
metatype - the metatype corresponding to the arguments to create
Returns:
a status indicating true if valid

validToReplaceArgument

protected IStatus validToReplaceArgument(PatternParameterValue.Unresolved unresolved)
Description copied from class: AbstractPatternParameter
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. The logic is augmented by the default logic of the appropriately selected validation strategy.

Overrides:
validToReplaceArgument in class AbstractPatternParameter
Parameters:
unresolved - the unresolved value to determine if resolution into a valid argument is possible
Returns:
a status true if valid

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.