hudson.plugins.analysis.core
Class AbstractAnnotationParser

java.lang.Object
  extended by hudson.plugins.analysis.core.AbstractAnnotationParser
All Implemented Interfaces:
AnnotationParser, Serializable

public abstract class AbstractAnnotationParser
extends Object
implements AnnotationParser

A base class for parsers that work on files and produce annotations.

Author:
Ulli Hafner
See Also:
Serialized Form

Constructor Summary
protected AbstractAnnotationParser(String defaultEncoding)
          Creates a new instance of AbstractAnnotationParser.
 
Method Summary
protected  int createContextHashCode(String fileName, int line)
          Creates a hash code from the source code of the warning line and the surrounding context.
protected  String getDefaultEncoding()
          Returns the default encoding to be used when reading and parsing files.
protected  Collection<FileAnnotation> intern(Collection<FileAnnotation> annotations)
          Let FileAnnotations share some of their internal data structure to reduce memory footprint.
 Collection<FileAnnotation> parse(File file, String moduleName)
          Returns the annotations found in the specified file.
abstract  Collection<FileAnnotation> parse(InputStream file, String moduleName)
          Returns the annotations found in the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAnnotationParser

protected AbstractAnnotationParser(String defaultEncoding)
Creates a new instance of AbstractAnnotationParser.

Parameters:
defaultEncoding - the default encoding to be used when reading and parsing files
Method Detail

getDefaultEncoding

protected final String getDefaultEncoding()
Returns the default encoding to be used when reading and parsing files.

Returns:
the default encoding

parse

public Collection<FileAnnotation> parse(File file,
                                        String moduleName)
                                 throws InvocationTargetException
Returns the annotations found in the specified file.

Specified by:
parse in interface AnnotationParser
Parameters:
file - the file to parse
moduleName - name of the maven module
Returns:
the parsed result (stored in the module instance)
Throws:
InvocationTargetException - if the file could not be parsed (wrap your exception in this exception)

intern

protected Collection<FileAnnotation> intern(Collection<FileAnnotation> annotations)
Let FileAnnotations share some of their internal data structure to reduce memory footprint.

Parameters:
annotations - the annotations to compress
Returns:
The same object as passed in the 'annotations' parameter to let this function used as a filter.

parse

public abstract Collection<FileAnnotation> parse(InputStream file,
                                                 String moduleName)
                                          throws InvocationTargetException
Returns the annotations found in the specified file.

Parameters:
file - the file to parse
moduleName - name of the maven module
Returns:
the found annotations
Throws:
InvocationTargetException - if the file could not be parsed (wrap your exception in this exception)

createContextHashCode

protected int createContextHashCode(String fileName,
                                    int line)
                             throws IOException
Creates a hash code from the source code of the warning line and the surrounding context.

Parameters:
fileName - the absolute path of the file to read
line - the line of the warning
Returns:
a has code of the source code
Throws:
IOException - if the contents of the file could not be read


Copyright © 2004-2012 Hudson. All Rights Reserved.