jaxx.compiler
Class JAXXCompilerLaunchor

java.lang.Object
  extended by jaxx.compiler.JAXXCompilerLaunchor

public class JAXXCompilerLaunchor
extends java.lang.Object

Author:
chemit

Nested Class Summary
protected static class JAXXCompilerLaunchor.LifeCycle
           
 
Field Summary
protected  java.lang.String[] classNames
          original list of classes to compile
protected  int compilerCount
           
protected  java.util.Map<java.lang.String,JAXXCompiler> compilers
          Maps the names of classes being compiled to the compiler instance handling the compilation.
protected  JAXXCompilerLaunchor.LifeCycle currentPass
           
protected  int errorCount
           
protected  java.io.File[] files
          original list of files to compile
protected  java.util.List<java.lang.String> jaxxFileClassNames
          Class names corresponding to the files in the jaxxFiles list.
protected  java.util.List<java.io.File> jaxxFiles
          Files to be treated while compilation.
protected static org.apache.commons.logging.Log log
          log
protected  CompilerOptions options
          options of the launchor and underlines compilers
protected  JAXXProfile profiler
           
protected static JAXXCompilerLaunchor singleton
          shared instance of unique launchor at a givne time.
protected  java.util.Map<java.io.File,SymbolTable> symbolTables
          Maps the names of classes being compiled to their symbol tables (created after the first compiler pass).
protected  int warningCount
           
 
Constructor Summary
protected JAXXCompilerLaunchor(java.io.File[] files, java.lang.String[] classNames, CompilerOptions options)
           
 
Method Summary
static void addProfileTime(JAXXCompiler compiler, java.lang.String key)
           
 boolean compile()
          Compiled a set of files.
static JAXXCompiler createDummyCompiler()
          Creates a dummy Compiler for use in unit testing.
static JAXXCompiler createDummyCompiler(java.lang.ClassLoader classLoader)
          Creates a dummy Compiler for use in unit testing.
static JAXXCompilerLaunchor get()
           
protected  JAXXCompiler getCompiler(java.lang.String className, java.lang.String message)
           
 int getCompilerCount()
           
 JAXXCompiler getJAXXCompiler(java.lang.String className)
           
 java.lang.String getLineSeparator()
          Returns the system line separator string.
 SymbolTable getSymbolTable(java.lang.String className)
           
 java.lang.String getVersion()
           
 void init()
           
static boolean isRegistred()
           
static void loadLibraries(boolean verbose)
          Load the Initializer services found via theServiceLoader mecanism.
protected  JAXXCompiler newCompiler(java.io.File parentFile, java.io.File file, java.lang.String className)
           
static JAXXCompilerLaunchor newLaunchor()
          Create a new empty launchor and set it as current launchor accessible via method get()
static JAXXCompilerLaunchor newLaunchor(java.io.File[] files, java.lang.String[] classNames, CompilerOptions options)
          Create a new launchor and set it as current launchor accessible via method get().
static JAXXCompilerLaunchor newLaunchor(java.io.File base, java.lang.String[] relativePaths, CompilerOptions options)
          Create a new launchor and set it as current launchor accessible via method get().
protected  boolean nextStep(JAXXCompilerLaunchor.LifeCycle nextCycle, boolean success)
           
protected  boolean report(boolean success)
           
protected  void reset()
          Resets all state in preparation for a new compilation session.
protected static void showUsage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
log


singleton

protected static JAXXCompilerLaunchor singleton
shared instance of unique launchor at a givne time.


options

protected CompilerOptions options
options of the launchor and underlines compilers


files

protected final java.io.File[] files
original list of files to compile


classNames

protected final java.lang.String[] classNames
original list of classes to compile


jaxxFiles

protected java.util.List<java.io.File> jaxxFiles
Files to be treated while compilation.


jaxxFileClassNames

protected java.util.List<java.lang.String> jaxxFileClassNames
Class names corresponding to the files in the jaxxFiles list.


compilers

protected java.util.Map<java.lang.String,JAXXCompiler> compilers
Maps the names of classes being compiled to the compiler instance handling the compilation.


symbolTables

protected java.util.Map<java.io.File,SymbolTable> symbolTables
Maps the names of classes being compiled to their symbol tables (created after the first compiler pass).


currentPass

