Class CssFile

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public abstract class CssFile
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    Since:
    1.0.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CssFile​()  
    • Constructor Detail

      • CssFile

        public CssFile​()
    • Method Detail

      • initCssFile

        protected final void initCssFile​()
      • getCssBlocks

        public java.util.Set<AbstractCssFileBlock> getCssBlocks​()
        Returns:
        the cssBlocks
        Since:
        1.0.0
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object
      • toCssString

        public java.lang.String toCssString​()
        Returns:
        the css string. i.e. the contents in the css file as a string.
        Since:
        1.0.0
      • toCssString

        public java.lang.String toCssString​(boolean rebuild)
        Parameters:
        rebuild - true to force to rebuild
        Returns:
        the css string. i.e. the contents in the css file as a string.
        Since:
        1.0.0
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os,
                                   java.lang.String charset)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        charset - the charset type of bytes to write
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os,
                                   java.lang.String charsetName,
                                   boolean rebuild)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        charsetName - the charset type of bytes to write
        rebuild - the load method in CssBlocked will be invoked a gain
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os,
                                   boolean rebuild)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        rebuild - the load method in CssBlocked will be invoked a gain
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os,
                                   java.nio.charset.Charset charset)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        charset - the charset type of bytes to write
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os,
                                   java.nio.charset.Charset charset,
                                   boolean rebuild)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        charset - the charset type of bytes to write
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • toOutputStream

        public void toOutputStream​(java.io.OutputStream os)
                            throws java.io.IOException
        Parameters:
        os - the OutputStream object to write
        Throws:
        java.io.IOException
        Since:
        1.1.2
      • isOptimizeCssString

        public final boolean isOptimizeCssString​()
        Returns:
        true if the toCssString to be optimized.
        Since:
        1.0.0
      • setOptimizeCssString

        public void setOptimizeCssString​(boolean optimizeCssString)
        optimizes the toCssString output. For instance the optimized output for the following blocks in the CssFile extended class will be .test4-class{list-style-position:outside;background-repeat:no-repeat;} .
        private CssBlock cssBlock1 = new CssBlock(".test4-class") {
        @Override
        protected void load(Set cssProperties) {
        cssProperties.add(ListStylePosition.INSIDE);
        }
        };
        private CssBlock cssBlock2 = new CssBlock(".test4-class") {
        @Override
        protected void load(Set cssProperties) {
        cssProperties.add(BackgroundRepeat.NO_REPEAT);
        cssProperties.add(ListStylePosition.OUTSIDE);
        }
        };
        Parameters:
        optimizeCssString - the optimizeCssString to set. true to optimize the toCssString value and false to turn off optimization. The default value is true.
        Since:
        1.0.0
      • isPrependCharset

        public boolean isPrependCharset​()
        Returns:
        true or false
        Since:
        1.1.2
      • setPrependCharset

        public void setPrependCharset​(boolean prependCharset)
        prepends the charset declaration (eg: @CHARSET "UTF-8";) while writing css string to the output stream by toOutputStream methods.
        Parameters:
        prependCharset - true to prepend the charset declaration (eg: @CHARSET "UTF-8";) while writing css string to the output stream by toOutputStream methods.
        Since:
        1.1.2