public class JAXXCompiler extends Object
| Modifier and Type | Field and Description |
|---|---|
protected File |
baseDir
Base directory used for path resolution (normally the directory in
which the .jaxx file resides).
|
protected DataBindingHelper |
bindingHelper
Binding Util
|
protected StringBuilder |
bodyCode
Extra code to be added to the class body.
|
static String |
BORDER_LAYOUT_PREFIX |
protected ClassLoader |
classLoader
ClassLoader which searches the user-specified class path in
addition to the normal class path
|
protected CompilerConfiguration |
defaultConfiguration |
protected CompiledObjectDecorator |
defaultDecorator
default decodator to use if none specified
|
protected Document |
document
Parsed XML of src file.
|
protected JAXXEngine |
engine
engine which references this compiler
(can be null if compiler is standalone)
|
protected Map<EventHandler,String> |
eventHandlerMethodNames
Map of event handler method names used in compiler
|
protected Map<String,Map<ClassDescriptor,List<EventHandler>>> |
eventHandlers
Maps objects (expressed in Java code) to event listener classes
(e.g.
|
protected boolean |
failed
flag to detect if an error occurs while compiling jaxx file
|
protected DefaultObjectHandler |
firstPassClassTagHandler
The unique object handler used in first pass
|
protected boolean |
identCssFound
Flag to know if jaxx file ident css was found, otherwise add it
at the end of the second compile pass.
|
protected IDHelper |
idHelper
to generate ids
|
protected Map<CompiledObject,String> |
ids
Maps objects to their ID strings.
|
protected Set<String> |
importedClasses
Contains strings of the form "javax.swing.Timer"
|
protected Set<String> |
importedPackages
Contains strings of the form "javax.swing."
|
protected StringBuilder |
initializer
Extra code to be added to the instance initializer.
|
protected List<Runnable> |
initializers
A list of Runnables which will be run after the first compilation pass.
|
static int |
INLINE_THRESHOLD
Maximum length of an inlinable creation method.
|
protected List<Rule> |
inlineStyles
Contains all attributes defined inline on class tags.
|
protected JavaFile |
javaFile
the file to be generated
|
static String |
JAXX_INTERNAL_NAMESPACE |
static String |
JAXX_NAMESPACE |
protected JAXXCompilerFile |
jaxxFile |
protected StringBuilder |
lateInitializer
Extra code to be added at the end of the instance initializer.
|
protected static String |
lineSeparator
Line separator cached value
|
protected static org.apache.logging.log4j.Logger |
log
Logger
|
protected boolean |
mainDeclared
true if a main() method has been declared in a script
|
protected boolean |
needSwingUtil
Deprecated.
since 2.4.1, will be removed in version 3.0, it is not a good
idea to do special treatment for a particular class, to use SwingUtil,
do like for other class : import it!
|
protected Map<String,CompiledObject> |
objects
Maps object ID strings to the objects themselves.
|
protected Stack<CompiledObject> |
openComponents
Keeps track of open components (components still having children added).
|
protected String |
outputClassName
Name of class being compiled.
|
protected CompiledObject |
root
Object corresponding to the root tag in the document.
|
protected ScriptManager |
scriptManager
script manager
|
protected Stack<File> |
sourceFiles
Used for error reporting purposes, so we can report the right source file.
|
protected File |
src
jaxx file being compiled.
|
static boolean |
STRICT_CHECKS
True to throw exceptions when we encounter unresolvable classes,
false to ignore.
|
protected Stylesheet |
stylesheet
Combination of all stylesheets registered using
registerStylesheet(Stylesheet). |
protected SymbolTable |
symbolTable
table of symbols for this compiler
|
protected Stack<Element> |
tagsBeingCompiled
Used for error reporting purposes, so we can report the right line number.
|
protected String |
uiHandler |
| Constructor and Description |
|---|
JAXXCompiler() |
JAXXCompiler(JAXXEngine engine,
JAXXCompilerFile jaxxFile,
List<String> defaultImports)
Creates a new JAXXCompiler.
|
public static final String JAXX_NAMESPACE
public static final String JAXX_INTERNAL_NAMESPACE
public static final int INLINE_THRESHOLD
public static final String BORDER_LAYOUT_PREFIX
protected static final org.apache.logging.log4j.Logger log
protected static final String lineSeparator
public static boolean STRICT_CHECKS
This is currently set to false until JAXX has full support for inner classes (including enumerations), because currently they don't always resolve (but will generally run without error anyway).
protected final DefaultObjectHandler firstPassClassTagHandler
protected final Set<String> importedPackages
protected final Set<String> importedClasses
protected final Stack<CompiledObject> openComponents
protected final IDHelper idHelper
protected final DataBindingHelper bindingHelper
protected final SymbolTable symbolTable
protected final File baseDir
protected final File src
protected final String outputClassName
protected final ScriptManager scriptManager
protected final List<Rule> inlineStyles
protected final Map<String,Map<ClassDescriptor,List<EventHandler>>> eventHandlers
protected final Map<EventHandler,String> eventHandlerMethodNames
protected final List<Runnable> initializers
This is primarily used to trigger the creation of CompiledObjects, which cannot be created during the first pass and must be created in document order.
protected final StringBuilder initializer
protected final StringBuilder lateInitializer
protected final StringBuilder bodyCode
protected final Stack<Element> tagsBeingCompiled
protected final Stack<File> sourceFiles
protected final Map<String,CompiledObject> objects
These are created during the second compilation pass.
protected final Map<CompiledObject,String> ids
These are created during the second compilation pass.
protected final JAXXEngine engine
protected final CompilerConfiguration defaultConfiguration
protected final JAXXCompilerFile jaxxFile
protected boolean failed
protected CompiledObject root
protected Document document
protected Stylesheet stylesheet
registerStylesheet(Stylesheet).protected ClassLoader classLoader
protected boolean mainDeclared
protected JavaFile javaFile
protected CompiledObjectDecorator defaultDecorator
protected boolean identCssFound
@Deprecated protected boolean needSwingUtil
protected String uiHandler
public JAXXCompiler()
public JAXXCompiler(JAXXEngine engine, JAXXCompilerFile jaxxFile, List<String> defaultImports)
engine - engine which use the compiler (could be null if not attach to any engine)jaxxFile - the file to compiledefaultImports - list of default imports to add to java filespublic static String getLineSeparator()
public static String getCanonicalName(ClassDescriptor clazz)
public static String getCanonicalName(CompiledObject compiled)
public static String escapeJavaString(String raw)
raw - the raw string to be escapepublic static SAXParser getSAXParser()
public static Document parseDocument(InputStream in) throws IOException, SAXException
IOExceptionSAXExceptionpublic void runInitializers()
public void registerInitializer(Runnable r)
Runnable which will be executed after the first
compilation pass is complete.r - runnable to registerpublic void compileFirstPass(Element tag) throws IOException
IOExceptionpublic void compileSecondPass(Element tag) throws IOException
IOExceptionpublic void compileFirstPass()
throws IOException
IOExceptionpublic void compileSecondPass()
throws IOException
IOExceptionpublic void openComponent(CompiledObject component) throws CompilerException
CompilerExceptionpublic void openComponent(CompiledObject component, String constraints) throws CompilerException
CompilerExceptionpublic void openInvisibleComponent(CompiledObject component)
public CompiledObject getOpenComponent()
public void closeComponent(CompiledObject component)
public void registerCompiledObject(CompiledObject object)
public CompiledObject getCompiledObject(String id)
public boolean inlineCreation(CompiledObject object)
public void checkOverride(CompiledObject object) throws CompilerException
CompilerExceptionpublic DataBindingHelper getBindingHelper()
public void registerEventHandler(EventHandler handler)
public String getEventHandlerMethodName(EventHandler handler)
public void addScriptField(FieldDescriptor field)
public void addScriptMethod(MethodDescriptor method)
public void registerScript(String script) throws CompilerException
CompilerExceptionpublic void registerScript(String script, File sourceFile) throws CompilerException
CompilerExceptionpublic String preprocessScript(String script) throws CompilerException
CompilerExceptionpublic boolean isIdentCssFound()
public void registerStyleSheetFile(URL styleFile, boolean warnAutoCssImport)
public void applyStylesheets()
public void registerStylesheet(Stylesheet stylesheet)
public void addInlineStyle(CompiledObject object, String propertyName, boolean dataBinding)
public void reportWarning(String warning)
public void reportError(String error)
public void reportError(CompilerException ex)
public void reportError(String extraMessage, CompilerException ex)
public void reportError(int lineNumber,
String error)
public Map<String,CompiledObject> getObjects()
public Map<String,Map<ClassDescriptor,List<EventHandler>>> getEventHandlers()
public CompilerConfiguration getConfiguration()
public String getOutputClassName()
public File getBaseDir()
public Iterator<CompiledObject> getObjectCreationOrder()
public CompiledObject getRootObject()
public ScriptManager getScriptManager()
public SymbolTable getSymbolTable()
public Stylesheet getStylesheet()
public FieldDescriptor getScriptField(String fieldName)
public MethodDescriptor getScriptMethod(String methodName)
public boolean isFailed()
public ClassLoader getClassLoader()
ClassLoader which searches the user-specified
class path in addition to the normal system class path.ClassLoader to use while resolving class referencespublic void setClassLoader(ClassLoader classLoader)
public boolean isSuperClassAware(Class<?> type)
type.
Note: If no super-class exist, then returns
false.
type - the type to check against super classtrue if super class exists and is assignable against the
given type, false otherwiseClassNotFoundException - if could not find class descriptor for
super-classpublic JAXXObjectDescriptor getJAXXObjectDescriptor()
public StringBuilder getInitializer()
public StringBuilder getLateInitializer()
public StringBuilder getBodyCode()
public boolean isMainDeclared()
public void setMainDeclared(boolean mainDeclared)
public void appendInitializerCode(String code)
public void appendBodyCode(String code)
public void appendLateInitializer(String code)
public void addImport(Class<?> clazz)
public void addImport(String text)
protected void addDefaultImport(String text)
public void addDependencyClass(String className)
public String loadFile(File file)
Note: If any errors encounters, then report an error in the compiler and returns an empty string.
file - the file to loadpublic String checkJavaCode(String javaCode)
A warning is generated if the string has enclosing curly braces.
javaCode - the Java code snippet to testCompilerException - if the code cannot be parsedpublic boolean checkReference(Element tag, String reference, boolean strict, String attribute)
tag - the current tagreference - the required referencestrict - flag to report an error if reference was not foundattribute - (if not null reference the attribute where is defined
the reference)true if reference was found, false
otherwise and add an error in compilerpublic String[] getExtraInterfaces()
public void setExtraInterfaces(String[] extraInterfaces)
public boolean isAbstractClass()
public void setAbstractClass(boolean abstractClass)
public String getGenericType()
public void setGenericType(String genericType)
public String getSuperGenericType()
public void setSuperGenericType(String superGenericType)
public void addSimpleField(JavaField javaField)
public JavaFile getJavaFile()
public void generate(JavaFileGenerator generator) throws IOException
IOExceptionpublic JAXXEngine getEngine()
public void clear()
public String getImportedType(Class<?> type)
If import can not be done, will then returns the fully qualified name of the type.
type - the type to simplifypublic String getImportedType(String type)
If import can not be done, will then returns the fully qualified name of the type.
type - the fqn of the type to simplifypublic String getUiHandler()
public void setUiHandler(String uiHandler)
public String getUIHandlerWithGeneric()
public boolean isUseHandler()
public String computeI18nProperty(CompiledObject editorName)
public String getI18nProperty(CompiledObject compiledObject)
public String processDataBindings(String stringValue) throws CompilerException
CompilerExceptionpublic void setI18n(String i18n)
public void registerBeanScope(BeanScope beanScope)
public void removeBeanScope()
Copyright © 2008–2019 Ultreia.io. All rights reserved.