hudson.plugins.warnings.parser
Class RegexpParser

java.lang.Object
  extended by hudson.plugins.warnings.parser.RegexpParser
All Implemented Interfaces:
WarningsParser
Direct Known Subclasses:
AntEclipseParser, AntJavacParser, GccParser, HpiCompileParser, InvalidsParser, JavacParser, JavaDocParser, MavenParser, MsBuildParser, SunCParser

public abstract class RegexpParser
extends java.lang.Object
implements WarningsParser

Parses an input stream for compiler warnings using the provided regular expression.

Author:
Ulli Hafner

Field Summary
protected static java.lang.String DEPRECATION
          Warning classification.
protected static java.lang.String PROPRIETARY_API
          Warning classification.
 
Constructor Summary
RegexpParser(java.lang.String warningPattern)
          Creates a new instance of RegexpParser.
RegexpParser(java.lang.String warningPattern, boolean useMultiLine)
          Creates a new instance of RegexpParser.
 
Method Summary
protected  java.lang.String classifyWarning(java.lang.String message)
          Classifies the warning message: tries to guess a category from the warning message.
protected abstract  Warning createWarning(java.util.regex.Matcher matcher)
          Creates a new annotation for the specified pattern.
protected  int getLineNumber(java.lang.String lineNumber)
          Converts a string line number to an integer value.
 java.util.Collection<FileAnnotation> parse(java.io.InputStream file)
          Parses the specified input stream for compiler warnings using the provided regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPRECATION

protected static final java.lang.String DEPRECATION
Warning classification.

See Also:
Constant Field Values

PROPRIETARY_API

protected static final java.lang.String PROPRIETARY_API
Warning classification.

See Also:
Constant Field Values
Constructor Detail

RegexpParser

public RegexpParser(java.lang.String warningPattern)
Creates a new instance of RegexpParser. Uses a single line matcher.

Parameters:
warningPattern - pattern of compiler warnings.

RegexpParser

public RegexpParser(java.lang.String warningPattern,
                    boolean useMultiLine)
Creates a new instance of RegexpParser.

Parameters:
warningPattern - pattern of compiler warnings.
useMultiLine - Enables multi line mode. In multi line mode the expressions ^ and $ match just after or just before, respectively, a line terminator or the end of the input sequence. By default these expressions only match at the beginning and the end of the entire input sequence.
Method Detail

parse

public java.util.Collection<FileAnnotation> parse(java.io.InputStream file)
                                           throws java.io.IOException
Parses the specified input stream for compiler warnings using the provided regular expression.

Specified by:
parse in interface WarningsParser
Parameters:
file - the file to parse
Returns:
the collection of annotations
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

createWarning

protected abstract Warning createWarning(java.util.regex.Matcher matcher)
Creates a new annotation for the specified pattern.

Parameters:
matcher - the regular expression matcher
Returns:
a new annotation for the specified pattern

getLineNumber

protected final int getLineNumber(java.lang.String lineNumber)
Converts a string line number to an integer value. If the string is not a valid line number, then 0 is returned which indicates a warning at the top of the file.

Parameters:
lineNumber - the line number (as a string)
Returns:
the line number

classifyWarning

protected java.lang.String classifyWarning(java.lang.String message)
Classifies the warning message: tries to guess a category from the warning message.

Parameters:
message - the message to check
Returns:
warning category, empty string if unknown


Copyright © 2008. All Rights Reserved.