1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.web.sx

File CssExtension.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
10
4
1
75
41
5
0.5
2.5
4
1.25

Classes

Class Line # Actions
CssExtension 37 10 0% 5 2
0.8571428785.7%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.web.sx;
21   
22    import java.io.IOException;
23    import java.io.StringReader;
24    import java.io.StringWriter;
25   
26    import org.slf4j.Logger;
27    import org.slf4j.LoggerFactory;
28   
29    import com.yahoo.platform.yui.compressor.CssCompressor;
30   
31    /**
32    * StyleSheet extension.
33    *
34    * @version $Id: cda08e75763bf654209d78c55dcc2ea1d524bd0f $
35    * @since 1.7M2
36    */
 
37    public class CssExtension implements Extension
38    {
39    /** Logging helper. */
40    private static final Logger LOGGER = LoggerFactory.getLogger(CssExtension.class);
41   
 
42  706 toggle @Override
43    public String getClassName()
44    {
45  706 return "XWiki.StyleSheetExtension";
46    }
47   
 
48  236 toggle @Override
49    public String getContentType()
50    {
51  236 return "text/css; charset=UTF-8";
52    }
53   
 
54  236 toggle @Override
55    public SxCompressor getCompressor()
56    {
57  236 return new SxCompressor()
58    {
 
59  236 toggle @Override
60    public String compress(String source)
61    {
62  236 try {
63  236 CssCompressor compressor = new CssCompressor(new StringReader(source));
64  236 StringWriter out = new StringWriter();
65  236 compressor.compress(out, -1);
66  236 return out.toString();
67    } catch (IOException ex) {
68  0 LOGGER.warn("Exception compressing SSX code", ex);
69    }
70  0 return source;
71    }
72    };
73    }
74   
75    }