uk.org.ogsadai.activity.files.regexp
Class OroMatcher

java.lang.Object
  |
  +--uk.org.ogsadai.activity.files.regexp.AbstractMatcher
        |
        +--uk.org.ogsadai.activity.files.regexp.OroMatcher

public class OroMatcher
extends AbstractMatcher

This class implements a matcher class designed around the Jakarta ORO regular expression support. It wraps the org.apache.oro.text.regex.PatternMatcher class to present an interface consistent with AbstractMatcher.

An instance of this class is typically obtained using the matcher() method on an instance of either the OroAwkPattern or the OroPerl5Pattern class.

Author:
The OGSA-DAI Project Team
See Also:
OroAwkPattern.matcher(), OroPerl5Pattern.matcher()

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  org.apache.oro.text.regex.PatternMatcherInput mInput
          Governs the string which we will be searching for matches within.
private  org.apache.oro.text.regex.PatternMatcher mMatcher
          The underlying org.apache.oro.text.regex.PatternMatcher object.
private  org.apache.oro.text.regex.Pattern mPattern
          The regular expression which this matcher matches.
 
Fields inherited from class uk.org.ogsadai.activity.files.regexp.AbstractMatcher
mSearchOffset
 
Constructor Summary
OroMatcher(org.apache.oro.text.regex.Pattern pattern)
          Construct a new matcher object intended to find matches of the given regular expression.
 
Method Summary
 int endOffset()
          Return the offset of the end of the most recent match of the regular expression found in the input text.
 boolean findNextMatch()
          Search the input string for the next occurrence of a match of the regular expression.
 java.lang.String group(int index)
          Returns the input subsequence captured by the given group during the previous match operation.
 int groupCount()
          Returns the number of capturing groups in this matcher's regular expression.
 void setInput(java.lang.String input)
          Register a string of text as the text over which this matcher object searches for occurrences of its regular expression.
 int startOffset()
          Return the offset of the start of the most recent match of the regular expression found in the input text.
 
Methods inherited from class uk.org.ogsadai.activity.files.regexp.AbstractMatcher
getSearchOffset, groups, setSearchOffset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

mPattern

private org.apache.oro.text.regex.Pattern mPattern
The regular expression which this matcher matches.


mMatcher

private org.apache.oro.text.regex.PatternMatcher mMatcher
The underlying org.apache.oro.text.regex.PatternMatcher object.


mInput

private org.apache.oro.text.regex.PatternMatcherInput mInput
Governs the string which we will be searching for matches within.

Constructor Detail

OroMatcher

public OroMatcher(org.apache.oro.text.regex.Pattern pattern)
           throws UnsupportedRegexpPatternFormatException
Construct a new matcher object intended to find matches of the given regular expression.

Parameters:
pattern - the regular expression to find matches of
Throws:
UnsupportedRegexpPatternFormatException; - if the pattern is not of a type supported by Jakarta ORO i.e. is not an instance of Perl5Pattern or AwkPattern.
UnsupportedRegexpPatternFormatException
Method Detail

setInput

public void setInput(java.lang.String input)
Description copied from class: AbstractMatcher
Register a string of text as the text over which this matcher object searches for occurrences of its regular expression. After this text has been registered, occurrences can be located using the findNextMatch() method.

Specified by:
setInput in class AbstractMatcher
Parameters:
input - The string of text to search within

findNextMatch

public boolean findNextMatch()
                      throws java.lang.IllegalStateException
Description copied from class: AbstractMatcher
Search the input string for the next occurrence of a match of the regular expression. Iff such a match exists, this method returns true and causes the details regarding the match to be stored locally. These details include the offset in the entire input string of the start and the end positions of the match; and the actual text which matched the parenthesised groups in the regular expression this matcher matches.

Specified by:
findNextMatch in class AbstractMatcher
Returns:
true if another occurrence of a match of the regular expression exists;
false otherwise
Throws:
java.lang.IllegalStateException - if no text input has yet been registered via the setInput(String) method

startOffset

public int startOffset()
Description copied from class: AbstractMatcher
Return the offset of the start of the most recent match of the regular expression found in the input text.

Specified by:
startOffset in class AbstractMatcher
Returns:
the start offset

endOffset

public int endOffset()
Description copied from class: AbstractMatcher
Return the offset of the end of the most recent match of the regular expression found in the input text.

Specified by:
endOffset in class AbstractMatcher
Returns:
the end offset

groupCount

public int groupCount()
Description copied from class: AbstractMatcher
Returns the number of capturing groups in this matcher's regular expression. Note that group 0, denoting the entire match, is not included in this count.

Specified by:
groupCount in class AbstractMatcher
Returns:
the number of groups

group

public java.lang.String group(int index)
Description copied from class: AbstractMatcher
Returns the input subsequence captured by the given group during the previous match operation. Group 0 refers to the entire match. If a group was not matched or does not exist then null is returned.

Specified by:
group in class AbstractMatcher
Parameters:
index - the index of the capturing group, or zero
Returns:
the text matching the given group, or null