Class Less


  • public class Less
    extends java.lang.Object
    The main class of JLessC library. Its contain all start points for converting LESS to CSS files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMPRESS
      Key for compress option. true, if the CSS data should be compressed without any extra formating characters.
      static java.lang.String REWRITE_URLS
      Rewrites URLs to make them relative to the base less file.
    • Constructor Summary

      Constructors 
      Constructor Description
      Less()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String compile​(java.io.File lessFile, boolean compress)
      Compile the less data from a file.
      static java.lang.String compile​(java.io.File lessFile, boolean compress, ReaderFactory readerFactory)
      Compile the less data from a file.
      static java.lang.String compile​(java.net.URL baseURL, java.lang.String lessData, boolean compress)
      Compile the less data from a string.
      static java.lang.String compile​(java.net.URL baseURL, java.lang.String lessData, boolean compress, ReaderFactory readerFactory)
      Compile the less data from a string.
      static java.lang.String compile​(java.net.URL baseURL, java.lang.String lessData, java.util.Map<java.lang.String,​java.lang.String> options)
      Compile the less data from a string.
      static java.lang.String compile​(java.net.URL baseURL, java.lang.String lessData, java.util.Map<java.lang.String,​java.lang.String> options, ReaderFactory readerFactory)
      Compile the less data from a string.
      static void registerCustomFunction​(java.lang.String name, CustomLessFunction func)
      Register a custom less function.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMPRESS

        public static final java.lang.String COMPRESS
        Key for compress option. true, if the CSS data should be compressed without any extra formating characters.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Less

        public Less()
    • Method Detail

      • compile

        public static java.lang.String compile​(java.net.URL baseURL,
                                               java.lang.String lessData,
                                               boolean compress)
                                        throws LessException
        Compile the less data from a string.
        Parameters:
        baseURL - the baseURL for import of external less data.
        lessData - the input less data
        compress - true, if the CSS data should be compressed without any extra formating characters.
        Returns:
        the resulting less data
        Throws:
        LessException - if any error occur on compiling.
      • compile

        public static java.lang.String compile​(java.net.URL baseURL,
                                               java.lang.String lessData,
                                               boolean compress,
                                               ReaderFactory readerFactory)
                                        throws LessException
        Compile the less data from a string.
        Parameters:
        baseURL - the baseURL for import of external less data.
        lessData - the input less data
        compress - true, if the CSS data should be compressed without any extra formating characters.
        readerFactory - A factory for the readers for imports.
        Returns:
        the resulting less data
        Throws:
        LessException - if any error occur on compiling.
      • compile

        public static java.lang.String compile​(java.net.URL baseURL,
                                               java.lang.String lessData,
                                               java.util.Map<java.lang.String,​java.lang.String> options)
                                        throws LessException
        Compile the less data from a string.
        Parameters:
        baseURL - the baseURL for import of external less data.
        lessData - the input less data
        options - some optional options, see constants for details
        Returns:
        the resulting less data
        Throws:
        LessException - if any error occur on compiling.
      • compile

        public static java.lang.String compile​(java.net.URL baseURL,
                                               java.lang.String lessData,
                                               java.util.Map<java.lang.String,​java.lang.String> options,
                                               ReaderFactory readerFactory)
                                        throws LessException
        Compile the less data from a string.
        Parameters:
        baseURL - the baseURL for import of external less data.
        lessData - the input less data
        options - some optional options, see constants for details
        readerFactory - A factory for the readers for imports.
        Returns:
        the resulting less data
        Throws:
        LessException - if any error occur on compiling.
      • compile

        public static java.lang.String compile​(java.io.File lessFile,
                                               boolean compress)
                                        throws java.io.IOException
        Compile the less data from a file.
        Parameters:
        lessFile - the less file
        compress - true, if the CSS data should be compressed without any extra formating characters.
        Returns:
        the resulting less data
        Throws:
        java.io.IOException - if an I/O error occurs reading from the less file
      • compile

        public static java.lang.String compile​(java.io.File lessFile,
                                               boolean compress,
                                               ReaderFactory readerFactory)
                                        throws java.io.IOException
        Compile the less data from a file.
        Parameters:
        lessFile - the less file
        compress - true, if the CSS data should be compressed without any extra formating characters.
        readerFactory - A factory for the readers for imports.
        Returns:
        the resulting less data
        Throws:
        java.io.IOException - if an I/O error occurs reading from the less file
      • registerCustomFunction

        public static void registerCustomFunction​(@Nonnull
                                                  java.lang.String name,
                                                  CustomLessFunction func)
        Register a custom less function.
        Parameters:
        name - the non null name
        func - the function