@Deprecated
public class EntryReader
extends java.io.LineNumberReader
implements java.lang.Iterable<java.lang.String>, java.util.Iterator<java.lang.String>
Example use:
// EntryReader constructor args are: filename, comment regexp, include regexp
try (EntryReader er = new EntryReader(filename, "^#.*", null)) {
for (String line : er) {
...
}
} catch (IOException e) {
System.err.println("Problem reading " + filename + ": " + e.getMessage());
}
Modifier and Type | Class and Description |
---|---|
static class |
EntryReader.Entry
Deprecated.
Descriptor for an entry (record, paragraph, etc.).
|
Modifier and Type | Field and Description |
---|---|
java.util.regex.Pattern |
entry_start_re
Deprecated.
Regular expression that starts a long entry.
|
java.util.regex.Pattern |
entry_stop_re
Deprecated.
|
Constructor and Description |
---|
EntryReader(java.io.File file)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.io.File file,
java.lang.String charsetName)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.io.File file,
java.lang.String comment_re,
java.lang.String include_re)
Deprecated.
Create an EntryReader.
|
EntryReader(java.io.InputStream in)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.io.InputStream in,
java.lang.String filename)
Deprecated.
Create a EntryReader that uses the default character set and does not support comments or
include directives.
|
EntryReader(java.io.InputStream in,
java.lang.String charsetName,
java.lang.String filename)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.io.InputStream in,
java.lang.String filename,
java.lang.String comment_re_string,
java.lang.String include_re_string)
Deprecated.
Create a EntryReader.
|
EntryReader(java.io.InputStream in,
java.lang.String charsetName,
java.lang.String filename,
java.lang.String comment_re_string,
java.lang.String include_re_string)
Deprecated.
Create a EntryReader that uses the given character set.
|
EntryReader(java.io.Reader reader)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.io.Reader reader,
java.lang.String filename,
java.lang.String comment_re_string,
java.lang.String include_re_string)
Deprecated.
Create a EntryReader.
|
EntryReader(java.lang.String filename)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.lang.String filename,
java.lang.String charsetName)
Deprecated.
Create a EntryReader that does not support comments or include directives.
|
EntryReader(java.lang.String filename,
java.lang.String comment_re,
java.lang.String include_re)
Deprecated.
Create a new EntryReader starting with the specified file.
|
Modifier and Type | Method and Description |
---|---|
EntryReader.Entry |
get_entry()
Deprecated.
Returns the next entry (paragraph) in the file.
|
java.lang.String |
getFileName()
Deprecated.
Returns the current filename.
|
int |
getLineNumber()
Deprecated.
Return the current line number in the current file.
|
boolean |
hasNext()
Deprecated.
Returns whether or not there is another line to read.
|
java.util.Iterator<java.lang.String> |
iterator()
Deprecated.
Return a line-by-line iterator for this file.
|
static void |
main(java.lang.String[] args)
Deprecated.
Simple usage example.
|
void |
mark(int readAheadLimit)
Deprecated.
|
java.lang.String |
next()
Deprecated.
Return the next line in the multi-file.
|
void |
putback(java.lang.String line)
Deprecated.
Puts the specified line back in the input.
|
int |
read()
Deprecated.
|
int |
read(char[] cbuf,
int off,
int len)
Deprecated.
|
java.lang.String |
readLine()
Deprecated.
Read a line, ignoring comments and processing includes.
|
void |
remove()
Deprecated.
remove() is not supported.
|
void |
reset()
Deprecated.
|
void |
set_entry_start_stop(java.util.regex.Pattern entry_start_re,
java.util.regex.Pattern entry_stop_re)
Deprecated.
Set the regular expressions for the start and stop of long entries (multiple lines that are
read as a group by get_entry()).
|
void |
set_entry_start_stop(java.lang.String entry_start_re,
java.lang.String entry_stop_re)
Deprecated.
Set the regular expressions for the start and stop of long entries (multiple lines that are
read as a group by get_entry()).
|
void |
setLineNumber(int lineNumber)
Deprecated.
Set the current line number in the current file.
|
long |
skip(long n)
Deprecated.
|
public java.util.regex.Pattern entry_start_re
If the first line of an entry matches this regexp, then the entry is terminated by: entry_stop_re
, another line that matches entry_start_re
(even not following a
newline), or the end of the current file.
Otherwise, the first line of an entry does NOT match this regexp (or the regexp is null), in which case the entry is terminated by a blank line or the end of the current file.
public java.util.regex.Pattern entry_stop_re
entry_start_re
public EntryReader(java.io.InputStream in, java.lang.String charsetName, java.lang.String filename, java.lang.String comment_re_string, java.lang.String include_re_string) throws java.io.UnsupportedEncodingException
in
- source from which to read entriescharsetName
- the character set to usefilename
- non-null file name for stream being readcomment_re_string
- regular expression that matches comments. Any text that matches
comment_re is removed. A line that is entirely a comment is ignored.include_re_string
- regular expression that matches include directives. The expression
should define one group that contains the include file name.java.io.UnsupportedEncodingException
- if the charset encoding is not supportedEntryReader(InputStream,String,String,String)
public EntryReader(java.io.InputStream in, java.lang.String charsetName, java.lang.String filename) throws java.io.UnsupportedEncodingException
in
- the InputStreamcharsetName
- the character set to usefilename
- the file namejava.io.UnsupportedEncodingException
- if the charset encoding is not supportedEntryReader(InputStream,String,String,String)
public EntryReader(java.io.InputStream in, java.lang.String filename, java.lang.String comment_re_string, java.lang.String include_re_string)
in
- source from which to read entriesfilename
- non-null file name for stream being readcomment_re_string
- regular expression that matches comments. Any text that matches
comment_re is removed. A line that is entirely a comment is ignored.include_re_string
- regular expression that matches include directives. The expression
should define one group that contains the include file name.public EntryReader(java.io.InputStream in, java.lang.String filename)
in
- the InputStreamfilename
- the file nameEntryReader(InputStream,String,String,String,String)
public EntryReader(java.io.InputStream in)
in
- the InputStreamEntryReader(InputStream,String,String,String)
public EntryReader(java.io.Reader reader, java.lang.String filename, java.lang.String comment_re_string, java.lang.String include_re_string)
reader
- source from which to read entriesfilename
- file name corresponding to reader, for use in error messagescomment_re_string
- regular expression that matches comments. Any text that matches
comment_re is removed. A line that is entirely a comment is ignoredinclude_re_string
- regular expression that matches include directives. The expression
should define one group that contains the include file namepublic EntryReader(java.io.Reader reader)
reader
- source from which to read entriesEntryReader(Reader,String,String,String)
public EntryReader(java.io.File file, java.lang.String comment_re, java.lang.String include_re) throws java.io.IOException
file
- initial file to readcomment_re
- regular expression that matches comments. Any text that matches comment_re is
removed. A line that is entirely a comment is ignored.include_re
- regular expression that matches include directives. The expression should
define one group that contains the include file name.java.io.IOException
- if there is a problem reading the filepublic EntryReader(java.io.File file) throws java.io.IOException
file
- the file to readjava.io.IOException
- if there is a problem reading the fileEntryReader(File,String,String)
public EntryReader(java.io.File file, java.lang.String charsetName) throws java.io.IOException
file
- the file to readcharsetName
- the character set to usejava.io.IOException
- if there is a problem reading the fileEntryReader(File,String,String)
public EntryReader(java.lang.String filename, java.lang.String comment_re, java.lang.String include_re) throws java.io.IOException
filename
- initial file to readcomment_re
- regular expression that matches comments. Any text that matches comment_re
is removed. A line that is entirely a comment is ignored.include_re
- regular expression that matches include directives. The expression should
define one group that contains the include file name.java.io.IOException
- if there is a problem reading the fileEntryReader(File,String,String)
public EntryReader(java.lang.String filename) throws java.io.IOException
filename
- source from which to read entriesjava.io.IOException
- if there is a problem reading the fileEntryReader(String,String,String)
public EntryReader(java.lang.String filename, java.lang.String charsetName) throws java.io.IOException
filename
- source from which to read entriescharsetName
- the character set to usejava.io.IOException
- if there is a problem reading the fileEntryReader(String,String,String)
public java.lang.String readLine() throws java.io.IOException
readLine
in class java.io.LineNumberReader
java.io.IOException
public java.util.Iterator<java.lang.String> iterator()
Warning: This does not return a fresh iterator each time. The iterator is a singleton, the same one is returned each time, and a new one can never be created after it is exhausted.
iterator
in interface java.lang.Iterable<java.lang.String>
public boolean hasNext()
hasNext
in interface java.util.Iterator<java.lang.String>
public java.lang.String next()
next
in interface java.util.Iterator<java.lang.String>
java.util.NoSuchElementException
- at end of filepublic void remove()
remove
in interface java.util.Iterator<java.lang.String>
public EntryReader.Entry get_entry() throws java.io.IOException
entry_start_re
(see set_entry_start_stop(java.lang.String, java.lang.String)
). If no more
entries are available, returns null.java.io.IOException
- if there is a problem reading the filepublic java.lang.String getFileName()
public int getLineNumber()
getLineNumber
in class java.io.LineNumberReader
public void setLineNumber(int lineNumber)
setLineNumber
in class java.io.LineNumberReader
lineNumber
- new line number for the current filepublic void set_entry_start_stop(java.lang.String entry_start_re, java.lang.String entry_stop_re)
entry_start_re
- regular expression that starts a long entryentry_stop_re
- regular expression that ends a long entrypublic void set_entry_start_stop(java.util.regex.Pattern entry_start_re, java.util.regex.Pattern entry_stop_re)
entry_start_re
- regular expression that starts a long entryentry_stop_re
- regular expression that ends a long entrypublic void putback(java.lang.String line)
line
- the line to be put back in the inputpublic void mark(int readAheadLimit)
mark
in class java.io.LineNumberReader
public int read()
read
in class java.io.LineNumberReader
public int read(char[] cbuf, int off, int len)
read
in class java.io.LineNumberReader
public void reset()
reset
in class java.io.LineNumberReader
public long skip(long n)
skip
in class java.io.LineNumberReader
public static void main(java.lang.String[] args) throws java.io.IOException
args
- command-line arguments: filename [comment_re [include_re]]java.io.IOException
- if there is a problem reading a file