ro.isdc.wro.extensions.processor.js
Class AbstractLinterProcessor

java.lang.Object
  extended by ro.isdc.wro.extensions.processor.js.AbstractLinterProcessor
All Implemented Interfaces:
ResourcePostProcessor, ResourcePreProcessor
Direct Known Subclasses:
JsHintProcessor, JsLintProcessor

@SupportedResourceType(value=JS)
public abstract class AbstractLinterProcessor
extends Object
implements ResourcePreProcessor, ResourcePostProcessor

Processor which analyze the js code and warns you about any problems. The processing result won't change no matter if the processed script contains errors or not.

Since:
1.3.5
Author:
Alex Objelean

Constructor Summary
AbstractLinterProcessor()
           
 
Method Summary
protected  String createDefaultOptions()
           
protected abstract  AbstractLinter newLinter()
           
protected  void onException(WroRuntimeException e)
          Invoked when a processing exception occurs.
protected  void onLinterException(LinterException e, Resource resource)
          Called when LinterException is thrown.
 void process(Reader reader, Writer writer)
          Perform actual resource processing.
 void process(Resource resource, Reader reader, Writer writer)
          Process a content supplied by a reader and perform some sort of processing.
 AbstractLinterProcessor setOptions(String... options)
          Deprecated. 
 AbstractLinterProcessor setOptionsAsString(String options)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLinterProcessor

public AbstractLinterProcessor()
Method Detail

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.

Specified by:
process in interface ResourcePreProcessor
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.

onException

protected void onException(WroRuntimeException e)
Invoked when a processing exception occurs.


process

public void process(Reader reader,
                    Writer writer)
             throws IOException
Perform actual resource processing. The content to be processed is read from source Reader and is written to destination Writer. It is the client responsibility to close both: Reader and writer.

Specified by:
process in interface ResourcePostProcessor
Parameters:
reader - source stream.
writer - destination stream.
Throws:
IOException

onLinterException

protected void onLinterException(LinterException e,
                                 Resource resource)
Called when LinterException is thrown. Allows subclasses to re-throw this exception as a RuntimeException or handle it differently. The default implementation simply logs the errors.

Parameters:
e - LinterException which has occurred.
resource - the processed resource which caused the exception.

createDefaultOptions

protected String createDefaultOptions()
Returns:
default options to use for linting.

setOptionsAsString

public AbstractLinterProcessor setOptionsAsString(String options)
Parameters:
options - comma separated list of options.

setOptions

@Deprecated
public AbstractLinterProcessor setOptions(String... options)
Deprecated. 

Sets an array of options. Use setOptionsAsString(String) instead.


newLinter

protected abstract AbstractLinter newLinter()
Returns:
the linter to use for js code validation.


Copyright © 2008-2013. All Rights Reserved.