|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectReader
BufferedReader
LineNumberReader
EntryReader
public class EntryReader
Class that reads "entries" from a file. In the simplest case, entries can be lines. It supports: include files, comments, and multi-line entries (paragraphs). The syntax of each of these is customizable.
and @see #set_entry_start_stop(String,String)| Nested Class Summary | |
|---|---|
static class |
EntryReader.Entry
Descriptor for an entry (paragraph) |
| Field Summary | |
|---|---|
Pattern |
entry_start_re
Regular expression that starts a long entry (paragraph). |
Pattern |
entry_stop_re
Regular expression that terminates a long entry. |
| Fields inherited from class Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
EntryReader(File file)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(File file,
String charsetName)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(File file,
String comment_re,
String include_re)
Create a EntryReader |
|
EntryReader(InputStream in)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(InputStream in,
String filename)
Create a EntryReader that uses the default character set and does not support comments or include directives. |
|
EntryReader(InputStream in,
String charsetName,
String filename)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(InputStream in,
String filename,
String comment_re_string,
String include_re_string)
Create a EntryReader |
|
EntryReader(InputStream in,
String charsetName,
String filename,
String comment_re_string,
String include_re_string)
|
|
EntryReader(Reader reader)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(Reader reader,
String filename,
String comment_re_string,
String include_re_string)
Create a EntryReader |
|
EntryReader(String filename)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(String filename,
String charsetName)
Create a EntryReader that does not support comments or include directives. |
|
EntryReader(String filename,
String comment_re,
String include_re)
Create a new EntryReader starting with the specified file. |
|
| Method Summary | |
|---|---|
EntryReader.Entry |
get_entry()
Returns the next entry (paragraph) in the file. |
String |
get_filename()
Deprecated. |
long |
get_line_number()
Deprecated. |
String |
getFileName()
Returns the current filename |
int |
getLineNumber()
Return the current line number in the current file. |
boolean |
hasNext()
Returns whether or not there is another line to read. |
Iterator<String> |
iterator()
Returns a line-by-line interator for this file. |
static void |
main(String[] args)
Simple example |
void |
mark(int readAheadLimit)
Mark the present position in the stream. |
String |
next()
Returns the next line in the multi-file. |
void |
putback(String line)
Puts the specified line back in the input. |
int |
read()
Read a single character. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
String |
readLine()
Read a line, ignoring comments and processing includes. |
void |
remove()
remove() is not supported |
void |
reset()
Reset the stream to the most recent mark. |
void |
set_entry_start_stop(Pattern entry_start_re,
Pattern entry_stop_re)
Set the regular expressions for the start and stop of long entries (multiple lins that are read as a group by get_entry()). |
void |
set_entry_start_stop(String entry_start_re,
String entry_stop_re)
Set the regular expressions for the start and stop of long entries (multiple lins that are read as a group by get_entry()). |
void |
setLineNumber(int lineNumber)
Set the current line number in the current file. |
long |
skip(long n)
Skip characters. |
| Methods inherited from class BufferedReader |
|---|
close, markSupported, ready |
| Methods inherited from class Reader |
|---|
read, read |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Pattern entry_start_re
public Pattern entry_stop_re
| Constructor Detail |
|---|
public EntryReader(InputStream in,
String charsetName,
String filename,
String comment_re_string,
String include_re_string)
throws UnsupportedEncodingException
UnsupportedEncodingException
public EntryReader(InputStream in,
String charsetName,
String filename)
throws UnsupportedEncodingException
UnsupportedEncodingExceptionEntryReader(InputStream,String,String,String)
public EntryReader(InputStream in,
String filename,
String comment_re_string,
String include_re_string)
in - Initial sourcefilename - 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 ignoredinclude_re_string - Regular expression that matches include directives.
The expression should define one group that contains
the include file name
public EntryReader(InputStream in,
String filename)
EntryReader(InputStream,String,String,String,String)public EntryReader(InputStream in)
EntryReader(InputStream,String,String,String)
public EntryReader(Reader reader,
String filename,
String comment_re_string,
String include_re_string)
reader - Initial sourcecomment_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(Reader reader)
EntryReader(Reader,String,String,String)
public EntryReader(File file,
String comment_re,
String include_re)
throws IOException
file - Initial file to read.comment_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.
IOException
public EntryReader(File file)
throws IOException
IOExceptionEntryReader(File,String,String)
public EntryReader(File file,
String charsetName)
throws IOException
IOExceptionEntryReader(File,String,String)
public EntryReader(String filename,
String comment_re,
String include_re)
throws IOException
IOExceptionEntryReader(File,String,String)
public EntryReader(String filename)
throws IOException
IOExceptionEntryReader(String,String,String)
public EntryReader(String filename,
String charsetName)
throws IOException
IOExceptionEntryReader(String,String,String)| Method Detail |
|---|
public String readLine()
throws IOException
readLine in class LineNumberReaderIOExceptionpublic Iterator<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 Iterable<String>public boolean hasNext()
hasNext in interface Iterator<String>public String next()
next in interface Iterator<String>public void remove()
remove in interface Iterator<String>
public EntryReader.Entry get_entry()
throws IOException
entry_start_re
(see set_entry_start_stop(java.lang.String, java.lang.String)). If no more entries are
available, returns null.
IOException@Deprecated public String get_filename()
getFileName()public String getFileName()
@Deprecated public long get_line_number()
getLineNumber()public int getLineNumber()
getLineNumber in class LineNumberReaderpublic void setLineNumber(int lineNumber)
setLineNumber in class LineNumberReader
public void set_entry_start_stop(String entry_start_re,
String entry_stop_re)
public void set_entry_start_stop(Pattern entry_start_re,
Pattern entry_stop_re)
public void putback(String line)
public void mark(int readAheadLimit)
mark in class LineNumberReaderpublic int read()
read in class LineNumberReader
public int read(char[] cbuf,
int off,
int len)
read in class LineNumberReaderpublic void reset()
reset in class LineNumberReaderpublic long skip(long n)
skip in class LineNumberReader
public static void main(String[] args)
throws IOException
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||