Package eu.bandm.tools.umod
Class Factory
java.lang.Object
eu.bandm.tools.umod.Factory
Collection of methods for easy programmatic creation of a umod model description.
Usage:
((FIXME: these further stages of processing could be integrated in this Factory by further convenience wrapper methods, if desired.))
The original umod model is a umod model itself, and is accessible throughout by the field
The basic umod rules are tested anyhow:
The additional rules imposed by the umod parser front-end are ensured additionally, if parameter
- Create an instance of this class.
- Create the meta-model by its methods.
- call
new Checker.check(myFactory.model, msg)
- call
GeneratedPackage gp = new UMod2Java().translate(myFactory.model)
- call
new Unparser.write(gp)
((FIXME: these further stages of processing could be integrated in this Factory by further convenience wrapper methods, if desired.))
The original umod model is a umod model itself, and is accessible throughout by the field
model
.
The umod model classes defined in UMod
are returned as results and
accessible via model
and can be manipulated directly, if required.
But the factory methods are preferred, because of implied consistency.
The basic umod rules are tested anyhow:
- There is one single namespace for the model itself, model clases, enumerations, imports, exported interfaces, and visitor base classes. Identifiers are unique among all these.
- No shadowing/re-usage of field names on a path to the classs tree root(s).
The additional rules imposed by the umod parser front-end are ensured additionally, if parameter
parserLike
is set to true:
- Field names start lower case; class names start upper case.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
A convenience wrapper for the different combinations of boolean attributes of visitor definitions. -
Field Summary
Modifier and TypeFieldDescriptionfinal UMod.Forest
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>>
final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddClassDef
(UMod.ClassDef superclass, String name, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc, boolean isAlgebraic, boolean isAbstract) Add a class definition to the model.void
addDocumentation
(UMod.Item item, String text) Append a String to the documentation sequence of the model itself, a Class/Enumeration/Visitor/Interface definition, or a Field definition.addEnumDef
(String name, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc) Add an enumeration definition to the model.addEnumDef
(String name, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc, String... items) Add an enumeration definition plus some/all of its enumeration values to the model.void
addEnumItem
(UMod.EnumDef edef, String name, @Opt String doc) Add a further enumeration value to an already defined enumeration type.addExternalDeclaration
(String name, @Opt Location<XMLDocumentIdentifier> loc) Add an external declaration to the model.addFieldDef
(UMod.ClassDef cls, String name, UMod.ClassDef fieldType, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc) addFieldDef
(UMod.ClassDef cls, String name, UMod.Type fieldType, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc) Add a field definition to a class definition.void
addJavaText
(UMod.ClassDef cd, String text, @Opt Location<XMLDocumentIdentifier> loc) Add a verbatim java block, either to a class definition's code, or to the top-level model classs, ifcd==null
.void
addTostringText
(UMod.ClassDef cd, String text, @Opt Location<XMLDocumentIdentifier> loc) Add a standardtoString()
method to the class definition's code.addVisitorDef
(String name, @Opt Location<XMLDocumentIdentifier> loc, @Opt String doc, @Opt Factory.VisitorFlavours flavour, int number) Add a base visitor definition to the model.void
addVisitorRegister
(UMod.FieldDef field, int num, int pos, @Opt String lr) Add a visitor register number to a field.protected void
opt_addDocumentation
(UMod.Item item, @Opt String text) protected void
Add definition into the one, unified toplevel namespace.void
setDocumentation
(UMod.EnumDef def, String item, String text) Put the string value as (the only!) doc text of the enumeration item.protected void
synterror
(Location<XMLDocumentIdentifier> loc, String txt)
-
Field Details
-
model
-
parserLike
public final boolean parserLike -
msg
-
-
Constructor Details
-
Factory
-
-
Method Details
-
putDef
Add definition into the one, unified toplevel namespace. -
synterror
-
addDocumentation
Append a String to the documentation sequence of the model itself, a Class/Enumeration/Visitor/Interface definition, or a Field definition. (Enumeration items are no subclass of UMod.Item and thus not covered by this method.) -
setDocumentation
Put the string value as (the only!) doc text of the enumeration item. -
opt_addDocumentation
-
addExternalDeclaration
public UMod.ExtDeclaration addExternalDeclaration(String name, @Opt @Opt Location<XMLDocumentIdentifier> loc) Add an external declaration to the model. -
addVisitorDef
public UMod.VisitorHint addVisitorDef(String name, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc, @Opt @Opt Factory.VisitorFlavours flavour, int number) Add a base visitor definition to the model. -
addVisitorRegister
Add a visitor register number to a field. Double use of pos is NOT prevented, but means undetermined sequential order. -
addEnumDef
public UMod.EnumDef addEnumDef(String name, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc) Add an enumeration definition to the model. The uniqueness of the name is tested immediately. -
addEnumDef
public UMod.EnumDef addEnumDef(String name, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc, String... items) Add an enumeration definition plus some/all of its enumeration values to the model. The uniqueness of the ernumeration's name is tested immediately. FIXME UNIUQE enumitemname TEST !? -
addEnumItem
Add a further enumeration value to an already defined enumeration type. FIXME UNIUQE enumitemname TEST !? -
addClassDef
public UMod.ClassDef addClassDef(@Opt UMod.ClassDef superclass, String name, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc, boolean isAlgebraic, boolean isAbstract) Add a class definition to the model. The uniqueness of the name is tested immediately. -
addJavaText
public void addJavaText(@Opt UMod.ClassDef cd, String text, @Opt @Opt Location<XMLDocumentIdentifier> loc) Add a verbatim java block, either to a class definition's code, or to the top-level model classs, ifcd==null
. -
addTostringText
public void addTostringText(UMod.ClassDef cd, String text, @Opt @Opt Location<XMLDocumentIdentifier> loc) Add a standardtoString()
method to the class definition's code. -
addFieldDef
public UMod.FieldDef addFieldDef(UMod.ClassDef cls, String name, UMod.Type fieldType, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc) Add a field definition to a class definition. The uniqueness of field names is tested later, by theChecker
. The type of the field can be constructed by the constructors of the sub-classes ofUMod.TypeConstructed
, applied recursively, and to the constantsUMod.BOOL
,UMod.CHAR
,UMod.FLOAT
,UMod.INT
andUMod.STRING
.
(All these can be looked up by their umod-frontend name fromReducer.predefinedTypes
. -
addFieldDef
public UMod.FieldDef addFieldDef(UMod.ClassDef cls, String name, UMod.ClassDef fieldType, @Opt @Opt Location<XMLDocumentIdentifier> loc, @Opt @Opt String doc)
-