edu.neu.ccs.demeter.tools.daj
Class DAJ

java.lang.Object
  |
  +--edu.neu.ccs.demeter.tools.daj.DAJ

public class DAJ
extends Object

The main DAJ functionality.


Method Summary
static int compile(String[] args)
          Compile a DAJ project.
static void compileAspects(String ajc, List argList)
          Compile a list of aspects.
static void compileStubs(String ajc, List traversalFiles, File stubsDirectory, List aspectFiles, List AJCOptions, File destinationDirectory)
          Compile the generated stub aspects along with the source aspects.
static void compileTraversals(String ajc, List traversalFiles, File traversalsDirectory, List aspectFiles, List AJCOptions, File destinationDirectory)
          Compile the generated traversal aspects along with the source aspects.
static File generateClass(ClassGraph cd, String name, ClassDef cl, File gendir)
          Generates a Java source (.java) file for a class defined in a class dictionary.
static void generateClass(ClassGraph cd, String name, ClassDef cl, PrintWriter out)
          Generate a Java class definition for a class defined in a class dictionary.
static List generateClasses(ClassGraph cd, String name, File gendir)
          Generates a Java source (.java) file for each class in a class dictionary.
static File generateExpandedClassDictionary(ClassGraph cd, String name, File gendir)
          Generate an expanded class dictionary (.xcd) file from a class dictionary.
static void generateExpandedClassDictionary(ClassGraph cd, String name, PrintWriter out)
          Generate an expanded class dictionary (.xcd) from a class dictionary.
static File generateGrammar(ClassGraph cd, String name, File gendir)
          Generate an ANTLR grammar (.g) file from a class dictionary.
static void generateGrammar(ClassGraph cd, String name, PrintWriter out)
          Generate an ANTLR grammar from a class dictionary.
static List generateParser(File grammar, File gendir)
          Generate parser and lexer Java files from an ANTLR grammar (.g) file.
static List generateParsers(List grammarFiles, File gendir)
          Generate parser and lexer Java files from ANTLR grammar (.g) files.
static File generateParsingAspect(ClassGraph cd, String name, File gendir)
          Generate an AspectJ aspect (.java) file for parsing from a class dictionary.
static void generateParsingAspect(ClassGraph cd, String name, PrintWriter out)
          Generate an AspectJ aspect definition for parsing from a class dictionary.
static void generateStubs(List traversalFiles, File destinationDirectory)
          Generate a stub aspect file for each traversal file.
static void generateTraversals(List traversalFiles, File stubClassesDirectory, boolean generatePrintingAdvice, File destinationDirectory)
          Generate a traversal aspect file for each traversal file.
static List getAspectFiles(List trvFiles, File gendir)
          A list of generated aspect files.
static List getGrammarFiles(List cdFiles, File gendir)
          A list of generated grammar files.
static void main(String[] args)
          Compile a DAJ project, then exit the VM.
static List processClassDictionaries(List cds, File gendir)
           
static List processClassDictionary(ClassGraph cd, String name, File gendir)
          Process a class dictionary.
static List processClassDictionary(File cd, File gendir)
          Process a class dictionary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(String[] args)
Compile a DAJ project, then exit the VM.

Parameters:
args - command line arguments

compile

public static int compile(String[] args)
Compile a DAJ project.

Parameters:
args - command line arguments
Returns:
the exit code

processClassDictionaries

public static List processClassDictionaries(List cds,
                                            File gendir)
                                     throws ExceptionList
ExceptionList

processClassDictionary

public static List processClassDictionary(File cd,
                                          File gendir)
                                   throws IOException,
                                          ParseException
Process a class dictionary file. Generate a Java source file for each class in a class dictionary, plus an expanded class dictionary (.xcd) file, an ANTLR grammar (.g) file, and an AspectJ parsing aspect file.

Parameters:
cd - a .cd file
gendir - the output directory for the generated Java files
Returns:
a list of generated .java files
IOException
ParseException

processClassDictionary

public static List processClassDictionary(ClassGraph cd,
                                          String name,
                                          File gendir)
                                   throws IOException
Process a class dictionary. Generate a Java source file for each class in a class dictionary, plus an expanded class dictionary (.xcd) file, an ANTLR grammar (.g) file, and an AspectJ parsing aspect file.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
gendir - the output directory for the generated files
Returns:
a list of generated .java files
IOException

generateExpandedClassDictionary

public static File generateExpandedClassDictionary(ClassGraph cd,
                                                   String name,
                                                   File gendir)
                                            throws IOException
Generate an expanded class dictionary (.xcd) file from a class dictionary.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
gendir - the output directory for the generated file
Returns:
the generated file
IOException

generateExpandedClassDictionary

public static void generateExpandedClassDictionary(ClassGraph cd,
                                                   String name,
                                                   PrintWriter out)
Generate an expanded class dictionary (.xcd) from a class dictionary.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
out - a text output stream

generateGrammar

public static File generateGrammar(ClassGraph cd,
                                   String name,
                                   File gendir)
                            throws IOException
Generate an ANTLR grammar (.g) file from a class dictionary. The names of the parser and lexer will be based on the name of the class dictionary, e.g. if name is Foo then Foo.g will contain FooParser and FooLexer.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
gendir - the output directory for the generated file
Returns:
the generated file
IOException

