Example usage for com.google.common.css.compiler.ast GssParserException printStackTrace

List of usage examples for com.google.common.css.compiler.ast GssParserException printStackTrace

Introduction

In this page you can find the example usage for com.google.common.css.compiler.ast GssParserException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.log4ic.compressor.utils.template.JavascriptTemplateEngine.java

public static String compress(String name, String source, Mode mode) {
    HtmlCompressor compressor = new HtmlCompressor();

    compressor.setRemoveIntertagSpaces(true); //removes iter-tag whitespace characters
    compressor.setRemoveQuotes(true); //removes unnecessary tag attribute quotes
    compressor.setSimpleDoctype(true); //simplify existing doctype
    compressor.setRemoveScriptAttributes(true); //remove optional attributes from script tags
    compressor.setRemoveStyleAttributes(true); //remove optional attributes from style tags
    compressor.setRemoveLinkAttributes(true); //remove optional attributes from link tags
    compressor.setRemoveFormAttributes(true); //remove optional attributes from form tags
    compressor.setRemoveInputAttributes(true); //remove optional attributes from input tags
    compressor.setSimpleBooleanAttributes(true); //remove values from boolean tag attributes
    compressor.setRemoveJavaScriptProtocol(true); //remove "javascript:" from inline event handlers
    //compressor.setRemoveHttpProtocol(true);        //replace "http://" with "//" inside tag attributes
    //        compressor.setRemoveHttpsProtocol(true);       //replace "https://" with "//" inside tag attributes
    compressor.setPreserveLineBreaks(false); //preserves original line breaks
    compressor.setRemoveSurroundingSpaces(HtmlCompressor.ALL_TAGS); //remove spaces around provided tags

    compressor.setCompressCss(true); //compress inline css
    compressor.setCompressJavaScript(true); //compress inline javascript

    //use Google Closure Compiler for javascript compression
    compressor.setJavaScriptCompressor(new ClosureJavaScriptCompressor(CompilationLevel.SIMPLE_OPTIMIZATIONS));

    //use your own implementation of css comressor
    compressor.setCssCompressor(new Compressor() {
        @Override//w  ww.  j ava2 s . co m
        public String compress(String source) {
            try {
                return com.log4ic.compressor.utils.Compressor
                        .compressGss(new SourceCode("inner-style", source));
            } catch (GssParserException e) {
                e.printStackTrace();
            }
            return null;
        }
    });

    String compressedHtml = compressor.compress(source);

    return parse(name, compressedHtml, mode);
}