org.bbqjs.compiler
Class AbstractCompiler<C extends CompilableFile>

java.lang.Object
  extended by org.bbqjs.compiler.AbstractCompiler<C>
All Implemented Interfaces:
Compiler
Direct Known Subclasses:
CSSCompiler, JavaScriptCompiler, LanguageCompiler

public abstract class AbstractCompiler<C extends CompilableFile>
extends Object
implements Compiler


Field Summary
protected  String[] libraries
           
 
Constructor Summary
AbstractCompiler(String[] libraries)
           
 
Method Summary
protected  void afterWrittenLibrariesToOutputStream(List<C> includedFiles, OutputStream outputStream)
          Override this method to perform any post processing or cleanup.
 String compile(URL inputFile, String packageName, String[] sourceRoots)
          Returns a string of the compiled source of the given input file.
protected  void compileToOutputStream(C target, OutputStream outputStream)
          Writes the target file and all files included by the target file into the output stream
protected  void parseInputFile(C file, List<C> includedFiles)
          Gets the passed CompilableFile to tell us which files it expects to include and recursively adds the include file to the list of files to write into the output stream
protected  void writeToOutputStream(List<C> includedFiles, OutputStream outputStream)
          Will write the list of files out into the passed output stream, along with any libraries that have been requested to be included.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.bbqjs.compiler.Compiler
compile
 

Field Detail

libraries

protected String[] libraries
Constructor Detail

AbstractCompiler

public AbstractCompiler(String[] libraries)
Method Detail

compile

public String compile(URL inputFile,
                      String packageName,
                      String[] sourceRoots)
Description copied from interface: Compiler
Returns a string of the compiled source of the given input file. Not terribly performant but useful sometimes.

Specified by:
compile in interface Compiler
Parameters:
inputFile -
packageName -
sourceRoots -
Returns:

compileToOutputStream

protected void compileToOutputStream(C target,
                                     OutputStream outputStream)
                              throws IOException
Writes the target file and all files included by the target file into the output stream

Parameters:
target -
outputStream -
Throws:
IOException

writeToOutputStream

protected void writeToOutputStream(List<C> includedFiles,
                                   OutputStream outputStream)
                            throws IOException
Will write the list of files out into the passed output stream, along with any libraries that have been requested to be included.

Parameters:
includedFiles -
outputStream -
Throws:
IOException

afterWrittenLibrariesToOutputStream

protected void afterWrittenLibrariesToOutputStream(List<C> includedFiles,
                                                   OutputStream outputStream)
                                            throws IOException
Override this method to perform any post processing or cleanup.

Parameters:
includedFiles -
outputStream -
Throws:
IOException

parseInputFile

protected void parseInputFile(C file,
                              List<C> includedFiles)
Gets the passed CompilableFile to tell us which files it expects to include and recursively adds the include file to the list of files to write into the output stream

Parameters:
file -


Copyright © 2012. All Rights Reserved.