org.bbqjs.compiler
Class AbstractCompilableFile

java.lang.Object
  extended by org.bbqjs.compiler.AbstractCompilableFile
All Implemented Interfaces:
CompilableFile
Direct Known Subclasses:
CompilableCSSFile, CompilableJavaScriptFile, CompilableLanguageFile

public abstract class AbstractCompilableFile
extends Object
implements CompilableFile

Interrogates passed JavaScript files for their include statements. It's recommended that include statements are at the top of the file but it's not essential. Whitespace between include lines is ignored.


 include(org.my.project.JSClass);
 include(org.my.project.AnotherJSClass);
 include(org.some.other.project.YetAnotherJSClass);
 
 org.my.namespace.MyClass = Class.create({
     ...
 });
 

Author:
alex

Field Summary
protected  ByteArrayOutputStream contents
          Holds contents of file after includes
protected  List<CompilableFile> includedFiles
          List of files included by this file
protected  String[] sourceRoots
          Java by default caches everything accessed via the classpath - this is fine for production, but if we are developing it means, for example, that if you are changing js/css files, the compiler servlets in the spring integration package will not be able to pick up your changes.
 
Constructor Summary
AbstractCompilableFile(URL filePath, String[] sourceRoots)
           
 
Method Summary
protected  void encounteredInclude(String className)
           
protected  void encounteredInclude(String className, URL javaScriptFile)
           
 boolean equals(Object file)
           
protected  void findIncludes(URL file)
           
 URL getFilePath()
          Returns the path to this file.
 List<CompilableFile> getIncludedFiles()
          Returns a list of files included by this source file.
static void setLogger(org.slf4j.Logger log)
           
 String toString()
           
 void writeTo(OutputStream outputStream)
          Calling this method will cause the contents of the file to be written into the output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

contents

protected ByteArrayOutputStream contents
Holds contents of file after includes


includedFiles

protected List<CompilableFile> includedFiles
List of files included by this file


sourceRoots

protected String[] sourceRoots
Java by default caches everything accessed via the classpath - this is fine for production, but if we are developing it means, for example, that if you are changing js/css files, the compiler servlets in the spring integration package will not be able to pick up your changes. This property is a list of filesystem locations that we should try to pull files from before using the classpath - ie. your src/main/javascript folder and the like.

Constructor Detail

AbstractCompilableFile

public AbstractCompilableFile(URL filePath,
                              String[] sourceRoots)
Method Detail

setLogger

public static void setLogger(org.slf4j.Logger log)

findIncludes

protected void findIncludes(URL file)
                     throws IOException
Throws:
IOException

encounteredInclude

protected void encounteredInclude(String className)
                           throws IOException
Throws:
IOException

encounteredInclude

protected void encounteredInclude(String className,
                                  URL javaScriptFile)
                           throws IOException
Throws:
IOException

writeTo

public void writeTo(OutputStream outputStream)
             throws IOException
Description copied from interface: CompilableFile
Calling this method will cause the contents of the file to be written into the output stream.

Specified by:
writeTo in interface CompilableFile
Parameters:
outputStream -
Throws:
IOException

getFilePath

public URL getFilePath()
Description copied from interface: CompilableFile
Returns the path to this file.

Specified by:
getFilePath in interface CompilableFile
Returns:

getIncludedFiles

public List<CompilableFile> getIncludedFiles()
Description copied from interface: CompilableFile
Returns a list of files included by this source file.

Specified by:
getIncludedFiles in interface CompilableFile
Returns:

equals

public boolean equals(Object file)
Overrides:
equals in class Object
Parameters:
file -
Returns:

toString

public String toString()
Overrides:
toString in class Object
Returns:


Copyright © 2012. All Rights Reserved.