Example usage for com.google.common.css.compiler.passes CompactPrinter getCompactPrintedString

List of usage examples for com.google.common.css.compiler.passes CompactPrinter getCompactPrintedString

Introduction

In this page you can find the example usage for com.google.common.css.compiler.passes CompactPrinter getCompactPrintedString.

Prototype

public String getCompactPrintedString() 

Source Link

Document

Returns the CSS compacted printed output.

Usage

From source file:com.log4ic.compressor.utils.Compressor.java

/**
 * css//from   w  w  w  .  j  a  v a  2s .  c o  m
 *
 * @param job
 * @return
 * @throws GssParserException
 */
public static String compressGss(JobDescription job) throws GssParserException {
    logger.debug("CSS...");
    try {
        GssParser parser = new GssParser(job.inputs);
        CssTree cssTree = parser.parse();
        if (job.outputFormat != JobDescription.OutputFormat.DEBUG) {
            CompilerErrorManager errorManager = new CompilerErrorManager();
            PassRunner passRunner = new ExtendedPassRunner(job, errorManager);
            passRunner.runPasses(cssTree);
        }

        if (job.outputFormat == JobDescription.OutputFormat.COMPRESSED) {
            CompactPrinter compactPrinterPass = new CompactPrinter(cssTree);
            compactPrinterPass.runPass();
            return compactPrinterPass.getCompactPrintedString();
        } else {
            PrettyPrinter prettyPrinterPass = new PrettyPrinter(cssTree.getVisitController());
            prettyPrinterPass.runPass();
            return prettyPrinterPass.getPrettyPrintedString();
        }
    } finally {
        logger.debug("CSS...");
    }
}