Examples of CssCompressor


Examples of com.yahoo.platform.yui.compressor.CssCompressor

  }

  public static String compress(final String toCompress) {
    final StringWriter writer = new StringWriter((int) (toCompress.length() * 0.8));
    try {
      new CssCompressor(new StringReader(toCompress)).compress(writer, 0);
    } catch (final Exception e) {
      log.warn("Could not compress merged CSS stream, using uncompressed content", e);
      return toCompress;
    }
    return writer.toString();
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

  public static byte[] compress(final byte[] toCompress, Charset charset) {
    ByteArrayOutputStream out = new ByteArrayOutputStream(toCompress.length);

    final OutputStreamWriter writer = new OutputStreamWriter(out);
    try {
      new CssCompressor(new InputStreamReader(new ByteArrayInputStream(toCompress), charset)).compress(writer, 0);
      writer.flush();
      writer.close();
    } catch (final Exception e) {
      log.warn("Could not compress merged CSS stream, using uncompressed content", e);
      return toCompress;
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

        StringWriter writer = new StringWriter(1000);
        Reader reader = new InputStreamReader(resource.openStream());

        try
        {
            new CssCompressor(reader).compress(writer, -1);

            writer.flush();

            return IOUtils.toInputStream(writer.getBuffer());
        } finally
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

            if (fileType.equals(FileType.JS_FILE)) {
                final JavaScriptCompressor compressor = createJavaScriptCompressor(in);
                compressor.compress(out, lineBreakPosition, munge, warn, preserveAllSemiColons, !optimize);
            } else if (fileType.equals(FileType.CSS_FILE)) {
                final CssCompressor compressor = new CssCompressor(in);
                compressor.compress(out, lineBreakPosition);
            } else if (fileType.equals(FileType.HTML_FILE) || fileType.equals(FileType.XHTML_FILE)) {
                final HtmlCompressor compressor = new HtmlCompressor();
                out.write(compressor.compress(readerToString(in)));
            } else if (fileType.equals(FileType.XML_FILE)){
                final XmlCompressor compressor = new XmlCompressor();
                out.write(compressor.compress(readerToString(in)));
            }

            // close all streams
            in.close();
            in = null;
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

      return ProcessorUtil.process(vfs, resource, "css",
          new ProcessorCallback() {
            @Override
            public void call(final Reader reader, final Writer writer)
                throws IOException {
              final CssCompressor compressor = new CssCompressor(
                  new StringReader(resource.getContents()));
              final int linebreakpos = -1;
              compressor.compress(writer, linebreakpos);
            }
          });
    } catch (final StackOverflowError e) {
      LOGGER.error(
          "Failed to run yuicompressor on source:\n" + resource.getContents(),
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

  //adds a line break after X chars
  private final static int LINE_BREAK_POS = 1000;
  private static final Logger log = Logger.getLogger(YUICompressorAdaptor.class);

  public static String compressCSS(Reader in) throws IOException{
    CssCompressor compressor = new CssCompressor(in);
    StringWriter out = new StringWriter();
    compressor.compress(out, LINE_BREAK_POS);
    return out.toString();
  }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

   * @param in the reader where the data must be read
   * @param out the writer where the data must be written
   * @throws IOException
   */
  public static void compressCSS(Reader in, Writer out) throws IOException{
    CssCompressor compressor = new CssCompressor(in);
    compressor.compress(out, LINE_BREAK_POS);
  }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

    }

    @Override
    protected void doMinimize(Reader input, Writer output) throws IOException
    {
        new CssCompressor(input).compress(output, -1);
    }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

            }

            getLog().debug("YUICOMPRESS: " + inFile.getAbsolutePath() + " -> " + outFile.getAbsolutePath());

            try {
                CssCompressor compressor = new CssCompressor(in);
                compressor.compress(out, linebreakpos);
            } catch (IllegalArgumentException e) {
                throw new IllegalArgumentException(
                    "Unexpected characters found in CSS file. Ensure that the CSS file does not contain '$', and try again", e);
            }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

            switch (engine) {
                case YUI:
                    log.debug("Using YUI Compressor engine.");

                    CssCompressor compressor = new CssCompressor(reader);
                    compressor.compress(writer, yuiConfig.getLineBreak());
                    break;
                default:
                    log.warn("CSS engine not supported.");
                    break;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.