Package org.ametys.core.minimize.css
Class MinimizeCSSManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.minimize.AbstractMinimizeManager
-
- org.ametys.core.minimize.css.MinimizeCSSManager
-
- All Implemented Interfaces:
LogEnabled,Initializable,Component,Serviceable
public class MinimizeCSSManager extends AbstractMinimizeManager implements Component, Initializable
Minimize manager for CSS files
-
-
Field Summary
Fields Modifier and Type Field Description static StringROLEThe avalon ROLE-
Fields inherited from class org.ametys.core.minimize.AbstractMinimizeManager
_proxiedContextPathProvider, _resolver, _sourceMapCache
-
-
Constructor Summary
Constructors Constructor Description MinimizeCSSManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddSourceMap(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator, int lineCount, String fileContent, String fileUri, String sourceMapUri)Aggregate the source map of the single file with the othersprotected StringapplyMediaToContent(String content, String media)Defaut implementation to apply a media to a content.protected StringformatSourceMappingURL(String sourceMapName)Format a source mapping URL to be added at the end of a minimized fileprotected StringgetMinimizedContent(String fileUri, String nestedParentFilesName)Get the minimized content at the specified URIprotected StringgetSourceMappingURL(String line)Get the source mapping URL value from the linevoidinitialize()protected booleanisSourceMappingURLLine(String line)Test if the line contains a source mapping URLStringminimizeCss(String code, String location)Minimize a CSS stringStringminimizeCss(String code, String location, String sourceMapKey, Long lastModified)Minimize a CSS stringprotected StringremoveSourceMappingURLLine(String content)Remove the source mapping url from the contentvoidservice(ServiceManager smanager)-
Methods inherited from class org.ametys.core.minimize.AbstractMinimizeManager
convertSourceMapURIs, minimizeAndAggregateURIs, validateAndOutputMinimizedFile
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
MinimizeCSSManager
public MinimizeCSSManager()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractMinimizeManager- Throws:
ServiceException
-
minimizeCss
public String minimizeCss(String code, String location) throws ProcessingException, IOException
Minimize a CSS string- Parameters:
code- The CSS codelocation- The CSS location, can be null if no location was determined- Returns:
- The minimized CSS
- Throws:
ProcessingException- If an error occurred during minimizationIOException- If an error occurred while retrieving the source map
-
minimizeCss
public String minimizeCss(String code, String location, String sourceMapKey, Long lastModified) throws IOException, ProcessingException
Minimize a CSS string- Parameters:
code- The CSS codelocation- The CSS location, can be null if no location was determined, in which case no source map will be generatedsourceMapKey- The key to store the source map in cache. Can be null to prevent source map generationlastModified- The last modified date of the code, used to assert validity of the source map cache. Can be null- Returns:
- The minimized CSS
- Throws:
ProcessingException- If an error occurred during minimizationIOException- If an error occurred while retrieving the source map
-
getMinimizedContent
protected String getMinimizedContent(String fileUri, String nestedParentFilesName)
Description copied from class:AbstractMinimizeManagerGet the minimized content at the specified URI- Specified by:
getMinimizedContentin classAbstractMinimizeManager- Parameters:
fileUri- The urinestedParentFilesName- The parents file name, can be an empty string if there are no parents- Returns:
- The minimized content of the specified URI
-
applyMediaToContent
protected String applyMediaToContent(String content, String media)
Description copied from class:AbstractMinimizeManagerDefaut implementation to apply a media to a content.- Overrides:
applyMediaToContentin classAbstractMinimizeManager- Parameters:
content- The contentmedia- The media- Returns:
- The content with the media
-
addSourceMap
protected void addSourceMap(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator, int lineCount, String fileContent, String fileUri, String sourceMapUri)
Description copied from class:AbstractMinimizeManagerAggregate the source map of the single file with the others- Specified by:
addSourceMapin classAbstractMinimizeManager- Parameters:
sourceMapGenerator- The aggregator helperlineCount- The current line countfileContent- The content of the filefileUri- The uri of the filesourceMapUri- The sourceMappingURL found at the end of the file content
-
isSourceMappingURLLine
protected boolean isSourceMappingURLLine(String line)
Description copied from class:AbstractMinimizeManagerTest if the line contains a source mapping URL- Specified by:
isSourceMappingURLLinein classAbstractMinimizeManager- Parameters:
line- The line- Returns:
- True if a source mapping url is found
-
getSourceMappingURL
protected String getSourceMappingURL(String line)
Description copied from class:AbstractMinimizeManagerGet the source mapping URL value from the line- Specified by:
getSourceMappingURLin classAbstractMinimizeManager- Parameters:
line- The line- Returns:
- The source mapping URL
-
removeSourceMappingURLLine
protected String removeSourceMappingURLLine(String content)
Description copied from class:AbstractMinimizeManagerRemove the source mapping url from the content- Specified by:
removeSourceMappingURLLinein classAbstractMinimizeManager- Parameters:
content- The content- Returns:
- The content without the mention of the source mapping URL
-
formatSourceMappingURL
protected String formatSourceMappingURL(String sourceMapName)
Description copied from class:AbstractMinimizeManagerFormat a source mapping URL to be added at the end of a minimized file- Specified by:
formatSourceMappingURLin classAbstractMinimizeManager- Parameters:
sourceMapName- The map name- Returns:
- The source mapping URL line
-
-