org.apache.sling.fileoptim

## Interface FileOptimizerService

All Known Implementing Classes:
  FileOptimizerServiceImpl

    @ProviderType
    public interface FileOptimizerService

A service for optimizing files stored in Sling Resources.

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `canOptimize(org.apache.sling.api.resource.Resource fileResource)` Returns true if the resource is a registered type, the CA Config for the resource is enabled and if an optimizer is registered for the file's meta type
`OptimizationResult` `getOptimizedContents(org.apache.sling.api.resource.Resource fileResource)` Gets the optimized contents of a file resource.
`boolean` `isOptimized(org.apache.sling.api.resource.Resource fileResource)` Returns true if the specified resource has already been optimized by the FileOptimizer.
`OptimizationResult` `optimizeFile(org.apache.sling.api.resource.Resource fileResource, boolean autoCommit)` Optimizes a file resource.

### Method Detail

#### canOptimize

    boolean canOptimize(org.apache.sling.api.resource.Resource fileResource)

Returns true if the resource is a registered type, the CA Config for the resource is enabled and if an optimizer is registered for the file's meta type

Parameters:
  `fileResource` - the resource to check if the optimizer is available
Returns:
  true if the file optimizer can optimize the file, false otherwise

#### getOptimizedContents

    OptimizationResult getOptimizedContents(org.apache.sling.api.resource.Resource fileResource)
                                     throws IOException

Gets the optimized contents of a file resource. This will not update the underlying resource, but instead just returns the results of optimizing the resource.

Parameters:
  `fileResource` - the resource to optimize
Returns:
  the results of the optimization
Throws:
  `IOException` - an exception occurs reading the original resource

#### isOptimized

    boolean isOptimized(org.apache.sling.api.resource.Resource fileResource)

Returns true if the specified resource has already been optimized by the FileOptimizer.

Parameters:
  `fileResource` - the resource to check
Returns:
  true if optimized by the file optimizer, false otherwise

#### optimizeFile

    OptimizationResult optimizeFile(org.apache.sling.api.resource.Resource fileResource,
                                    boolean autoCommit)
                             throws IOException

Optimizes a file resource. This method will modify the underlying resource.

Parameters:
  `fileResource` - the resource to optimize
  `autoCommit` - if true, the results will automatically be committed to the Sling Repo
Returns:
  the results of the optimization
Throws:
  `IOException` - an exception occurs reading the original resource