hudson.plugins.dry.parser
Class AbstractDryParser

java.lang.Object
  extended by hudson.plugins.dry.parser.AbstractDryParser
All Implemented Interfaces:
hudson.plugins.analysis.core.AnnotationParser, Serializable
Direct Known Subclasses:
CpdParser, SimianParser

public abstract class AbstractDryParser
extends Object
implements hudson.plugins.analysis.core.AnnotationParser

A base class for duplicate code parsers. Use this class as a starting point for your duplication result parser and register an instance in the DuplicationParserRegistry.

Author:
Ulli Hafner
See Also:
Serialized Form

Constructor Summary
AbstractDryParser(int highThreshold, int normalThreshold)
          Creates a new instance of AbstractDryParser.
 
Method Summary
protected abstract  boolean accepts(InputStream inputStream)
          Returns whether this parser accepts the specified stream as a valid file.
protected  hudson.plugins.analysis.util.model.Priority getPriority(int lines)
          Returns the priority of the warning.
 Collection<hudson.plugins.analysis.util.model.FileAnnotation> parse(File file, String moduleName)
          
protected abstract  Collection<DuplicateCode> parse(InputStream inputStream, String moduleName)
          Returns the duplication 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

AbstractDryParser

public AbstractDryParser(int highThreshold,
                         int normalThreshold)
Creates a new instance of AbstractDryParser.

Parameters:
highThreshold - minimum number of duplicate lines for high priority warnings
normalThreshold - minimum number of duplicate lines for normal priority warnings
Method Detail

parse

public Collection<hudson.plugins.analysis.util.model.FileAnnotation> parse(File file,
                                                                           String moduleName)
                                                                    throws InvocationTargetException

Specified by:
parse in interface hudson.plugins.analysis.core.AnnotationParser
Throws:
InvocationTargetException

parse

protected abstract Collection<DuplicateCode> parse(InputStream inputStream,
                                                   String moduleName)
                                            throws InvocationTargetException
Returns the duplication annotations found in the specified file.

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

accepts

protected abstract boolean accepts(InputStream inputStream)
Returns whether this parser accepts the specified stream as a valid file.

Parameters:
inputStream - the file to parse
Returns:
true if this parser accepts the specified stream as a valid file, false if the parser can't read this file

getPriority

protected hudson.plugins.analysis.util.model.Priority getPriority(int lines)
Returns the priority of the warning.

Parameters:
lines - number of duplicate lines
Returns:
the priority of the warning


Copyright © 2004-2013 Hudson. All Rights Reserved.