|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjaxx.compiler.JAXXCompiler
public class JAXXCompiler
Compiles JAXX files into Java classes.
useJAXXCompilerFinalizer ... todo finish javadoc
| Field Summary | |
|---|---|
protected File |
baseDir
Base directory used for path resolution (normally the directory in which the .jaxx file resides). |
protected DataBindingHelper |
bindingHelper
Binding Util |
protected StringBuffer |
bodyCode
Extra code to be added to the class body. |
protected ClassLoader |
classLoader
ClassLoader which searches the user-specified class path in addition to the normal class path |
protected CompilerConfiguration |
configuration
configuration of the compiler |
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 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 StringBuffer |
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 StringBuffer |
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.commons.logging.Log |
log
Logger |
protected boolean |
mainDeclared
true if a main() method has been declared in a script |
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
|
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(jaxx.runtime.css.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. |
| Constructor Summary | |
|---|---|
JAXXCompiler(JAXXEngine engine,
File baseDir,
File src,
String outputClassName,
CompilerConfiguration configuration,
List<String> defaultImports)
Creates a new JAXXCompiler. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log log
public static final boolean STRICT_CHECKS
public static final String JAXX_NAMESPACE
public static final String JAXX_INTERNAL_NAMESPACE
public static final int INLINE_THRESHOLD
protected static String lineSeparator
protected final DefaultObjectHandler firstPassClassTagHandler
protected boolean failed
protected CompiledObject root
protected Set<String> importedPackages
protected Set<String> importedClasses
protected Stack<CompiledObject> openComponents
protected final IDHelper idHelper
protected final DataBindingHelper bindingHelper
protected SymbolTable symbolTable
protected File baseDir
protected File src
protected Document document
protected String outputClassName
protected ScriptManager scriptManager
protected Stylesheet stylesheet
registerStylesheet(jaxx.runtime.css.Stylesheet).
protected List<Rule> inlineStyles
protected Map<String,Map<ClassDescriptor,List<EventHandler>>> eventHandlers
protected Map<EventHandler,String> eventHandlerMethodNames
protected ClassLoader classLoader
protected List<Runnable> initializers
protected StringBuffer initializer
protected StringBuffer lateInitializer
protected StringBuffer bodyCode
protected boolean mainDeclared
protected JavaFile javaFile
protected CompilerConfiguration configuration
protected Stack<Element> tagsBeingCompiled
protected Stack<File> sourceFiles
protected Map<String,CompiledObject> objects
protected Map<CompiledObject,String> ids
protected CompiledObjectDecorator defaultDecorator
protected final JAXXEngine engine
| Constructor Detail |
|---|
public JAXXCompiler(JAXXEngine engine,
File baseDir,
File src,
String outputClassName,
CompilerConfiguration configuration,
List<String> defaultImports)
engine - engine which use the compiler (could be null if not attach to any engine)baseDir - classpath locationsrc - location of file to runoutputClassName - the out file nameconfiguration - configuration to pass to javacdefaultImports - list of default imports to add to java files| Method Detail |
|---|
public void runInitializers()
public void registerInitializer(Runnable r)
Runnable which will be executed after the first
compilation pass is complete.
r - runnable to register
public void compileFirstPass(Element tag)
throws IOException
IOException
public void compileSecondPass(Element tag)
throws IOException
IOException
protected void compileFirstPass()
throws IOException
IOException
protected void compileSecondPass()
throws IOException
IOException
public void openComponent(CompiledObject component)
throws CompilerException
CompilerException
public 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
CompilerException
public void registerScript(String script,
File sourceFile)
throws CompilerException
CompilerException
public String preprocessScript(String script)
throws CompilerException
CompilerExceptionpublic void applyStylesheets()
public void registerStylesheet(Stylesheet stylesheet)
public void addInlineStyle(CompiledObject object,
String propertyName,
boolean dataBinding)
public void reportWarning(String warning)
public void reportWarning(Element tag,
String warning,
int lineOffset)
public void reportError(String error)
public void reportError(CompilerException ex)
public void reportError(String extraMessage,
CompilerException ex)
public void reportError(Element tag,
String error)
public void reportError(Element tag,
String error,
int lineOffset)
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 Set<String> getImportedClasses()
public Set<String> getImportedPackages()
public Iterator<CompiledObject> getObjectCreationOrder()
public CompiledObject getRootObject()
public Stack<File> getSourceFiles()
public ScriptManager getScriptManager()
public SymbolTable getSymbolTable()
public Stylesheet getStylesheet()
public FieldDescriptor[] getScriptFields()
public FieldDescriptor getScriptField(String fieldName)
public MethodDescriptor[] getScriptMethods()
public MethodDescriptor getScriptMethod(String methodName)
public boolean isFailed()
public IDHelper getIdHelper()
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 JAXXObjectDescriptor getJAXXObjectDescriptor()
public StringBuffer getInitializer()
public StringBuffer getLateInitializer()
public StringBuffer 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 boolean hasMethod(String methodName)
public void addImport(String text)
public void addDependencyClass(String className)
public String checkJavaCode(String javaCode)
javaCode - the Java code snippet to test
CompilerException - if the code cannot be parsed
public 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 getAutoId(String name)
public String getUniqueId(Object object)
public void setExtraInterfaces(String[] extraInterfaces)
public String[] getExtraInterfaces()
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 finalizeCompiler(Iterable<JAXXCompilerFinalizer> finalizers)
throws Exception
Exception
public void generate(JavaFileGenerator generator)
throws IOException
IOExceptionpublic static String getLineSeparator()
public static String getCanonicalName(Class<?> clazz)
public static String getCanonicalName(ClassDescriptor clazz)
public static String getCanonicalName(CompiledObject compiled)
public static String escapeJavaString(String raw)
raw - the raw string to be escape
public static File URLtoFile(URL url)
public static File URLtoFile(String urlString)
public static SAXParser getSAXParser()
public static Document parseDocument(InputStream in)
throws IOException,
SAXException
IOException
SAXExceptionpublic JAXXEngine getEngine()
public void clear()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||