de.grogra.rgg.model
Class XLFilter

java.lang.Object
  extended by de.grogra.pf.io.FilterBase
      extended by de.grogra.rgg.model.XLFilter
All Implemented Interfaces:
Filter, FilterSource, ObjectSource, RegistryContext, Map
Direct Known Subclasses:
JavaFilter, LSYFilter, RGGFilter

public class XLFilter
extends FilterBase
implements ObjectSource

An XLFilter parses a character stream representing XL source code into a CompilationUnit. The auxiliary method compile() automatically compiles the resulting compilation unit into the contained types.

Author:
Ole Kniemeyer

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.grogra.pf.io.FilterSource
FilterSource.MetaDataKey<V>
 
Nested classes/interfaces inherited from interface de.grogra.util.Map
Map.Chain
 
Field Summary
static boolean DUMP_TREE
           
 
Fields inherited from class de.grogra.pf.io.FilterBase
item, source
 
Fields inherited from interface de.grogra.pf.io.FilterSource
AUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URL
 
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
 
Constructor Summary
XLFilter(FilterItem item, ReaderSource source)
          Constructs a new filter which transforms the input source into an instance of CompilationUnit which can be compiled afterwards.
 
Method Summary
 Type[] compile()
          Compiles the source of this filter into an array of the types which are declared by the source.
static Type[] compile(java.io.Reader input, java.lang.String systemId)
          This auxiliary method compiles the source code of input to an array of types
protected  de.grogra.xl.parser.Parser createParser(Tokenizer t)
          Creates the parser which will subsequently be used to parse the token stream resulting from t into an abstract syntax tree.
protected  Tokenizer createTokenizer()
          Creates the tokenizer to be used for scanning of the source.
protected  java.lang.String getClassName()
          Derives a legal class name from the sytem id of the source.
protected  ObjectList<Annotation> getEnclosingAnnotations()
           
protected  de.grogra.xl.compiler.scope.Scope getImports(de.grogra.xl.compiler.scope.ClassPath path)
          Constructs the scope which includes all automatic imports.
static de.grogra.xl.compiler.ASMTypeLoader getLoaderForAll()
           
protected  java.lang.Class[] getMemberTypeImports()
          Defines the automatic member type imports (e.g., import java.awt.PageAttributes.
 de.grogra.xl.compiler.CompilationUnit getObject()
          Returns the data as an object of a class which is compatible which the flavor.
protected  java.lang.String[] getPackageImports()
          Defines the automatic package imports (e.g., import java.lang.
protected  java.lang.Class[] getSingleTypeImports()
          Defines the automatic single type imports (e.g., import java.util.Map;).
protected  java.lang.Class[] getStaticTypeImports()
          Defines the automatic static type imports (e.g., import static java.lang.Math.
protected  boolean isD2FWidening()
          Defines whether the conversion from double to float should be considered as widening, i.e., should be done automatically if required.
 
Methods inherited from class de.grogra.pf.io.FilterBase
get, getFilter, getFlavor, getImpl, getMetaData, getRegistry, getSource, getSystemId, initProgressMonitor, setFlavor, setMetaData, setMetaData, setProgress, setSystemId, toString, toURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.pf.io.FilterSource
getFilter, getFlavor, getMetaData, getSystemId, initProgressMonitor, setMetaData, setProgress
 
Methods inherited from interface de.grogra.pf.registry.RegistryContext
getRegistry
 

Field Detail

DUMP_TREE

public static boolean DUMP_TREE
Constructor Detail

XLFilter

public XLFilter(FilterItem item,
                ReaderSource source)
Constructs a new filter which transforms the input source into an instance of CompilationUnit which can be compiled afterwards.

Parameters:
item - the defining item for this filter within the registry, may be null
source - the source from which the input stream of characters will be read
See Also:
getObject(), compile()
Method Detail

compile

public Type[] compile()
               throws java.io.IOException
Compiles the source of this filter into an array of the types which are declared by the source. This included top-level types, nested types, and local and anonymous classes. The returned types are wrappers for true Class objects, i.e., they represent true classes loaded by the Java virtual machine.

Returns:
array of compiled, declared types of the source code
Throws:
java.io.IOException - if source cannot be read or if there is a lexical, syntactic or semantic error

compile

public static Type[] compile(java.io.Reader input,
                             java.lang.String systemId)
                      throws java.io.IOException
This auxiliary method compiles the source code of input to an array of types

Parameters:
input -
systemId -
Returns:
array of compiled, declared types of the source code
Throws:
java.io.IOException - if source cannot be read or if there is a lexical, syntactic or semantic error
See Also:
compile()

createParser

protected de.grogra.xl.parser.Parser createParser(Tokenizer t)
Creates the parser which will subsequently be used to parse the token stream resulting from t into an abstract syntax tree.

Parameters:
t - token stream input
Returns:
parser which parses token stream of t

createTokenizer

protected Tokenizer createTokenizer()
Creates the tokenizer to be used for scanning of the source.

Returns:
tokenizer instance

getClassName

protected java.lang.String getClassName()
Derives a legal class name from the sytem id of the source. May be used in subclasses which implicitly generate such a class name.

Returns:
class name derived from system id of the source

getEnclosingAnnotations

protected ObjectList<Annotation> getEnclosingAnnotations()

getImports

protected de.grogra.xl.compiler.scope.Scope getImports(de.grogra.xl.compiler.scope.ClassPath path)
                                                throws java.lang.ClassNotFoundException
Constructs the scope which includes all automatic imports.

Parameters:
path - class path which defines the existing classes and interfaces
Returns:
scope including automatic imports based on path
Throws:
java.lang.ClassNotFoundException
See Also:
getPackageImports(), getMemberTypeImports(), getSingleTypeImports(), getStaticTypeImports()

getLoaderForAll

public static de.grogra.xl.compiler.ASMTypeLoader getLoaderForAll()

getMemberTypeImports

protected java.lang.Class[] getMemberTypeImports()
Defines the automatic member type imports (e.g., import java.awt.PageAttributes.*;).

Returns:
types whose member types are imported automatically

getObject

public de.grogra.xl.compiler.CompilationUnit getObject()
                                                throws java.io.IOException
Description copied from interface: ObjectSource
Returns the data as an object of a class which is compatible which the flavor.

Specified by:
getObject in interface ObjectSource
Returns:
the data
Throws:
java.io.IOException

getPackageImports

protected java.lang.String[] getPackageImports()
Defines the automatic package imports (e.g., import java.lang.*;). The implementation of XLFilter returns {"java.lang"}.

Returns:
automatic package imports

getSingleTypeImports

protected java.lang.Class[] getSingleTypeImports()
                                          throws java.lang.ClassNotFoundException
Defines the automatic single type imports (e.g., import java.util.Map;).

Returns:
types which are imported automatically
Throws:
java.lang.ClassNotFoundException

getStaticTypeImports

protected java.lang.Class[] getStaticTypeImports()
                                          throws java.lang.ClassNotFoundException
Defines the automatic static type imports (e.g., import static java.lang.Math.*;).

Returns:
types whose static members are imported automatically
Throws:
java.lang.ClassNotFoundException

isD2FWidening

protected boolean isD2FWidening()
Defines whether the conversion from double to float should be considered as widening, i.e., should be done automatically if required.

Returns:
implicit conversion from double to float?