public class RegexErrorPattern extends Object implements Cloneable
RegexErrorPattern specifies a regular expression and rules how to create markers for
Problems View. It is used by RegexErrorParser
to process build output.
Regex pattern used by this class is Java regular expression and defines capturing groups. Those capturing groups are used in file, line, description expressions to get the values.
For example: pattern "(../../..) (.*):(\d*): (Error:.*)" could go along with file-expression "$2", line-expression "$3" and description-expression "$1 $4".
Note: variable name is being stored in marker tag. However currently it is not being used.
Severity could be one of:
- IMarkerGenerator.SEVERITY_INFO
,
- IMarkerGenerator.SEVERITY_WARNING
,
- IMarkerGenerator.SEVERITY_ERROR_RESOURCE
,
- IMarkerGenerator.SEVERITY_ERROR_BUILD
- SEVERITY_SKIP
SEVERITY_SKIP
means that output line is checked to match the pattern
but won't be parsed to create a marker. It is useful with conjunction with
eatProcessedLine=true
to filter out certain lines.
eatProcessedLine
specifies if the current output line is being passed
to the rest of patterns for further processing or consumed by the pattern.
Clients may extend this class. As it implements Cloneable
interface those clients
must implement Object.clone()
and Object.equals(java.lang.Object)
methods to avoid slicing.
Modifier and Type | Field and Description |
---|---|
static int |
SEVERITY_SKIP
Additional "severity" flag which tells if qualified output line should be ignored.
|
Constructor and Description |
---|
RegexErrorPattern(String pattern,
String fileExpression,
String lineExpression,
String descriptionExpression,
String varNameExpression,
int severity,
boolean eat)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
boolean |
equals(Object o) |
protected String |
getDesc(Matcher matcher) |
String |
getDescriptionExpression() |
String |
getFileExpression() |
protected String |
getFileName(Matcher matcher) |
String |
getLineExpression() |
protected int |
getLineNum(Matcher matcher) |
String |
getPattern() |
int |
getSeverity() |
protected int |
getSeverity(Matcher matcher) |
protected String |
getVarName(Matcher matcher) |
String |
getVarNameExpression() |
boolean |
isEatProcessedLine() |
boolean |
processLine(String line,
ErrorParserManager eoParser)
Parse a line of build output and register error/warning for
Problems view.
|
protected boolean |
recordError(Matcher matcher,
ErrorParserManager eoParser)
Register the error in
ErrorParserManager . |
void |
setDescriptionExpression(String descriptionExpression) |
void |
setEatProcessedLine(boolean eatProcessedLine) |
void |
setFileExpression(String fileExpression) |
void |
setLineExpression(String lineExpression) |
void |
setPattern(String pattern) |
void |
setSeverity(int severity) |
void |
setVarNameExpression(String varNameExpression) |
public static final int SEVERITY_SKIP
public RegexErrorPattern(String pattern, String fileExpression, String lineExpression, String descriptionExpression, String varNameExpression, int severity, boolean eat)
pattern
- - regular expression describing the capturing groupsfileExpression
- - capturing group expression defining file namelineExpression
- - capturing group expression defining line numberdescriptionExpression
- - capturing group expression defining descriptionvarNameExpression
- -capturing group expression defining variable nameseverity
- - severity, one of
IMarkerGenerator.SEVERITY_INFO
,
IMarkerGenerator.SEVERITY_WARNING
,
IMarkerGenerator.SEVERITY_ERROR_RESOURCE
,
IMarkerGenerator.SEVERITY_ERROR_BUILD
SEVERITY_SKIP
eat
- - defines whether to consume output line avoiding further processing by other patterns
See general description for this class RegexErrorPattern
for more details.
public String getPattern()
public String getFileExpression()
public String getLineExpression()
public String getDescriptionExpression()
public String getVarNameExpression()
public int getSeverity()
IMarkerGenerator.SEVERITY_INFO
,
IMarkerGenerator.SEVERITY_WARNING
,
IMarkerGenerator.SEVERITY_ERROR_RESOURCE
,
IMarkerGenerator.SEVERITY_ERROR_BUILD
public boolean isEatProcessedLine()
public void setPattern(String pattern)
pattern
- - regular expression pattern describing the capturing groupspublic void setFileExpression(String fileExpression)
fileExpression
- - capturing group expression defining file namepublic void setLineExpression(String lineExpression)
lineExpression
- - capturing group expression defining line numberpublic void setDescriptionExpression(String descriptionExpression)
descriptionExpression
- - capturing group expression defining descriptionpublic void setVarNameExpression(String varNameExpression)
varNameExpression
- -capturing group expression defining variable namepublic void setSeverity(int severity)
severity
- - severity, one of
IMarkerGenerator.SEVERITY_INFO
,
IMarkerGenerator.SEVERITY_WARNING
,
IMarkerGenerator.SEVERITY_ERROR_RESOURCE
,
IMarkerGenerator.SEVERITY_ERROR_BUILD
SEVERITY_SKIP
public void setEatProcessedLine(boolean eatProcessedLine)
eatProcessedLine
- - whether to consume output line avoiding further processing by other patternsprotected String getFileName(Matcher matcher)
matcher
- - matcher to parse the input line.null
.protected int getLineNum(Matcher matcher)
matcher
- - matcher to parse the input line.0
.protected String getDesc(Matcher matcher)
matcher
- - matcher to parse the input line.null
.protected String getVarName(Matcher matcher)
matcher
- - matcher to parse the input line.null
.protected int getSeverity(Matcher matcher)
matcher
- - matcher to parse the input line.public boolean processLine(String line, ErrorParserManager eoParser)
line
- - one line of output.eoParser
- - ErrorParserManager
.true
if error/warning/info problem was found.protected boolean recordError(Matcher matcher, ErrorParserManager eoParser)
ErrorParserManager
.matcher
- - matcher to parse the input line.eoParser
- - ErrorParserManager
.true
indicating that error was found.public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Copyright (c) IBM Corp. and others 2004, 2020. All Rights Reserved.