Package com.yahoo.platform.yui.compressor

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


      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

  //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

   * @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

    }

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

            }

            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

            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

                  new FileInputStream(srcFile), "UTF-8");

              out = new OutputStreamWriter(new FileOutputStream(
                  copyToFile), "UTF-8");

              CssCompressor compressor = new CssCompressor(in);
              compressor.compress(out, -1);

              // zk modified here
            } finally {
              if (in != null) {
                in.close();
View Full Code Here

    }

    @Override
    public String compress(String original) {
        try {
            CssCompressor compressor = new CssCompressor(new StringReader(original));
            StringWriter out = new StringWriter(original.length() / 2);
            compressor.compress(out, getLineBreakPosition());
            return out.toString();
        } catch (IOException iox) {
            throw new WicketRuntimeException("A problem occurred while compressing CSS resource: " + iox.getMessage(), iox);
        }
    }
View Full Code Here

            if ("js".equals(type)) {
                JavaScriptCompressor jsc = new JavaScriptCompressor(in, getLogBasedErrorReporter());
                jsc.compress(out, linebreak, munge, verbose, preserveAllSemiColons, disableOptimizations);
            } else if ("css".equals(type)) {
                CssCompressor cssc = new CssCompressor(in);
                cssc.compress(out, 100);
            }
            out.flush();
            minifiedBytes = baos.toByteArray();
        } catch (Exception e) { // Catch everything - on a runtime exception, we still want to return the unminified bytes
            LOG.warn("Could not minify resources, returned unminified bytes", e);
View Full Code Here

TOP

Related Classes of com.yahoo.platform.yui.compressor.CssCompressor

Copyright © 2018 www.massapicom. 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.