org.weborganic.bastille.util
Class JSMin

java.lang.Object
  extended by org.weborganic.bastille.util.JSMin

public final class JSMin
extends Object

A JavaScript minimiser.

This class is a slightly modified version of the work done by John Reilly who initially adapted Douglas Crockford's C version of his JavaScript minimiser.


Nested Class Summary
static class JSMin.UnterminatedCommentException
          A comment that does not terminate properly.
static class JSMin.UnterminatedRegExpLiteralException
          A regular expression that does not terminate properly.
static class JSMin.UnterminatedStringLiteralException
          A string that does not terminate properly.
 
Constructor Summary
JSMin(InputStream in, OutputStream out)
          Creates a new JavaScript minimiser for the specified I/O.
 
Method Summary
 void jsmin()
          Main JSMin method.
static void main(String[] arg)
          To invoke the minimizer on the command line.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSMin

public JSMin(InputStream in,
             OutputStream out)
Creates a new JavaScript minimiser for the specified I/O.

Parameters:
in - The JavaScript to minimise.
out - The minimised script.
Method Detail

jsmin

public void jsmin()
           throws IOException,
                  ParsingException
Main JSMin method.

Copy the input to the output, deleting the characters which are insignificant to JavaScript:

Throws:
IOException - If an error occurs while reading the input or writing on the output.
ParsingException - If an error occurs while parsing the JavaScript (minimizing is not possible then).

main

public static void main(String[] arg)
To invoke the minimizer on the command line.

Parameters:
arg - name of file to minimize