Class SpecGenerator
- java.lang.Object
-
- org.eclipse.epsilon.hutn.xmi.parser.generator.SpecGenerator
-
public class SpecGenerator extends java.lang.Object
Generates a HUTN spec in a LIFO manner. ClassObjects are generated using
#generateTopLevelClassObject(String)
and#generateContainedClassObject(String, String)
.Before generating any ClassObjects, the generator must first be initialised using
initialise()
orinitialise(String)
.To nest class objects, first use a call to
#generateTopLevelClassObject(String)
and then add levels of nesting with#generateContainedClassObject(String)
.A call to
stopGeneratingCurrentClassObject()
completes the generation of the current class object. Furthermore, the next class object to be generated will have the same parent as the last class object to be generated.Example: To generate the following structure:
Family { members: Person { dog: Dog {} }, Person {} }
the following calls would be made:initialise("families"); generateTopLevelClassObject("Family"); generateContainedClassObject("Person"); generateContainedClassObject("Dog"); stopGeneratingCurrentClassObject(); // Dog stopGeneratingCurrentClassObject(); // Person generateContainedClassObject("Person"); stopGeneratingCurrentClassObject(); stopGeneratingCurrentClassObject(); // Family
The last two lines are optional, if no further ClassObjects are to be generated.- Author:
- lrose
-
-
Constructor Summary
Constructors Constructor Description SpecGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeValue(java.lang.String featureName, java.lang.String value, int lineNumber)
void
generateContainedClassObject(java.lang.String containingFeature, java.lang.String identifier, int lineNumber)
Generates a new ClassObject whose type is determined by inspecting the class of the parent ClassObject.void
generateContainedClassObject(java.lang.String containingFeature, java.lang.String identifier, java.lang.String type, int lineNumber)
Generates a new ClassObject with the type specified.void
generateTopLevelClassObject(java.lang.String identifier, java.lang.String type, int lineNumber)
ClassObject
getCurrentClassObject()
Spec
getSpec()
boolean
hasCurrentClassObject()
void
initialise()
void
initialise(java.lang.String nsUri)
void
stopGeneratingAndDeleteCurrentClassObject()
void
stopGeneratingCurrentClassObject()
-
-
-
Method Detail
-
getSpec
public Spec getSpec()
-
initialise
public void initialise()
-
initialise
public void initialise(java.lang.String nsUri)
-
generateTopLevelClassObject
public void generateTopLevelClassObject(java.lang.String identifier, java.lang.String type, int lineNumber)
-
generateContainedClassObject
public void generateContainedClassObject(java.lang.String containingFeature, java.lang.String identifier, int lineNumber)
Generates a new ClassObject whose type is determined by inspecting the class of the parent ClassObject. If no feature with the name specified can be found in the class of the parent ClassObject, the newly generated ClassObject will have type "UnknownType".- Parameters:
containingFeature
- - the name of the feature in the parent ClassObject that will contain the newly generatedidentifier
- - the identifier for the ClassObject to be created. Identifiers are used when adding values to reference slots. null is allowed, but this will create a ClassObject that cannot be referenced. ClassObject.
-
generateContainedClassObject
public void generateContainedClassObject(java.lang.String containingFeature, java.lang.String identifier, java.lang.String type, int lineNumber)
Generates a new ClassObject with the type specified. The newly generated ClassObject will be placed in a ContainmentSlot, with the feature specified, of the parent ClassObject.
If the parent ClassObject contains an existing ContainmentSlot with the feature specified, the newly generated ClassObject will be added to the values of that slot. Otherwise, a new ContainmentSlot with the feature specified will be created.
- Parameters:
type
- - the type of ClassObject to be generated.containingFeature
- - the name of the feature in the parent ClassObject that will contain the newly generated ClassObject.identifier
- - the identifier for the ClassObject to be created. Identifiers are used when adding values to reference slots. null is allowed, but this will create a ClassObject that cannot be referenced.lineNumber
- - the line number of the generated ClassObject
-
getCurrentClassObject
public ClassObject getCurrentClassObject()
-
hasCurrentClassObject
public boolean hasCurrentClassObject()
-
stopGeneratingCurrentClassObject
public void stopGeneratingCurrentClassObject()
-
stopGeneratingAndDeleteCurrentClassObject
public void stopGeneratingAndDeleteCurrentClassObject()
-
addAttributeValue
public void addAttributeValue(java.lang.String featureName, java.lang.String value, int lineNumber)
-
-