Package gnu.regexp
Class REMatchEnumeration
- java.lang.Object
-
- gnu.regexp.REMatchEnumeration
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Enumeration
public class REMatchEnumeration extends java.lang.Object implements java.util.Enumeration, java.io.Serializable
An REMatchEnumeration enumerates regular expression matches over a given input text. You obtain a reference to an enumeration using thegetMatchEnumeration()
methods on an instance of RE.REMatchEnumeration does lazy computation; that is, it will not search for a match until it needs to. If you'd rather just get all the matches at once in a big array, use the
getAllMatches()
methods on RE. However, using an enumeration can help speed performance when the entire text does not need to be searched immediately.The enumerated type is especially useful when searching on a Reader or InputStream, because the InputStream read position cannot be guaranteed after calling
getMatch()
(see the description of that method for an explanation of why). Enumeration also saves a lot of overhead required when callinggetMatch()
multiple times.- Author:
- Wes Biggs
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description REMatchEnumeration(RE expr, CharIndexed input, int index, int eflags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasMoreElements()
Returns true if there are more matches in the input text.boolean
hasMoreMatches()
Returns true if there are more matches in the input text.boolean
hasMoreMatches(java.lang.StringBuffer buffer)
Returns true if there are more matches in the input text.java.lang.Object
nextElement()
Returns the next match in the input text.REMatch
nextMatch()
Returns the next match in the input text.
-
-
-
Constructor Detail
-
REMatchEnumeration
REMatchEnumeration(RE expr, CharIndexed input, int index, int eflags)
-
-
Method Detail
-
hasMoreElements
public boolean hasMoreElements()
Returns true if there are more matches in the input text.- Specified by:
hasMoreElements
in interfacejava.util.Enumeration
-
hasMoreMatches
public boolean hasMoreMatches()
Returns true if there are more matches in the input text.
-
hasMoreMatches
public boolean hasMoreMatches(java.lang.StringBuffer buffer)
Returns true if there are more matches in the input text. Saves the text leading up to the match (or to the end of the input) in the specified buffer.
-
nextElement
public java.lang.Object nextElement() throws java.util.NoSuchElementException
Returns the next match in the input text.- Specified by:
nextElement
in interfacejava.util.Enumeration
- Throws:
java.util.NoSuchElementException
-
nextMatch
public REMatch nextMatch() throws java.util.NoSuchElementException
Returns the next match in the input text. This method is provided for convenience to avoid having to explicitly cast the return value to class REMatch.- Throws:
java.util.NoSuchElementException
-
-