protected JAXXCompilerLaunchor.LifeCycle currentPass

errorCount

protected int errorCount

warningCount

protected int warningCount

compilerCount

protected int compilerCount

profiler

protected JAXXProfile profiler
Constructor Detail

JAXXCompilerLaunchor

protected JAXXCompilerLaunchor(java.io.File[] files,
                               java.lang.String[] classNames,
                               CompilerOptions options)
Method Detail

newLaunchor

public static JAXXCompilerLaunchor newLaunchor()
Create a new empty launchor and set it as current launchor accessible via method get()

Returns:
the new instanciated launchor

newLaunchor

public static JAXXCompilerLaunchor newLaunchor(java.io.File base,
                                               java.lang.String[] relativePaths,
                                               CompilerOptions options)
Create a new launchor and set it as current launchor accessible via method get().

The launchor will be prepared to compile a set of files, expressed as paths relative to a base directory. The class names of the compiled files are derived from the relative path strings (e.g. "example/Foo.jaxx" compiles into a class named "example.Foo").

Parameters:
base - the directory against which to resolve relative paths
relativePaths - a list of relative paths to .jaxx files being compiled
options - the compiler options to use
Returns:
the new instanciated launchor

newLaunchor

public static JAXXCompilerLaunchor newLaunchor(java.io.File[] files,
                                               java.lang.String[] classNames,
                                               CompilerOptions options)
Create a new launchor and set it as current launchor accessible via method get().

The launchor will be prepared to compile a set of files, with the class names specified explicitly. The class compiled from files[i] will be named classNames[i].

Parameters:
files - the .jaxx files to compile
classNames - the names of the classes being compiled
options - the compiler options to use
Returns:
the new instanciated launchor

get

public static JAXXCompilerLaunchor get()
                                throws java.lang.NullPointerException
Returns:
the current launchor
Throws:
java.lang.NullPointerException - if no launchor was registred via a newLaunchor-like method.

isRegistred

public static boolean isRegistred()
Returns:
if there is a launchor registred, false otherwise.

loadLibraries

public static void loadLibraries(boolean verbose)
Load the Initializer services found via theServiceLoader mecanism.

Parameters:
verbose - true to print initializers

init

public void init()

reset

protected void reset()
Resets all state in preparation for a new compilation session.


getVersion

public java.lang.String getVersion()

createDummyCompiler

public static JAXXCompiler createDummyCompiler()
Creates a dummy Compiler for use in unit testing.

Returns:
the compiler

createDummyCompiler

public static JAXXCompiler createDummyCompiler(java.lang.ClassLoader classLoader)
Creates a dummy Compiler for use in unit testing.

Parameters:
classLoader - class loader to use
Returns:
the compiler

getJAXXCompiler

public JAXXCompiler getJAXXCompiler(java.lang.String className)
Parameters:
className - the name of the class to use
Returns:
the compiler instance which is processing the specified JAXX class. Each class is compiled by a different compiler instance.

getSymbolTable

public SymbolTable getSymbolTable(java.lang.String className)
Parameters:
className - the name of the class to use
Returns:
the symbol table for the specified JAXX class. Must be called during the second compiler pass. Returns null if no such symbol table could be found.

getLineSeparator

public java.lang.String getLineSeparator()
Returns the system line separator string.

Returns:
the string used to separate lines

compile

public boolean compile()
Compiled a set of files.

Returns:
true if compilation succeeds, false otherwise

getCompilerCount

public int getCompilerCount()

getCompiler

protected JAXXCompiler getCompiler(java.lang.String className,
                                   java.lang.String message)

nextStep

protected boolean nextStep(JAXXCompilerLaunchor.LifeCycle nextCycle,
                           boolean success)

report

protected boolean report(boolean success)

newCompiler

protected JAXXCompiler newCompiler(java.io.File parentFile,
                                   java.io.File file,
                                   java.lang.String className)
                            throws java.lang.reflect.InvocationTargetException,
                                   java.lang.IllegalAccessException,
                                   java.lang.InstantiationException,
                                   java.lang.NoSuchMethodException
Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.NoSuchMethodException

addProfileTime

public static void addProfileTime(JAXXCompiler compiler,
                                  java.lang.String key)

showUsage

protected static void showUsage()


Copyright © 2008-2009 CodeLutin. All Rights Reserved.