org.autosemantix
Class Model

java.lang.Object
  extended byorg.autosemantix.Model

public class Model
extends java.lang.Object

This class acts as a container for all information and methods related to the platform-specific Java model. Java code elements are stored using the ecore framework provided by the EMF library.

Version:
Created Jul 5, 2005
Author:
Shawn Simister

Constructor Summary
Model(Project project)
           
 
Method Summary
 EClass addClass(java.lang.String name)
          Add a class with the given name to the model.
 void clear()
          Reset the model to its initial empty state.
 EAttribute createAttribute(java.lang.String name)
          Create a new attribute with the given name.
 EOperation createOperation(java.lang.String name)
          Create a new method with the given name.
 boolean exportXMI(java.lang.String uri)
          Serializes a Model to disk as an XMI file.
 java.util.List getClasses()
          Get a list of all classes in top level package of the current model.
static java.util.List getDirectSuperTypes(EClass c)
          Find a list of all suprclasses which are one level up in the inheritance hierarchy.
 EcoreFactory getFactory()
          Get the current factory being used to create ecore objects.
 java.lang.String getJavaType(java.lang.String type)
          A lookup function to convert ecore types to regular Java types.
static java.util.List getLocalFeatures(EClass c)
          Find a list of attributes which are not inherited from the super classes.
 Model importXMI(java.lang.String uri)
          Deserialize an existing XMI file into an ecore Model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Model

public Model(Project project)
Method Detail

addClass

public EClass addClass(java.lang.String name)
Add a class with the given name to the model.

Parameters:
name - The class Name
Returns:
The new ecore class.

createAttribute

public EAttribute createAttribute(java.lang.String name)
Create a new attribute with the given name.

Parameters:
name - The attribute name.
Returns:
The new ecore class attribute.

createOperation

public EOperation createOperation(java.lang.String name)
Create a new method with the given name. Additional aspects of the method like return type and parameters must be added afterwards.

Parameters:
name - The method name.
Returns:
The new method object.

getFactory

public EcoreFactory getFactory()
Get the current factory being used to create ecore objects.

Returns:
The current factory.

getClasses

public java.util.List getClasses()
Get a list of all classes in top level package of the current model.

Returns:
A list of EClassifiers.

getDirectSuperTypes

public static java.util.List getDirectSuperTypes(EClass c)
Find a list of all suprclasses which are one level up in the inheritance hierarchy.

Parameters:
c - The class which we are querying.
Returns:
A list of classes which are direct super classes.

getLocalFeatures

public static java.util.List getLocalFeatures(EClass c)
Find a list of attributes which are not inherited from the super classes.

Parameters:
c - The class being queried.
Returns:
A list of attributes which are local to class c.

clear

public void clear()
Reset the model to its initial empty state.


getJavaType

public java.lang.String getJavaType(java.lang.String type)
A lookup function to convert ecore types to regular Java types.

Parameters:
type - The ecore type to lookup.
Returns:
A string representing the equivalent Java type if it exists, othewise the original ecore type.

exportXMI

public boolean exportXMI(java.lang.String uri)
Serializes a Model to disk as an XMI file.

Parameters:
uri - The location to save the file.
Returns:
Whether the serialization was successful.

importXMI

public Model importXMI(java.lang.String uri)
Deserialize an existing XMI file into an ecore Model.

Parameters:
uri - The path to the existing XMI file.
Returns:
A new Model if possible, otherwise null.