|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javatools.datatypes.PeekIterator<java.util.regex.MatchResult> javatools.filehandlers.MatchReader
public class MatchReader
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools).
It is licensed under the Creative Commons Attribution License
(see http://creativecommons.org/licenses/by/3.0) by
the YAGO-NAGA team (see http://mpii.de/yago-naga).
The MatchReader reads MatchResults from a file.
It closes the Reader automatically if hasNext()==false.
The MatchReader buffers always 1000 characters of the file, i.e.
it can work with large files without caching them in total.
Example:
MatchReader matchReader=new MatchReader("some Filename", "some Pattern"); for(MatchResult matchResult : matchReader) { System.out.println(matchResult.group(1)); }The file is automatically closed after the last match has been read. If you do not read all matches, close the iterator manually by the method close().
A single quote (') preceded by a backslash will not match a quote in the pattern.
Nested Class Summary | |
---|---|
static class |
MatchReader.MyMatchResult
A MatchResult that undoes the quotes |
Nested classes/interfaces inherited from class javatools.datatypes.PeekIterator |
---|
PeekIterator.ElementaryPeekIterator<T>, PeekIterator.SimplePeekIterator<T> |
Field Summary | |
---|---|
int |
BUFSIZE
Number of newly read chars |
int |
MAXPATTERNLENGTH
Maximal length of a String matching a pattern |
static java.lang.String |
QUOTE
Holds the string that quotes are replaced by |
Fields inherited from class javatools.datatypes.PeekIterator |
---|
closed, initialized, next |
Constructor Summary | |
---|---|
MatchReader(java.io.File f,
java.util.regex.Pattern p)
Constructs a MatchReader that reads from a file |
|
MatchReader(java.io.File f,
java.util.regex.Pattern p,
java.lang.String announceMsg)
Constructs a MatchReader that reads from a file, with progress message (main constructor) |
|
MatchReader(java.io.File f,
java.lang.String p)
Constructs a MatchReader that reads from a file |
|
MatchReader(java.io.File f,
java.lang.String p,
boolean crossLines)
Constructs a MatchReader that reads from a file |
|
MatchReader(java.io.File f,
java.lang.String p,
java.lang.String announceMsg)
Constructs a MatchReader that reads from a file, with progress message |
|
MatchReader(java.io.Reader i,
java.util.regex.Pattern p)
Constructs a MatchReader from a Reader and a Pattern |
|
MatchReader(java.io.Reader i,
java.lang.String p)
Constructs a MatchReader from a Reader and a Pattern |
|
MatchReader(java.lang.String f,
java.util.regex.Pattern p)
Constructs a MatchReader that reads from a file |
|
MatchReader(java.lang.String f,
java.util.regex.Pattern p,
java.lang.String announceMsg)
Constructs a MatchReader that reads from a file, with progress message |
|
MatchReader(java.lang.String f,
java.lang.String p)
Constructs a MatchReader that reads from a file |
|
MatchReader(java.lang.String f,
java.lang.String p,
java.lang.String announceMsg)
Constructs a MatchReader that reads from a file, with progress message |
Method Summary | |
---|---|
void |
close()
Closes the reader |
void |
finalize()
Closes the reader |
java.util.regex.MatchResult |
internalNext()
Returns the next MatchResult |
static void |
main(java.lang.String[] args)
Test routine |
Methods inherited from class javatools.datatypes.PeekIterator |
---|
asList, asList, asSet, asSet, asSet, emptyIterator, hasNext, iterator, list, list, next, nextOrNull, numElements, numElements, peek, remove, toString, toString, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int BUFSIZE
public final int MAXPATTERNLENGTH
public static final java.lang.String QUOTE
Constructor Detail |
---|
public MatchReader(java.io.Reader i, java.util.regex.Pattern p)
public MatchReader(java.io.Reader i, java.lang.String p)
public MatchReader(java.io.File f, java.util.regex.Pattern p, java.lang.String announceMsg) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.lang.String f, java.util.regex.Pattern p, java.lang.String announceMsg) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.lang.String f, java.lang.String p, java.lang.String announceMsg) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.io.File f, java.lang.String p, java.lang.String announceMsg) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.io.File f, java.lang.String p, boolean crossLines) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.io.File f, java.lang.String p) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.lang.String f, java.lang.String p) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.lang.String f, java.util.regex.Pattern p) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public MatchReader(java.io.File f, java.util.regex.Pattern p) throws java.io.FileNotFoundException
java.io.FileNotFoundException
Method Detail |
---|
public java.util.regex.MatchResult internalNext()
public void close()
close
in interface java.io.Closeable
close
in class PeekIterator<java.util.regex.MatchResult>
public void finalize()
finalize
in class java.lang.Object
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |