public class DefaultDocumentReader extends Object implements DocumentReader
| Constructor and Description |
|---|
DefaultDocumentReader(String document)
Instantiates the reader while taking in the document to be read through
|
| Modifier and Type | Method and Description |
|---|---|
void |
backtrack(int count)
Moves back the specified number of characters
|
String |
expect(Pattern pattern)
This will attempt to read string matching the given pattern from the document at the current point
indicated by the cursor.
|
String |
expect(String pattern)
This will attempt to read string matching the given pattern from the document at the current point
indicated by the cursor.
|
boolean |
has(Pattern pattern)
This method will determine whether the indicated pattern can be found at this point in the document or not
|
boolean |
has(String pattern)
This method will determine whether the indicated pattern can be found at this point in the document or not
|
boolean |
hasMore()
Determines whether we have hit the end of the document or not
|
String |
read(Pattern pattern)
Will attempt to read the string matching the given parameter.
|
String |
read(String pattern)
Will attempt to read the string matching the given parameter.
|
void |
reset()
This will cause the state of the reading to be reset.
|
String |
rest()
This will return the parts of document not yet read through by the reader
|
public DefaultDocumentReader(String document)
document - the documentpublic String rest()
rest in interface DocumentReaderpublic boolean has(Pattern pattern)
has in interface DocumentReaderpattern - the lookup patterntrue if the pattern can be foundpublic boolean has(String pattern)
has in interface DocumentReaderpattern - the lookup patterntrue if the pattern can be foundpublic boolean hasMore()
hasMore in interface DocumentReadertrue if we have no more to gopublic String read(Pattern pattern)
read in interface DocumentReaderpattern - the compiled pattern to be matched againstnull if it cannot be foundPattern.compile(String),
Pattern.compile(String, int)public String read(String pattern)
read in interface DocumentReaderpattern - the compiled pattern to be matched againstnull if it cannot be foundPattern.compile(String),
Pattern.compile(String, int)public String expect(Pattern pattern)
expect in interface DocumentReaderpattern - the regular to query forpublic String expect(String pattern)
DocumentReaderexpect in interface DocumentReaderpattern - the regular to query forpublic void reset()
reset in interface DocumentReaderpublic void backtrack(int count)
backtrack in interface DocumentReadercount - character count to backtrack byCopyright © 2014–2016. All rights reserved.