|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object types.LangDef
public abstract class LangDef
LangDef is the abstract class that all Language Definitions inherit from. It contains several utility methods and one method stub, generateCode, which is called by the Controller and returns a double array of strings, with the first entry corresponding to the file name to be outputted to, and the second entry corresponding to the contents of that file.
Field Summary | |
---|---|
protected ErrorHandler |
errorHandler
The ErrorHandler to use for reporting errors. |
protected Set<String> |
imports
A running list of all the distinct import statements required by various Widgets within the code. |
protected Set<String> |
innerClasses
A running list of all the distinct inner classes to be included in the final generated code. |
protected String |
libPath
The pathname to the language's lib folder. |
protected Set<String> |
modifiers
A running list of all the distinct modifiers to be included in the final generated code. |
protected Set<String> |
variables
A running list of all the distinct fields to be included in the final generated code. |
Constructor Summary | |
---|---|
protected |
LangDef(String libPath)
|
protected |
LangDef(String libPath,
Set<String> imports,
Set<String> modifiers,
Set<String> innerClasses,
Set<String> variables)
|
Method Summary | |
---|---|
protected String |
createWidget(Widget widget)
createWidget is a utility method included to cut down on potential code duplication. |
protected String |
createWidget(Widget widget,
WidgetDef parentDef)
Create a widget which may have child attributes granted by its parent widget. |
static LangDef |
defineLanguage(String lang)
Get a LangDef instance for the specified language. |
abstract String[][] |
generateCode(GUIFile guiFile,
ErrorHandler errorHandler)
generateCode accepts the generated Parser output and manipulates it according to the structure of the language to generate the appropriate output code. |
String |
getLibPath()
|
abstract Class<? extends WidgetDef> |
getRootWidgetType()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final String libPath
protected final Set<String> imports
protected final Set<String> modifiers
protected final Set<String> variables
protected final Set<String> innerClasses
protected ErrorHandler errorHandler
ErrorHandler
to use for reporting errors.
Constructor Detail |
---|
protected LangDef(String libPath, Set<String> imports, Set<String> modifiers, Set<String> innerClasses, Set<String> variables)
libPath
- The package prefix for the widget library.imports
- The set to use for imports
.modifiers
- The set to use for modifiers
.innerClasses
- The set to use for innerClasses
.variables
- The set to use for variables
.protected LangDef(String libPath)
libPath
- The package prefix for the widget library.Method Detail |
---|
public abstract String[][] generateCode(GUIFile guiFile, ErrorHandler errorHandler) throws GUIFileException
guiFile
- A GUIFile object, as returned by the parser.errorHandler
- The ErrorHandler
object to use for reporting
errors.
GUIFileException
- If any errors are found in the file.public abstract Class<? extends WidgetDef> getRootWidgetType()
protected String createWidget(Widget widget) throws GUIFileException
widget
- The widget from the GUIFile
to create.
BadAttributeException
- If an invalid attribute is given.
BadWidgetTypeException
- If the widget type does not exist.
BadChildWidgetException
- For an incompatible child type.
GUIFileException
protected String createWidget(Widget widget, WidgetDef parentDef) throws GUIFileException
widget
- The widget to generate code for.parentDef
- The widget definition for the widget's parent, or
null
; if null
then do not allow any child
attributes.
GUIFileException
WidgetDef.getChildDefaults()
public String getLibPath()
public static LangDef defineLanguage(String lang)
lang
- The name of the language, for instance "Java".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |