|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.ocl.AbstractTypeResolver<PK,C,O,P,PM>
public abstract class AbstractTypeResolver<PK,C,O,P,PM>
A partial implementation of the TypeResolver
interface, useful for
providers of environment implementations to build their type resolvers.
It is recommended that clients extend this class to customize resolution of types based on their models, rather than implementing the interface. Simply override a few protected methods for creating metamodel-specific constructs.
See the Environment
class for a description of the
generic type parameters of this class.
Field Summary | |
---|---|
protected static java.lang.String |
ADDITIONS_PACKAGE
|
protected static java.lang.String |
COLLECTIONS_PACKAGE
|
protected static java.lang.String |
MESSAGES_PACKAGE
|
protected static java.lang.String |
TUPLES_PACKAGE
|
protected static java.lang.String |
TYPES_PACKAGE
|
Constructor Summary | |
---|---|
AbstractTypeResolver(Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> env)
Initializes me with an environment. |
|
AbstractTypeResolver(Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> env,
Resource resource)
Initializes me with a resource in which I will persist the model-based types that I generate in my associated Environment . |
Method Summary | |
---|---|
protected abstract void |
addClassifier(PK pkg,
C classifier)
Adds a classifier to the specified package, which is one that I use to store OCL-generated types. |
protected abstract void |
addOperation(C owner,
O operation)
Adds the specified operation to a classifier. |
protected abstract void |
addProperty(C owner,
P property)
Adds the specified property to a classifier. |
protected PK |
createAdditionalFeaturesPackage()
Creates the package containing the additional operations and properties parsed in my environment. |
protected PK |
createCollectionPackage()
Creates the package containing the collection types that I generate. |
protected CollectionType<C,O> |
createCollectionType(CollectionKind kind,
C elementType)
Creates a new collection type of the specified kind and element
type, assuming that it does not already exist. |
protected PK |
createMessagePackage()
Creates the package containing the message types that I generate. |
protected MessageType<C,O,P> |
createOperationMessageType(O operation)
Creates a new message type for the specified element ,
assuming that it does not already exist. |
protected abstract PK |
createPackage(java.lang.String name)
Creates a package with the specified name. |
protected Resource |
createResource()
Creates the resource that persists my generated types. |
protected abstract C |
createShadowClass(C type)
Creates the shadow class to contain additional features defined for the specified OCL type . |
protected MessageType<C,O,P> |
createSignalMessageType(C signal)
Creates a new message type for the specified element ,
assuming that it does not already exist. |
protected PK |
createTuplePackage()
Creates the package containing the tuple types that I generate. |
protected TupleType<O,P> |
createTupleType(
Creates a new tuple type from the specified parts , assuming that
it does not already exist. |
protected PK |
createTypePackage()
Creates the package containing the type types that I generate. |
protected TypeType<C,O> |
createTypeType(C type)
Creates a new type type for the specified type ,
assuming that it does not already exist. |
void |
dispose()
Disposes me by unloading my resource, if and only if I created it in the first place. |
protected PK |
findAdditionalFeaturesPackage()
Finds the package storing additional features, if our resource already contains it. |
protected PK |
findCollectionPackage()
Finds the package storing collection types, if our resource already contains it. |
protected CollectionType<C,O> |
findCollectionType(CollectionKind kind,
C elementType)
Finds an existing collection type matching the specified kind and
element type, if any has already been created. |
protected O |
findMatchingOperation(C shadow,
O operation)
Finds an operation already existing in the specified shadow
class that matches the specified operation signature. |
protected P |
findMatchingProperty(C shadow,
P property)
Finds a property already existing in the specified shadow
class that matches the specified property signature. |
protected PK |
findMessagePackage()
Finds the package storing message types, if our resource already contains it. |
protected MessageType<C,O,P> |
findMessageType(java.lang.Object element)
Finds an existing message type matching the specified element ,
if any has already been created. |
protected abstract PK |
findPackage(java.lang.String name)
Finds the existing package with the specified name in my resource. |
protected C |
findShadowClass(C type)
Finds the shadow class to contain additional features defined for the specified OCL type , if it already exists. |
protected PK |
findTuplePackage()
Finds the package storing tuple types, if our resource already contains it. |
protected TupleType<O,P> |
findTupleType(
Finds an existing tuple type matching the specified parts , if any
has already been created. |
protected PK |
findTypePackage()
Finds the package storing type types, if our resource already contains it. |
protected TypeType<C,O> |
findTypeType(C type)
Finds an existing type type matching the specified type ,
if any has already been created. |
java.util.List<P> |
getAdditionalAttributes(C owner)
Obtains the additional attributes defined (via OCL) in the specified classifier context. |
PK |
getAdditionalFeaturesPackage()
Obtains the package containing the additional operations and properties parsed in my environment. |
java.util.List<O> |
getAdditionalOperations(C owner)
Obtains the additional operations defined (via OCL) in the specified classifier context. |
PK |
getCollectionPackage()
Obtains the package containing the collection types that I generate. |
protected Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> |
getEnvironment()
Obtains the environment that I persist. |
PK |
getMessagePackage()
Obtains the package containing the message types that I generate. |
Resource |
getResource()
Obtains the resource in which the types that I generate are stored for persistence. |
protected C |
getShadowClass(C type)
Obtains the shadow class for the specified model classifier, creating it if necessary. |
protected abstract C |
getShadowedClassifier(C shadow)
Obtains the classifier for which the specified shadow stores additional features. |
PK |
getTuplePackage()
Obtains the package containing the tuple types that I generate. |
PK |
getTypePackage()
Obtains the package containing the type types that I generate. |
protected boolean |
hasAdditionalFeatures()
Queries whether the current environment has any additional features defined at all. |
C |
resolve(C type)
Resolves the specified type , returning my own persistent
type instance representing the same OCL type. |
P |
resolveAdditionalAttribute(C owner,
P property)
Resolves the specified "additional attribute" defined by the OCL client on the specified owner type. |
O |
resolveAdditionalOperation(C owner,
O operation)
Resolves the specified "additional operation" defined by the OCL client on the specified owner type. |
CollectionType<C,O> |
resolveCollectionType(CollectionKind kind,
C elementType)
Resolves the collection type of the specified kind and
element type, either created anew or previously created. |
MessageType<C,O,P> |
resolveOperationMessageType(O operation)
Resolves the type for a message expression referencing the specified operation . |
MessageType<C,O,P> |
resolveSignalMessageType(C signal)
Resolves the type for a message expression referencing the specified signal . |
TupleType<O,P> |
resolveTupleType(
Resolves the tuple type consisting of the specified parts ,
in no particular order, either created anew or previously created. |
TypeType<C,O> |
resolveTypeType(C type)
Resolves the type for a type expression referencing the specified type . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String COLLECTIONS_PACKAGE
protected static final java.lang.String MESSAGES_PACKAGE
protected static final java.lang.String TUPLES_PACKAGE
protected static final java.lang.String TYPES_PACKAGE
protected static final java.lang.String ADDITIONS_PACKAGE
Constructor Detail |
---|
public AbstractTypeResolver(Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> env)
env
- the environment that I persistpublic AbstractTypeResolver(Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> env, Resource resource)
Environment
.
env
- my environmentresource
- my resourceMethod Detail |
---|
public C resolve(C type)
TypeResolver
type
, returning my own persistent
type instance representing the same OCL type.
The type
may have been newly created by the parser and be
a duplicate of a type previously resolved, or it may actually be a
type that was previously resolved. In the latter case, the
type
is returned as is. The null
type is
considered to be resolved (i.e., the result is also null
).
Usually, this method will delegate to one of the
resolveXyzType()
methods defined by this interface.
resolve
in interface TypeResolver<C,O,P>
type
- a type to resolve
type
if it is already resolvedprotected final Environment<PK,C,O,P,?,PM,?,?,?,?,?,?> getEnvironment()
public Resource getResource()
TypeResolver
getResource
in interface TypeResolver<C,O,P>
protected Resource createResource()
public PK getCollectionPackage()
protected PK createCollectionPackage()
protected PK findCollectionPackage()
null
if it does not yet existpublic CollectionType<C,O> resolveCollectionType(CollectionKind kind, C elementType)
TypeResolver
kind
and
element type, either created anew or previously created.
resolveCollectionType
in interface TypeResolver<C,O,P>
kind
- the kind of collection type to createelementType
- the element type
protected CollectionType<C,O> createCollectionType(CollectionKind kind, C elementType)
kind
and element
type, assuming that it does not already exist.
kind
- the kind of collection to createelementType
- the collection's element type
protected CollectionType<C,O> findCollectionType(CollectionKind kind, C elementType)
kind
and
element type, if any has already been created.
kind
- the element kind to search forelementType
- the element type to search for
null
if none foundpublic PK getTuplePackage()
protected PK createTuplePackage()
protected PK findTuplePackage()
null
if it does not yet existpublic TupleType<O,P> resolveTupleType(parts)
TypeResolver
parts
,
in no particular order, either created anew or previously created. The
resulting type is uniquely defined by the names and types of its parts, and
twp tuple types are considered equal if they have the same number of parts
and their parts correspond one-for-one in name and type (order is not
significant).
resolveTupleType
in interface TypeResolver<C,O,P>
parts
- a list of TypedElement
s defining the name and type of
each tuple part. The part names are unique
protected TupleType<O,P> createTupleType(parts)
parts
, assuming that
it does not already exist.
parts
- the TypedElement
s describing the tuple parts
protected TupleType<O,P> findTupleType(parts)
parts
, if any
has already been created.
parts
- the TypedElement
s describing the tuple parts
null
if none foundpublic PK getTypePackage()
protected PK createTypePackage()
protected PK findTypePackage()
null
if it does not yet existpublic TypeType<C,O> resolveTypeType(C type)
TypeResolver
type
. This is, effectively, the OCL metatype counterpart
for the specified model type.
resolveTypeType
in interface TypeResolver<C,O,P>
type
- a model type
protected TypeType<C,O> createTypeType(C type)
type
,
assuming that it does not already exist.
type
- the referenced model type
protected TypeType<C,O> findTypeType(C type)
type
,
if any has already been created.
type
- the referenced model type
null
if none foundpublic PK getMessagePackage()
protected PK createMessagePackage()
protected PK findMessagePackage()
null
if it does not yet existpublic MessageType<C,O,P> resolveOperationMessageType(O operation)
TypeResolver
operation
.
resolveOperationMessageType
in interface TypeResolver<C,O,P>
operation
- the operation call that the message represents
public MessageType<C,O,P> resolveSignalMessageType(C signal)
TypeResolver
signal
.
resolveSignalMessageType
in interface TypeResolver<C,O,P>
signal
- the signal send that the message represents
protected MessageType<C,O,P> createOperationMessageType(O operation)
element
,
assuming that it does not already exist.
operation
- the operation referenced by the message type
protected MessageType<C,O,P> createSignalMessageType(C signal)
element
,
assuming that it does not already exist.
signal
- the signal referenced by the message type
protected MessageType<C,O,P> findMessageType(java.lang.Object element)
element
,
if any has already been created.
element
- the referenced model element
null
if none foundpublic PK getAdditionalFeaturesPackage()
protected PK createAdditionalFeaturesPackage()
protected PK findAdditionalFeaturesPackage()
null
if it does not yet existpublic O resolveAdditionalOperation(C owner, O operation)
TypeResolver
owner
type.
resolveAdditionalOperation
in interface TypeResolver<C,O,P>
owner
- the type on which the additional operation is definedoperation
- the additional operation
public java.util.List<O> getAdditionalOperations(C owner)
TypeResolver
getAdditionalOperations
in interface TypeResolver<C,O,P>
owner
- the context classifier
protected O findMatchingOperation(C shadow, O operation)
shadow
class that matches the specified operation
signature.
shadow
- the shadow class to searchoperation
- the operation to match
null
if not foundprotected P findMatchingProperty(C shadow, P property)
shadow
class that matches the specified property
signature.
shadow
- the shadow class to searchproperty
- the property to match
null
if not foundpublic P resolveAdditionalAttribute(C owner, P property)
TypeResolver
owner
type.
resolveAdditionalAttribute
in interface TypeResolver<C,O,P>
owner
- the type on which the additional attribute is definedproperty
- the additional attribute
protected boolean hasAdditionalFeatures()
public java.util.List<P> getAdditionalAttributes(C owner)
TypeResolver
getAdditionalAttributes
in interface TypeResolver<C,O,P>
owner
- the context classifier
protected abstract C createShadowClass(C type)
type
.
type
- an OCL type
protected abstract void addProperty(C owner, P property)
owner
- the classifier to own the propertyproperty
- the property to add to the classifierprotected abstract void addOperation(C owner, O operation)
owner
- the classifier to own the operationoperation
- the operation to add to the classifierprotected C findShadowClass(C type)
type
, if it already exists.
type
- an OCL type
null
if not foundprotected abstract C getShadowedClassifier(C shadow)
shadow
- a class originally created to shadow a model classifier
createShadowClass(Object)
,
getShadowClass(Object)
protected C getShadowClass(C type)
type
- a classifier in the model
protected abstract PK createPackage(java.lang.String name)
name
- the package name
protected abstract PK findPackage(java.lang.String name)
name
- the package to seek
null
if noneprotected abstract void addClassifier(PK pkg, C classifier)
pkg
- one of my packagesclassifier
- a classifier to add to itpublic void dispose()
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |