当前位置: 首页>>代码示例>>Java>>正文


Java CssCompressor类代码示例

本文整理汇总了Java中com.yahoo.platform.yui.compressor.CssCompressor的典型用法代码示例。如果您正苦于以下问题:Java CssCompressor类的具体用法?Java CssCompressor怎么用?Java CssCompressor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CssCompressor类属于com.yahoo.platform.yui.compressor包,在下文中一共展示了CssCompressor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compressCSS

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
public void compressCSS(Path input, Path output) throws IOException {
    // yui compressor chokes on empty files
    long size = Files.size(input);
    if (size == 0) {
        if (!Files.exists(output)) {
            Files.createFile(output);
        }
        return;
    }

    Options o = new Options();
    try (Reader in = Files.newBufferedReader(input, Charset.forName(o.charset));
         Writer out = Files.newBufferedWriter(output, Charset.forName(o.charset))) {

        CssCompressor compressor = new CssCompressor(in);
        compressor.compress(out, o.lineBreakPos);
    }
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:19,代码来源:YuiWrapper.java

示例2: minifyCSS

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
/**
 * Minifies CSS by utilising YUI {@link CssCompressor}.
 *
 * @param bytes - an array of bytes to minify
 * @param linebreakpos - split long line after a specific column
 * @return minified content as array of bytes
 * @throws IOException
 */
static final byte[] minifyCSS(final byte[] bytes, int linebreakpos) throws IOException {
	Reader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes)));
	StringWriter writer = new StringWriter();

	try {
		new CssCompressor(reader).compress(writer, linebreakpos);
	} catch (IndexOutOfBoundsException e) {
		// handle YUI bug when file is empty or contains comments only
		return new byte[] {};
	}
	finally {
		if (reader != null) {
			reader.close();
		}
		if (writer != null) {
			writer.close();
		}
	}
	return writer.toString().getBytes("UTF-8");
}
 
开发者ID:deniskiriusin,项目名称:combinatorius,代码行数:29,代码来源:CIOUtils.java

示例3: compressCss

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
private void compressCss(File source, File dest) throws IOException {
	Reader in = null;
	Writer out = null;
	try {
		in = new BufferedReader(new FileReader(source));
		CssCompressor compressor = new CssCompressor(in);

		log("Compressing: " + source.getName());

		out = new BufferedWriter(new FileWriter(dest));
		compressor.compress(out, linebreak);

	} finally {
		if (in != null) in.close();
		if (out != null) out.close();
	}
}
 
开发者ID:sbuckle,项目名称:yui-compressor-ant-task,代码行数:18,代码来源:CompressTask.java

示例4: compressCSS

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
public void compressCSS(final File inputFile, final File outputFile, final YuiCompressorOptions o) throws IOException {
	Reader in = null;
	Writer out = null;
	try {
		in = new InputStreamReader(new FileInputStream(inputFile), o.charset);

		final CssCompressor compressor = new CssCompressor(in);
		in.close();
		in = null;

		out = new OutputStreamWriter(new FileOutputStream(outputFile, true), o.charset);
		compressor.compress(out, o.lineBreakPos);
	} finally {
		IOUtils.closeQuietly(in);
		IOUtils.closeQuietly(out);
	}
}
 
开发者ID:rii-mango,项目名称:Papaya-Builder,代码行数:18,代码来源:Builder.java

示例5: runSafe

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
@Override
protected void runSafe() throws Exception {
	try (Reader reader = new BufferedReader(new InputStreamReader(
			srcFile.getContents(), inCharset));
			Writer writer = new OutputStreamWriter(out, outCharset)) {
		try {
			new CssCompressor(reader).compress(writer, -1);
		} finally {
			writer.close();
		}
	}
}
 
开发者ID:mnlipp,项目名称:EclipseMinifyBuilder,代码行数:13,代码来源:YuiCssMinifier.java

示例6: compressCss

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
private void compressCss(Reader reader, OutputStream out) throws IOException
{
    CssCompressor compressor = new CssCompressor(reader);
    StringWriter writer = new StringWriter();

    compressor.compress(writer, -1);

    String compressed = writer.toString();
    IOUtils.copy(new StringReader(compressed), out);
}
 
开发者ID:touwolf,项目名称:kasije,代码行数:11,代码来源:ResourcesManagerImpl.java

示例7: write

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
public void write(Writer writer, boolean minify) throws IOException {
    if (minify) {
        InputStreamReader reader = new InputStreamReader(
                new ByteArrayInputStream(printState().getBytes("UTF-8")));
        CssCompressor compressor = new CssCompressor(reader);
        compressor.compress(writer, -1);
    } else {
        writer.write(printState());
    }
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:11,代码来源:ScssStylesheet.java

示例8: compressCSS

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
public static void compressCSS(String inputFilename, String outputFilename, Options o) throws IOException {
    Reader in = null;
    Writer out = null;
    try {
        in = new InputStreamReader(new FileInputStream(inputFilename), o.charset);
        CssCompressor compressor = new CssCompressor(in);
        in.close();
        in = null;
        out = new OutputStreamWriter(new FileOutputStream(outputFilename), o.charset);
        compressor.compress(out, o.lineBreakPos);
    } finally {
        IOUtils.closeQuietly(in);
        IOUtils.closeQuietly(out);
    }
}
 
开发者ID:AdityaAnand1,项目名称:Website-Compressor,代码行数:16,代码来源:Compressor.java

示例9: compressCss

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
private String compressCss(String content) {
  StringWriter stringWriter = new StringWriter(1024);
  try {
    CssCompressor compressor = new CssCompressor(new StringReader(content));
    compressor.compress(stringWriter, _compressorOptions.getLineBreakPosition());
  } catch (IOException ex) {
    s_logger.error("Unexpected IOException", ex);
  }
  return stringWriter.toString();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:11,代码来源:YUIBundleCompressor.java

示例10: minify

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
/**
 * Minifies the CSS contents from the given merged file into the minified file
 *
 * <p>
 * Minification is performed using the YUI Compressor compiler with no line break
 * </p>
 *
 * @see ThemeFilesProcessor#minify(java.io.File, java.io.File)
 * @see com.yahoo.platform.yui.compressor.CssCompressor
 */
@Override
protected void minify(File mergedFile, File minifiedFile) throws IOException {
    InputStream in = null;
    OutputStream out = null;
    OutputStreamWriter writer = null;
    InputStreamReader reader = null;

    LOG.info("Populating minified CSS file: " + minifiedFile.getPath());

    try {
        out = new FileOutputStream(minifiedFile);
        writer = new OutputStreamWriter(out);

        in = new FileInputStream(mergedFile);
        reader = new InputStreamReader(in);

        CssCompressor compressor = new CssCompressor(reader);
        compressor.compress(writer, this.linebreak);

        writer.flush();
    } finally {
        if (in != null) {
            in.close();
        }

        if (out != null) {
            out.close();
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:41,代码来源:ThemeCssFilesProcessor.java

示例11: minify

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
/**
 * Minifies a CSS file. Create missing parent directories if needed.
 *
 * @param mergedFile input file resulting from the merged step
 * @param minifiedFile output file resulting from the minify step
 * @throws IOException when the minify step fails
 */
@Override
protected void minify(File mergedFile, File minifiedFile) throws IOException {
    minifiedFile.getParentFile().mkdirs();

    try (InputStream in = new FileInputStream(mergedFile);
            OutputStream out = new FileOutputStream(minifiedFile);
            InputStreamReader reader = new InputStreamReader(in, charset);
            OutputStreamWriter writer = new OutputStreamWriter(out, charset)) {
        log.info("Creating the minified file [" + ((verbose) ? minifiedFile.getPath() : minifiedFile.getName())
                + "].");

        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;
        }
    } catch (IOException e) {
        log.error("Failed to compress the CSS file [" + ((verbose) ? mergedFile.getPath() : mergedFile.getName())
                + "].", e);
        throw e;
    }

    logCompressionGains(mergedFile, minifiedFile);
}
 
开发者ID:a1martin,项目名称:minifier-maven-plugin,代码行数:38,代码来源:ProcessCSSFilesTask.java

示例12: compress

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
@Override
public String compress(String source) {
   	StringWriter result = new StringWriter();
	
	try {
		CssCompressor compressor = new CssCompressor(new StringReader(source));
		compressor.compress(result, lineBreak);
	} catch (IOException e) {
		result.write(source);
		e.printStackTrace();
	}
	
	return result.toString();
}
 
开发者ID:ad3n,项目名称:htmlcompressor,代码行数:15,代码来源:YuiCssCompressor.java

示例13: minify

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
protected void minify(BufferedReader in, BufferedWriter out, String filename, String type) throws IOException {
    if (JS_TYPE.equals(type)) {
        JavaScriptCompressor jsc = new JavaScriptCompressor(in, getLogBasedErrorReporter());
        jsc.compress(out, linebreak, munge, verbose, preserveAllSemiColons, disableOptimizations);
    } else if (CSS_TYPE.equals(type)) {
        CssCompressor cssc = new CssCompressor(in);
        cssc.compress(out, 100);
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:10,代码来源:ResourceMinificationServiceImpl.java

示例14: process

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
public String process(File[] srcFiles) throws ProcessException {
    StringWriter writer = new StringWriter();

    try {
        for (File srcFile : srcFiles) {
            CssCompressor compressor = new CssCompressor(new InputStreamReader(new FileInputStream(srcFile)));
            compressor.compress(writer, -1);
        }
    } catch (IOException e) {
        throw new ProcessException("Failed to process CSS files.", e);
    }

    return writer.toString();
}
 
开发者ID:instant-solutions,项目名称:gradle-website-optimizer,代码行数:15,代码来源:CssProcessor.java

示例15: minimiseCSS

import com.yahoo.platform.yui.compressor.CssCompressor; //导入依赖的package包/类
private String minimiseCSS( String cssContents ) throws cfmRunTimeException {
	StringReader	stringReader = new StringReader( cssContents );

	try{
		CssCompressor compressor = new CssCompressor( stringReader );

		StringWriter out = new StringWriter();
		compressor.compress(out, -1);
		return out.toString();

	}catch(Exception e){
		throw newRunTimeException( "CSS Minimizer: failed: " + e.getMessage() );
	}
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:15,代码来源:cfSTYLESHEET.java


注:本文中的com.yahoo.platform.yui.compressor.CssCompressor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。