generateGrammar

public static void generateGrammar(ClassGraph cd,
                                   String name,
                                   PrintWriter out)
Generate an ANTLR grammar from a class dictionary. The names of the parser and lexer will be based on the class dictionary name, e.g. if name is Foo then the output grammar will contain FooParser and FooLexer.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
out - a text output stream

generateParsingAspect

public static File generateParsingAspect(ClassGraph cd,
                                         String name,
                                         File gendir)
                                  throws IOException
Generate an AspectJ aspect (.java) file for parsing from a class dictionary. The aspect name, parser name, and lexer name will be based on the name of the class dictionary, e.g. if name is Foo then the aspect will be named FooParsing and will refer to FooParser and FooLexer.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
gendir - the output directory for the generated file
Returns:
the generated file
IOException

generateParsingAspect

public static void generateParsingAspect(ClassGraph cd,
                                         String name,
                                         PrintWriter out)
Generate an AspectJ aspect definition for parsing from a class dictionary. The aspect name, parser name, and lexer name will be based on the name of the class dictionary, e.g. if name is Foo then the aspect will be named FooParsing and will refer to FooParser and FooLexer.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
out - a text output stream

generateClasses

public static List generateClasses(ClassGraph cd,
                                   String name,
                                   File gendir)
                            throws IOException
Generates a Java source (.java) file for each class in a class dictionary.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
gendir - the output directory for the generated files
Returns:
the list of generated files
IOException

generateClass

public static File generateClass(ClassGraph cd,
                                 String name,
                                 ClassDef cl,
                                 File gendir)
                          throws IOException
Generates a Java source (.java) file for a class defined in a class dictionary.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
cl - a class defined in cd
gendir - the output directory for the generated files
Returns:
the generated file
IOException

generateClass

public static void generateClass(ClassGraph cd,
                                 String name,
                                 ClassDef cl,
                                 PrintWriter out)
Generate a Java class definition for a class defined in a class dictionary.

Parameters:
cd - a class dictionary
name - the name of the class dictionary
cl - a class defined in cd
out - a text output stream

generateParsers

public static List generateParsers(List grammarFiles,
                                   File gendir)
                            throws Exception
Generate parser and lexer Java files from ANTLR grammar (.g) files.

Parameters:
grammarFiles - a list of .g files
gendir - the output directory for the generated files
Returns:
a list of generated .java files
Exception

generateParser

public static List generateParser(File grammar,
                                  File gendir)
                           throws Exception
Generate parser and lexer Java files from an ANTLR grammar (.g) file.

Parameters:
grammar - a .g file
gendir - the output directory for the generated files
Returns:
a list of generated .java files
Exception

generateStubs

public static void generateStubs(List traversalFiles,
                                 File destinationDirectory)
                          throws ExceptionList
Generate a stub aspect file for each traversal file.

Parameters:
traversalFiles - a list of .trv files
destinationDirectory - the output directory for the stubs
ExceptionList

compileStubs

public static void compileStubs(String ajc,
                                List traversalFiles,
                                File stubsDirectory,
                                List aspectFiles,
                                List AJCOptions,
                                File destinationDirectory)
                         throws Exception
Compile the generated stub aspects along with the source aspects.

Parameters:
ajc - the aspect compiler executable, or null to invoke ajc on the class path
traversalFiles - a list of .trv files
stubsDirectory - the directory the stubs were generated into
aspectFiles - a list of aspect source files
AJCOptions - a list of options for the aspect compiler
destinationDirectory - the output directory for the class files
Exception

generateTraversals

public static void generateTraversals(List traversalFiles,
                                      File stubClassesDirectory,
                                      boolean generatePrintingAdvice,
                                      File destinationDirectory)
                               throws Exception
Generate a traversal aspect file for each traversal file.

Parameters:
traversalFiles - a list of .trv files
stubClassesDirectory - the directory the stubs were compiled into
generatePrintingAdvice - should printing advice be generated?
destinationDirectory - the output directory for the traversal aspects
Exception

compileTraversals

public static void compileTraversals(String ajc,
                                     List traversalFiles,
                                     File traversalsDirectory,
                                     List aspectFiles,
                                     List AJCOptions,
                                     File destinationDirectory)
                              throws Exception
Compile the generated traversal aspects along with the source aspects.

Parameters:
ajc - the aspect compiler executable, or null to invoke ajc on the class path
traversalFiles - a list of .trv files
traversalsDirectory - the directory the traversal aspects were generated into
aspectFiles - a list of aspect source files
AJCOptions - a list of options for the aspect compiler
destinationDirectory - the output directory for the class files
Exception

compileAspects

public static void compileAspects(String ajc,
                                  List argList)
                           throws Exception
Compile a list of aspects.

Parameters:
ajc - the aspect compiler executable, or null to invoke ajc on the class path
argList - the command line arguments to the aspect compiler
Exception

getGrammarFiles

public static List getGrammarFiles(List cdFiles,
                                   File gendir)
A list of generated grammar files.

Parameters:
cdFiles - a list of .cd files
gendir - the output directory for generated files
Returns:
a list of .g files

getAspectFiles

public static List getAspectFiles(List trvFiles,
                                  File gendir)
A list of generated aspect files.