Class ObjectModelImpl
- java.lang.Object
-
- org.nuiton.eugene.models.object.xml.ObjectModelImpl
-
- All Implemented Interfaces:
WithTagValuesOrStereotypes
,Model
,ObjectModel
@Component(role=Model.class, hint="objectmodel") public class ObjectModelImpl extends Object implements ObjectModel
Implementation class for the root node abstraction of object model trees. This an entry point for browsing a model tree. This object offers as well several facilities for a direct access to some of the object model elements. In this concrete class, the tree is build by parsing an object model xml description using lutinxml XMLObjectParser. Created: 14 janv. 2004- Author:
- Cédric Pineau - pineau@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,ObjectModelClass>
classes
protected Map<String,ObjectModelClassifier>
classifiers
protected List<String>
comments
protected Map<String,ObjectModelEnumeration>
enumerations
protected Map<String,ObjectModelInterface>
interfaces
protected String
name
protected Map<String,ObjectModelPackage>
packages
protected Map<String,String>
tagValues
protected String
version
-
Fields inherited from interface org.nuiton.eugene.models.object.ObjectModel
NAME
-
-
Constructor Summary
Constructors Constructor Description ObjectModelImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAssociationClass(ObjectModelAssociationClassImpl clazz)
void
addClass(ObjectModelClassImpl clazz)
void
addComment(String comment)
void
addEnumeration(ObjectModelEnumerationImpl enumeration)
void
addInterface(ObjectModelInterfaceImpl interfacez)
void
addPackage(ObjectModelPackageImpl aPackage)
void
addStereotype(String stereotype)
void
addTagValue(String tagValue, String value)
Adds the givenvalue
associated to thetagValue
.ObjectModelImplTagValue
addTagValue(ObjectModelImplTagValue tagValue)
ObjectModelClass
getClass(String qualifiedClassName)
Returns the class corresponding to the given qualified name, or null if the model contains no class for this qualified name.Collection<ObjectModelClass>
getClasses()
Returns all classes defined in this model.ObjectModelClassifier
getClassifier(String qualifiedClassifierName)
Returns the classifier corresponding to the given qualified name, or null if the model contains no classifier for this qualified name.Collection<ObjectModelClassifier>
getClassifiers()
Returns all classifiers defined in this model.List<String>
getComments()
Returns all comments not lied to a particular model elementObjectModelEnumeration
getEnumeration(String qualifiedEnumerationName)
Return the enumeration corresponding to the given qualified nameCollection<ObjectModelEnumeration>
getEnumerations()
Returns all enumerations defined in this model.<O> O
getExtension(String reference, Class<O> extensionClass)
Get the extension associated to the reference (unique).ObjectModelInterface
getInterface(String qualifiedInterfaceName)
Returns the interface corresponding to the given qualified name, or null if the model contains no interface for this qualified name.Collection<ObjectModelInterface>
getInterfaces()
Returns all interfaces defined in this model.String
getModelType()
String
getName()
Returns the name of this model.ObjectModelPackage
getPackage(String packageName)
Returns the package corresponding to the given name, or null if the model contains no package for this name.ObjectModelPackage
getPackage(ObjectModelClassifier classifier)
Returns the package of the given classifier, or null if the model contains no package for this classifier.Collection<ObjectModelPackage>
getPackages()
Returns all packages defined in this model.Set<String>
getStereotypes()
String
getTagValue(String tagValue)
Returns the tagValue corresponding to the given name, or null if the element has no associated tagValue for this name.Map<String,String>
getTagValues()
Returns the tagValues associated with this element.String
getVersion()
Returns the version of this model.boolean
hasClass(String qualifiedClassName)
Indicates whether the model contains the class associated to the given classNameboolean
hasPackage(String packageName)
Indicates whether the model contains the package associated to the given nameboolean
hasStereotype(String stereotypeName)
boolean
hasTagValue(String tagValue)
Returns whether this element has a tagValue corresponding to the given name, or not.protected void
mergeClassifiers(ObjectModelClassifierImpl initialClazzifier, ObjectModelClassifierImpl additionalClazzifier)
protected void
mergePackages(ObjectModelPackageImpl initialPackage, ObjectModelPackageImpl additionalPackage)
void
removeClass(String className)
void
removeEnumeration(String enumerationName)
void
removeInterface(String interfaceName)
void
removePackage(String packageName)
void
removeStereotype(String stereotype)
void
removeTagValue(String tagvalue)
void
setName(String name)
void
setVersion(String version)
-
-
-
Field Detail
-
name
protected String name
-
version
protected String version
-
classes
protected Map<String,ObjectModelClass> classes
-
packages
protected Map<String,ObjectModelPackage> packages
-
interfaces
protected Map<String,ObjectModelInterface> interfaces
-
classifiers
protected Map<String,ObjectModelClassifier> classifiers
-
enumerations
protected Map<String,ObjectModelEnumeration> enumerations
-
-
Method Detail
-
getModelType
public String getModelType()
- Specified by:
getModelType
in interfaceModel
- Returns:
- the type of model.
-
setName
public void setName(String name)
-
setVersion
public void setVersion(String version)
-
getVersion
public String getVersion()
Description copied from interface:Model
Returns the version of this model.- Specified by:
getVersion
in interfaceModel
- Returns:
- the version of this model.
-
addPackage
public void addPackage(ObjectModelPackageImpl aPackage)
-
addClass
public void addClass(ObjectModelClassImpl clazz)
-
addAssociationClass
public void addAssociationClass(ObjectModelAssociationClassImpl clazz)
-
addComment
public void addComment(String comment)
-
getName
public String getName()
Returns the name of this model.
-
getPackages
public Collection<ObjectModelPackage> getPackages()
Description copied from interface:ObjectModel
Returns all packages defined in this model.- Specified by:
getPackages
in interfaceObjectModel
- Returns:
- a Collection containing all ObjectModelPackage for this model.
- See Also:
ObjectModelPackage
-
getPackage
public ObjectModelPackage getPackage(String packageName)
Description copied from interface:ObjectModel
Returns the package corresponding to the given name, or null if the model contains no package for this name.- Specified by:
getPackage
in interfaceObjectModel
- Parameters:
packageName
- - the name of the package to retrieve.- Returns:
- the ObjectModelPackage of the found given name, or null if the model contains no package for this name.
-
getPackage
public ObjectModelPackage getPackage(ObjectModelClassifier classifier)
Description copied from interface:ObjectModel
Returns the package of the given classifier, or null if the model contains no package for this classifier.- Specified by:
getPackage
in interfaceObjectModel
- Parameters:
classifier
- the classifier of the package to retrieve.- Returns:
- the ObjectModelPackage for the given classifier, or null if the model contains no package for this classifier.
-
hasPackage
public boolean hasPackage(String packageName)
Description copied from interface:ObjectModel
Indicates whether the model contains the package associated to the given name- Specified by:
hasPackage
in interfaceObjectModel
- Parameters:
packageName
- - the name of the package to retrieve.- Returns:
- true if the package has been found.
-
getClassifiers
public Collection<ObjectModelClassifier> getClassifiers()
Returns all classifiers defined in this model.- Specified by:
getClassifiers
in interfaceObjectModel
- Returns:
- a Collection containing all ObjectModelClassifier for this model.
- See Also:
ObjectModelClassifier
-
getClassifier
public ObjectModelClassifier getClassifier(String qualifiedClassifierName)
Returns the classifier corresponding to the given qualified name, or null if the model contains no classifier for this qualified name.- Specified by:
getClassifier
in interfaceObjectModel
- Parameters:
qualifiedClassifierName
- - the qualified name of the classifier to retrieve.- Returns:
- the ObjectModelClassifier of the found classifier, or null if the model contains no classifier for this qualified name.
-
getClasses
public Collection<ObjectModelClass> getClasses()
Returns all classes defined in this model.- Specified by:
getClasses
in interfaceObjectModel
- Returns:
- a Collection containing all ObjectModelClass for this model.
- See Also:
ObjectModelClass
-
getClass
public ObjectModelClass getClass(String qualifiedClassName)
Returns the class corresponding to the given qualified name, or null if the model contains no class for this qualified name.- Specified by:
getClass
in interfaceObjectModel
- Parameters:
qualifiedClassName
- - the qualified name of the class to retrieve.- Returns:
- the ObjectModelClass of the found class, or null if the model contains no class for this qualified name.
-
hasClass
public boolean hasClass(String qualifiedClassName)
Description copied from interface:ObjectModel
Indicates whether the model contains the class associated to the given className- Specified by:
hasClass
in interfaceObjectModel
- Parameters:
qualifiedClassName
- - the qualified name of the class to retrieve.- Returns:
- true if the class has been found.
-
addInterface
public void addInterface(ObjectModelInterfaceImpl interfacez)
-
getInterface
public ObjectModelInterface getInterface(String qualifiedInterfaceName)
Returns the interface corresponding to the given qualified name, or null if the model contains no interface for this qualified name.- Specified by:
getInterface
in interfaceObjectModel
- Parameters:
qualifiedInterfaceName
- - the qualified name of the interface to retrieve.- Returns:
- the ObjectModelInterface of the found interface, or null if the model contains no interface for this qualified name.
-
getInterfaces
public Collection<ObjectModelInterface> getInterfaces()
Returns all interfaces defined in this model.- Specified by:
getInterfaces
in interfaceObjectModel
- Returns:
- a Collection containing all ObjectModelInterface for this model.
- See Also:
ObjectModelInterface
-
addEnumeration
public void addEnumeration(ObjectModelEnumerationImpl enumeration)
-
getEnumerations
public Collection<ObjectModelEnumeration> getEnumerations()
Description copied from interface:ObjectModel
Returns all enumerations defined in this model.- Specified by:
getEnumerations
in interfaceObjectModel
- Returns:
- a Collection containing all ObjectModelEnumeration for this model.
- See Also:
ObjectModelEnumeration
-
getEnumeration
public ObjectModelEnumeration getEnumeration(String qualifiedEnumerationName)
Description copied from interface:ObjectModel
Return the enumeration corresponding to the given qualified name- Specified by:
getEnumeration
in interfaceObjectModel
- Parameters:
qualifiedEnumerationName
- the fully qualified name of the enumeration to retrieve.- Returns:
- the ObjectModelEnumeration of the found enumeration or null if the model contains no enumeration for this qualified name.
-
getComments
public List<String> getComments()
Returns all comments not lied to a particular model element- Specified by:
getComments
in interfaceObjectModel
- Returns:
- a List containing all comments for this model as Strings.
-
getStereotypes
public Set<String> getStereotypes()
- Specified by:
getStereotypes
in interfaceWithTagValuesOrStereotypes
-
hasStereotype
public boolean hasStereotype(String stereotypeName)
- Specified by:
hasStereotype
in interfaceWithTagValuesOrStereotypes
-
addStereotype
public void addStereotype(String stereotype)
- Specified by:
addStereotype
in interfaceWithTagValuesOrStereotypes
-
removeStereotype
public void removeStereotype(String stereotype)
- Specified by:
removeStereotype
in interfaceWithTagValuesOrStereotypes
-
removePackage
public void removePackage(String packageName)
-
removeClass
public void removeClass(String className)
-
removeInterface
public void removeInterface(String interfaceName)
-
removeEnumeration
public void removeEnumeration(String enumerationName)
-
mergePackages
protected void mergePackages(ObjectModelPackageImpl initialPackage, ObjectModelPackageImpl additionalPackage)
-
mergeClassifiers
protected void mergeClassifiers(ObjectModelClassifierImpl initialClazzifier, ObjectModelClassifierImpl additionalClazzifier)
-
addTagValue
public ObjectModelImplTagValue addTagValue(ObjectModelImplTagValue tagValue)
-
getTagValues
public Map<String,String> getTagValues()
Description copied from interface:WithTagValuesOrStereotypes
Returns the tagValues associated with this element. For each entry, the key is the name of the tagValue, the value is the value of the tagValue :-)- Specified by:
getTagValues
in interfaceWithTagValuesOrStereotypes
- Returns:
- a Map containing all tagValues associated with this element
-
getTagValue
public String getTagValue(String tagValue)
Description copied from interface:WithTagValuesOrStereotypes
Returns the tagValue corresponding to the given name, or null if the element has no associated tagValue for this name.- Specified by:
getTagValue
in interfaceWithTagValuesOrStereotypes
- Parameters:
tagValue
- tag value key- Returns:
- the value of the found tagValue, or null if the element has no associated tagValue for this name.
-
addTagValue
public void addTagValue(String tagValue, String value)
Description copied from interface:WithTagValuesOrStereotypes
Adds the givenvalue
associated to thetagValue
. Note: If a previous tag value was definied, then it will be replaced.- Specified by:
addTagValue
in interfaceWithTagValuesOrStereotypes
- Parameters:
tagValue
- the name of the tag valuevalue
- the value to associate
-
hasTagValue
public boolean hasTagValue(String tagValue)
Description copied from interface:WithTagValuesOrStereotypes
Returns whether this element has a tagValue corresponding to the given name, or not.- Specified by:
hasTagValue
in interfaceWithTagValuesOrStereotypes
- Parameters:
tagValue
- tag value name- Returns:
- a boolean indicating whether this element has a tagValue corresponding to the given name, or not.
-
removeTagValue
public void removeTagValue(String tagvalue)
- Specified by:
removeTagValue
in interfaceWithTagValuesOrStereotypes
-
getExtension
public <O> O getExtension(String reference, Class<O> extensionClass) throws RuntimeException
Get the extension associated to the reference (unique). Create it if not exist.- Specified by:
getExtension
in interfaceModel
- Type Parameters:
O
- object type returned- Parameters:
reference
- unique corresponding to the extension to getextensionClass
- class of the extension- Returns:
- the object value for the extension
- Throws:
ClassCastException
- when extensionClass is not validRuntimeException
- when instantiation problem to create new extension
-
-