ro.isdc.wro.model.resource.processor.decorator
Class ProcessorDecorator
java.lang.Object
ro.isdc.wro.util.AbstractDecorator<T>
ro.isdc.wro.model.resource.processor.decorator.AbstractProcessorDecoratorSupport<ResourcePreProcessor>
ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator
- All Implemented Interfaces:
- ImportAware, MinimizeAware, ResourcePostProcessor, ResourcePreProcessor, SupportAware, SupportedResourceTypeAware, ObjectDecorator<ResourcePreProcessor>
- Direct Known Subclasses:
- AbstractProcessorDecorator, BenchmarkProcessorDecorator, CopyrightKeeperProcessorDecorator, DefaultProcessorDecorator, ExceptionHandlingProcessorDecorator, ExtensionsAwareProcessorDecorator, ImportAwareProcessorDecorator, MinimizeAwareProcessorDecorator, PathPatternProcessorDecorator, SupportAwareProcessorDecorator
public class ProcessorDecorator
- extends AbstractProcessorDecoratorSupport<ResourcePreProcessor>
Default implementation which can decorate a processor. This class is still named ProcessorDecorator
, though
it is not abstract (for backward compatibility reasons). It will be renamed to ProcessorDecorator.
- Since:
- 1.4.1
- Author:
- Alex Objelean
ProcessorDecorator
public ProcessorDecorator(Object processor)
- Hides the postProcessor adaptation logic. This exist due to differences between pre & post processor interface.
This will be removed in 1.5.0 when all processors will have an unified interface.
process
public void process(Resource resource,
Reader reader,
Writer writer)
throws IOException
- Process a content supplied by a reader and perform some sort of processing. It is important to know that you should
use reader for processing instead of trying to access the resource original content using
Resource
, because
this way you can ignore the other preProcessors from the chain.
It is not require to explicitly handle exception. When the processing fails, the following can happen:
It is not required to close the reader and writers, because these will be closed for you.
- Parameters:
resource
- the original resource as it found in the model.reader
- Reader
used to read processed resource content.writer
- Writer
where used to write processed results.
- Throws:
IOException
- when an exception occurs. The future version will change the exception type to Exception
, because
any exception may occur during processing. The processing failure will be handled based on value of
WroConfiguration.isIgnoreFailingProcessor()
configuration flag.
isEligible
public final boolean isEligible(boolean minimize,
ResourceType searchedType)
- Indicates if the processor is eligible for usage based on provided criteria.
- Parameters:
minimize
- - when true the processor should be minimize aware.searchedType
- - the type of the accepted processor. If the processor will have no type specified it will still be
eligible.
- Returns:
- true if this processor is of searchedType.
isEnabled
protected boolean isEnabled(Resource resource)
- Parameters:
resource
- ResourcePreProcessor
for which enabled flag should be checked.
- Returns:
- a flag indicating if this processor is enabled. When false, the processing will be skipped and the content
will be left unchanged. This value is true by default.
toString
public String toString()
-
- Overrides:
toString
in class AbstractDecorator<ResourcePreProcessor>
Copyright © 2008-2013. All Rights Reserved.