hudson.plugins.warnings.parser
Class RegexpParser

java.lang.Object
  extended by hudson.plugins.warnings.parser.RegexpParser
All Implemented Interfaces:
WarningsParser
Direct Known Subclasses:
RegexpDocumentParser, RegexpLineParser

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, boolean useMultiLine, java.lang.String name)
          Creates a new instance of RegexpParser.
RegexpParser(java.lang.String warningPattern, java.lang.String name)
          Creates a new instance of RegexpParser.
 
Method Summary
protected  java.lang.String classifyIfEmpty(java.lang.String group, java.lang.String message)
          Returns a category for the current warning.
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  void findAnnotations(java.lang.String content, java.util.List<FileAnnotation> warnings)
          Parses the specified string content and creates annotations for each found warning.
protected  int getLineNumber(java.lang.String lineNumber)
          Converts a string line number to an integer value.
 java.lang.String getName()
          Gets the human readable name of this parser.
 void setName(java.lang.String name)
          Sets the name to the specified value.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hudson.plugins.warnings.parser.WarningsParser
parse
 

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,
                    java.lang.String name)
Creates a new instance of RegexpParser. Uses a single line matcher.

Parameters:
warningPattern - pattern of compiler warnings.
name - name of the parser

RegexpParser

public RegexpParser(java.lang.String warningPattern,
                    boolean useMultiLine,
                    java.lang.String name)
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.
name - name of the parser
Method Detail

findAnnotations

protected void findAnnotations(java.lang.String content,
                               java.util.List<FileAnnotation> warnings)
Parses the specified string content and creates annotations for each found warning.

Parameters:
content - the content to scan
warnings - the found annotations

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Gets the human readable name of this parser.

Specified by:
getName in interface WarningsParser
Returns:
the name

setName

public void setName(java.lang.String name)
Sets the name to the specified value.

Parameters:
name - the value to set

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

classifyIfEmpty

protected java.lang.String classifyIfEmpty(java.lang.String group,
                                           java.lang.String message)
Returns a category for the current warning. If the provided category is not empty, then a capitalized string is returned. Otherwise the category is obtained from the specified message text.

Parameters:
group - the warning category (might be empty)
message - the warning message
Returns:
the actual category


Copyright © 2009. All Rights Reserved.