Package com.yahoo.platform.yui.compressor

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


         switch (type_) {
         case CSS:
            new CssCompressor(r).compress(w, -1);
            break;
         case JS:
             new JavaScriptCompressor(r, er_).compress(w, -1, true,
                     false, false, false);
            break;
         default:
            throw new RuntimeException("Resource type not recognized: "
                  + type_.name());
View Full Code Here


            switch (type_) {
            case CSS:
                new CssCompressor(r).compress(w, -1);
                break;
            case JS:
                new JavaScriptCompressor(r, er_).compress(w, -1, true, false, false, false);
                break;
            default:
                throw new RuntimeException("Resource type not recognized: " + type_.name());
            }
        } finally {
View Full Code Here

        try {
            reader = new InputStreamReader(in, charset);
            writer = new OutputStreamWriter(out, charset);

            MavenLogErrorReporter reporter = new MavenLogErrorReporter(outputName);
            new JavaScriptCompressor(reader, reporter).compress(writer, 0, true, true, false, false);

            if (!closeAtFinish) {
                // add semicolon to satisfy end of context of each script when packing files
                writer.write(";");
                writer.flush();
View Full Code Here

   public void transform(HttpServletRewrite event, InputStream input, OutputStream output) throws IOException
   {

      // prepare input reader
      Reader reader = new InputStreamReader(input, getCharset());
      JavaScriptCompressor compressor = new JavaScriptCompressor(reader, null);

      // write compressed output
      OutputStreamWriter writer = new OutputStreamWriter(output, getCharset());
      compressor.compress(writer, 100, true, false, false, false);
      writer.flush();
   }
View Full Code Here

            File inputFile = new File(inputFilename);
            File outputFile = new File(outputFilename);
            in = new InputStreamReader(new FileInputStream(inputFile), minifyProperty.getCharset());
            minifyFileResult.setInputFileSize(inputFile.length());

            JavaScriptCompressor compressor = new JavaScriptCompressor(in, new MinifyUtil.CompressorErrorReporter());
            in.close();
            in = null;

            out = new OutputStreamWriter(new FileOutputStream(outputFile), minifyProperty.getCharset());
            compressor.compress(out, minifyProperty.getLineBreakPosition(), minifyProperty.isJsObfuscate(), minifyProperty.getVerbose(), minifyProperty.isPreserveSemicolon(), minifyProperty.getDisableOptimizations());
            out.flush();
            minifyFileResult.setOutputFileSize(outputFile.length());
            if (minifyProperty.isAppendLogToFile()) {
                out.append("\n/*Size: " + minifyFileResult.getInputFileSize() + "->"
                        + minifyFileResult.getOutputFileSize() + "Bytes "
View Full Code Here

        return minifyFileResult;
    }

    public void compressJavaScriptInternal(Reader in, Writer out, MinifyProperty minifyProperty) throws IOException {
        try {
            JavaScriptCompressor compressor = new JavaScriptCompressor(in, new MinifyUtil.CompressorErrorReporter());
            in.close();
            in = null;
            compressor.compress(out, minifyProperty.getLineBreakPosition(), minifyProperty.isJsObfuscate(), minifyProperty.getVerbose(), minifyProperty.isPreserveSemicolon(), minifyProperty.getDisableOptimizations());
            out.flush();
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }
View Full Code Here

      getLog().debug("use a temporary outputfile (in case in == out)");

      getLog().debug("start compression");
      out = new OutputStreamWriter(new FileOutputStream(outFileTmp), encoding);
      if (".js".equalsIgnoreCase(src.getExtension())) {
        JavaScriptCompressor compressor = new JavaScriptCompressor(in, jsErrorReporter_);
        compressor.compress(out, linebreakpos, !nomunge, jswarn, preserveAllSemiColons, disableOptimizations);
        //zk modified here
      } else if (".css".equalsIgnoreCase(src.getExtension()) || src.toFile().getName().endsWith(".css.dsp")) {
        //zk modified here
        // here we use css compressor for zk version

        CssCompressor compressor = new CssCompressor(in);
        compressor.compress(out, linebreakpos);
      }
      getLog().debug("end compression");
    } finally {
      IOUtil.close(in);
      IOUtil.close(out);
View Full Code Here

        Reader reader = toReader(resource);

        try
        {
            JavaScriptCompressor compressor = new JavaScriptCompressor(reader, errorReporter);
            compressor.compress(output, -1, true, true, false, false);

            identifyWarnings.run();

        } catch (EvaluatorException ex)
        {
View Full Code Here

        Reader reader = toReader(resource);

        try
        {
            JavaScriptCompressor compressor = new JavaScriptCompressor(reader, errorReporter);
            compressor.compress(output, -1, true, true, false, false);

            identifyWarnings.run();

        } catch (EvaluatorException ex)
        {
View Full Code Here

            // prepare output file
            outFile.getParentFile().mkdirs();
            Writer out = new OutputStreamWriter(new FileOutputStream(outFile), charset);

            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

TOP

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

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.