private void doJSCompression(final Reader in, Writer out, final String outputFilename) throws EvaluatorException, IOException {
traceVerbose("Start doJSCompression");
try {
// JS compressor
final JavaScriptCompressor compressor = new JavaScriptCompressor(in, new ErrorReporter() {
public void warning(final String message, final String sourceName,
final int line, final String lineSource, final int lineOffset) {
if (line < 0) {
trace(message);
} else {
trace(line + ':' + lineOffset + ':' + message);
}
}
public void error(final String message, final String sourceName,
final int line, final String lineSource, final int lineOffset) {
warning(message, sourceName, line, lineSource, lineOffset);
}
public EvaluatorException runtimeError(final String message, final String sourceName,
final int line, final String lineSource, final int lineOffset) {
error(message, sourceName, line, lineSource, lineOffset);
return new EvaluatorException(message);
}
});
// Close the input stream first, and then open the output stream,
// in case the output file should override the input file
closeObject(in);
// Get Writer object for output file
out = openDataWriter(new File(outputFilename), UTF8);
// Compress file
compressor.compress(out, -1, true, false,
true, false);
} finally {
closeObject(out);
traceVerbose("End doJSCompression");
}