Package org.plumelib.util
Class EntryReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
java.io.LineNumberReader
org.plumelib.util.EntryReader
Class that reads records or "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.
Here are example uses. The first reads by lines and the second reads by entries.
// EntryReader constructor args are: filename, EntryFormat, CommentFormat, include regex.
// First argument can also be a File or Path; additional constructors also exist.
try (EntryReader er = new EntryReader(filename,
EntryFormat.DEFAULT, CommentFormat.TEX, "\\\\include\\{(.*)\\}")) {
for (String line : er) {
...
}
} catch (IOException e) {
System.err.println("Problem reading " + filename + ": " + e.getMessage());
}
try (EntryReader er = new EntryReader(filename,
EntryFormat.TWO_BLANK_LINES_AND_FENCED_CODE_BLOCKS,
CommentFormat.HTML,
null)) {
for (EntryReader.Entry entry = er.getEntry(); entry != null; entry = er.getEntry()) {
...
}
} catch (IOException e) {
System.err.println("Problem reading " + filename + ": " + e.getMessage());
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class informsEntryReaderwhere a comment begins and ends.static classDescriptor for an entry (record, paragraph, etc.).static classThis class informsEntryReaderwhere an entry begins and ends. -
Field Summary
FieldsModifier and TypeFieldDescriptionSpecifies the syntax of comments (if comments are supported).booleanIf true, output diagnostics.final EntryReader.EntryFormatSpecifies how an entry begins and ends. -
Constructor Summary
ConstructorsConstructorDescriptionEntryReader(@MustCallAlias InputStream in) Create an EntryReader that does not support comments or include directives.EntryReader(@MustCallAlias InputStream in, String filename) Create an EntryReader that uses the default character set and does not support comments or include directives.EntryReader(@MustCallAlias InputStream in, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias InputStream in, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias InputStream in, String charsetName, String filename) Deprecated.EntryReader(@MustCallAlias InputStream in, String charsetName, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias InputStream in, String charsetName, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias InputStream in, String charsetName, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) EntryReader(@MustCallAlias InputStream in, String charsetName, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) Create an EntryReader that uses the given character set.EntryReader(@MustCallAlias InputStream in, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias InputStream in, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) Create an EntryReader.EntryReader(@MustCallAlias Reader reader) Create an EntryReader that does not support comments or include directives.EntryReader(@MustCallAlias Reader reader, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias Reader reader, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias Reader reader, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.EntryReader(@MustCallAlias Reader reader, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) Create an EntryReader.EntryReader(File file) Create an EntryReader that does not support comments or include directives.EntryReader(File file, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(File file, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(File file, String charsetName) Deprecated.EntryReader(File file, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(File file, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) Create an EntryReader.EntryReader(String filename) Create an EntryReader that does not support comments or include directives.EntryReader(String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(String filename, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(String filename, String charsetName) Deprecated.EntryReader(String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) Create a new EntryReader starting with the specified file.EntryReader(Path path) Create an EntryReader that does not support comments or include directives.EntryReader(Path path, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(Path path, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(Path path, String charsetName) Deprecated.EntryReader(Path path, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) Deprecated.EntryReader(Path path, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) Create an EntryReader. -
Method Summary
Modifier and TypeMethodDescription@Nullable EntryReader.EntrygetEntry()Returns the next entry (paragraph) in the file.Returns the current filename.@org.checkerframework.checker.index.qual.NonNegative intReturns the current line number in the current file.booleanhasNext()Returns true if there is another line to read.iterator()Returns a line-by-line iterator for this file.static voidSimple usage example.voidmark(int readAheadLimit) next()Returns the next line in the multi-file.voidPuts the specified line back in the input.@org.checkerframework.checker.index.qual.GTENegativeOne intread()@org.checkerframework.checker.index.qual.IndexOrLow({"#1"}) intread(char[] cbuf, int off, int len) @Nullable StringreadLine()Read a line, ignoring comments and processing includes.voidremove()remove() is not supported.voidreset()voidsetDebug(boolean debug) Set debugging on or off.voidsetLineNumber(@org.checkerframework.checker.index.qual.NonNegative int lineNumber) Set the current line number in the current file.@org.checkerframework.checker.index.qual.NonNegative longskip(long n) Methods inherited from class java.io.BufferedReader
close, lines, markSupported, readyMethods inherited from class java.io.Reader
nullReader, read, read, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
entryFormat
Specifies how an entry begins and ends. -
commentFormat
Specifies the syntax of comments (if comments are supported). -
debug
public boolean debugIf true, output diagnostics.
-
-
Constructor Details
-
EntryReader
@MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String charsetName, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) throws UnsupportedEncodingException Create an EntryReader that uses the given character set.- Parameters:
in- source from which to read entriescharsetName- the character set to usefilename- non-null file name for stream being readentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
UnsupportedEncodingException- if the charset encoding is not supported
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String charsetName, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) throws UnsupportedEncodingException Create an EntryReader that uses the given character set.- Parameters:
in- source from which to read entriescharsetName- the character set to usefilename- non-null file name for stream being readentryFormat- indicates how entries begin and endlineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
UnsupportedEncodingException- if the charset encoding is not supported
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String charsetName, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) throws UnsupportedEncodingException Deprecated.Create an EntryReader that uses the given character set.- Parameters:
in- source from which to read entriescharsetName- the character set to usefilename- non-null file name for stream being readtwoBlankLines- true if entries are separated by two blank lines rather than onelineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
UnsupportedEncodingException- if the charset encoding is not supported- See Also:
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String charsetName, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) throws UnsupportedEncodingException Deprecated.Create an EntryReader that uses the given character set.- Parameters:
in- source from which to read entriescharsetName- the character set to usefilename- non-null file name for stream being readlineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
UnsupportedEncodingException- if the charset encoding is not supported- See Also:
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String charsetName, String filename) throws UnsupportedEncodingException Deprecated.Create an EntryReader that does not support comments or include directives.- Parameters:
in- the InputStreamcharsetName- the character set to usefilename- the file name- Throws:
UnsupportedEncodingException- if the charset encoding is not supported- See Also:
-
EntryReader
@MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) Create an EntryReader.- Parameters:
in- source from which to read entriesfilename- non-null file name for stream being readentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.Create an EntryReader.- Parameters:
in- source from which to read entriesfilename- non-null file name for stream being readentryFormat- indicates how entries begin and endlineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.useEntryReader(InputStream,String,String,EntryFormat,String,String), passingUTF_8as the charsetCreate an EntryReader.- Parameters:
in- source from which to read entriesfilename- non-null file name for stream being readtwoBlankLines- true if entries are separated by two blank lines rather than onelineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias InputStream in, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.Create an EntryReader.- Parameters:
in- source from which to read entriesfilename- non-null file name for stream being readlineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name.
-
EntryReader
Create an EntryReader that uses the default character set and does not support comments or include directives.- Parameters:
in- the InputStreamfilename- the file name- See Also:
-
EntryReader
Create an EntryReader that does not support comments or include directives.- Parameters:
in- the InputStream- See Also:
-
EntryReader
@MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias Reader reader, String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegexString) Create an EntryReader.- Parameters:
reader- source from which to read entriesfilename- file name corresponding to reader, for use in error messagesentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias Reader reader, String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.Create an EntryReader.- Parameters:
reader- source from which to read entriesfilename- file name corresponding to reader, for use in error messagesentryFormat- indicates how entries begin and endlineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignoredincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias Reader reader, String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.Create an EntryReader.- Parameters:
reader- source from which to read entriesfilename- file name corresponding to reader, for use in error messagestwoBlankLines- if true, then entries are separated by two blank lines rather than onelineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignoredincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name
-
EntryReader
@Deprecated @MustCallAlias public EntryReader(@MustCallAlias @MustCallAlias Reader reader, String filename, @Nullable @Regex String lineCommentRegexString, @Nullable @Regex(1) String includeRegexString) Deprecated.Create an EntryReader.- Parameters:
reader- source from which to read entriesfilename- file name corresponding to reader, for use in error messageslineCommentRegexString- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignoredincludeRegexString- regular expression that matches include directives. The expression should define one group that contains the include file name
-
EntryReader
Create an EntryReader that does not support comments or include directives.- Parameters:
reader- source from which to read entries- See Also:
-
EntryReader
public EntryReader(Path path, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) throws IOException Create an EntryReader.- Parameters:
path- initial file to readentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(Path path, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
path- initial file to readentryFormat- indicates how entries begin and endlineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(Path path, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
path- initial file to readtwoBlankLines- if true, then entries are separated by two blank lines rather than onelineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(Path path, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
path- initial file to readlineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
Create an EntryReader that does not support comments or include directives.- Parameters:
path- the file to read- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
Deprecated.Create an EntryReader that does not support comments or include directives.- Parameters:
path- the file to readcharsetName- the character set to use- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
public EntryReader(File file, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) throws IOException Create an EntryReader.- Parameters:
file- initial file to readentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(File file, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
file- initial file to readentryFormat- indicates how entries begin and endlineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(File file, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
file- initial file to readtwoBlankLines- if true, then entries are separated by two blank lines rather than onelineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
@Deprecated public EntryReader(File file, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create an EntryReader.- Parameters:
file- initial file to readlineCommentRegex- regular expression that matches comments. Any text that matches lineCommentRegex is removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file
-
EntryReader
Create an EntryReader that does not support comments or include directives.- Parameters:
file- the file to read- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
Deprecated.Create an EntryReader that does not support comments or include directives.- Parameters:
file- the file to readcharsetName- the character set to use- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
public EntryReader(String filename, EntryReader.EntryFormat entryFormat, EntryReader.CommentFormat commentFormat, @Nullable @Regex(1) String includeRegex) throws IOException Create a new EntryReader starting with the specified file.- Parameters:
filename- initial file to readentryFormat- indicates how entries begin and endcommentFormat- indicates the syntax of commentsincludeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
@Deprecated public EntryReader(String filename, EntryReader.EntryFormat entryFormat, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create a new EntryReader starting with the specified file.- Parameters:
filename- initial file to readentryFormat- indicates how entries begin and endlineCommentRegex- regular expression that matches comments. Any text that matcheslineCommentRegexis removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
@Deprecated public EntryReader(String filename, boolean twoBlankLines, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create a new EntryReader starting with the specified file.- Parameters:
filename- initial file to readtwoBlankLines- if true, then entries are separated by two blank lines rather than onelineCommentRegex- regular expression that matches comments. Any text that matcheslineCommentRegexis removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
@Deprecated public EntryReader(String filename, @Nullable @Regex String lineCommentRegex, @Nullable @Regex(1) String includeRegex) throws IOException Deprecated.Create a new EntryReader starting with the specified file.- Parameters:
filename- initial file to readlineCommentRegex- regular expression that matches comments. Any text that matcheslineCommentRegexis removed. A line that is entirely a comment is ignored.includeRegex- regular expression that matches include directives. The expression should define one group that contains the include file name.- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
Create an EntryReader that does not support comments or include directives.- Parameters:
filename- source from which to read entries- Throws:
IOException- if there is a problem reading the file- See Also:
-
EntryReader
Deprecated.Create an EntryReader that does not support comments or include directives.- Parameters:
filename- source from which to read entriescharsetName- the character set to use- Throws:
IOException- if there is a problem reading the file- See Also:
-
-
Method Details
-
getFileName
Returns the current filename.- Returns:
- the current filename
-
getLineNumber
public @org.checkerframework.checker.index.qual.NonNegative int getLineNumber(@GuardSatisfied EntryReader this) Returns the current line number in the current file.- Overrides:
getLineNumberin classLineNumberReader- Returns:
- the current line number
-
setLineNumber
public void setLineNumber(@GuardSatisfied EntryReader this, @org.checkerframework.checker.index.qual.NonNegative int lineNumber) Set the current line number in the current file.- Overrides:
setLineNumberin classLineNumberReader- Parameters:
lineNumber- new line number for the current file
-
setDebug
public void setDebug(boolean debug) Set debugging on or off.- Parameters:
debug- true if debugging is on
-
readLine
Read a line, ignoring comments and processing includes. Returns null at end of file.A line that is completely a comment is ignored (and not returned as a blank line).
- Overrides:
readLinein classLineNumberReader- Returns:
- the string that was read, not including any line termination characters, or null at end of file
- Throws:
IOException
-
iterator
Returns a line-by-line iterator for this file.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.
-
hasNext
public boolean hasNext(@GuardSatisfied EntryReader this) Returns true if there is another line to read. Any IOExceptions are turned into errors (because the definition of hasNext() in Iterator doesn't throw any exceptions). -
next
Returns the next line in the multi-file.- Specified by:
nextin interfaceIterator<String>- Returns:
- the next line in the multi-file
- Throws:
NoSuchElementException- at end of file
-
remove
public void remove(@GuardSatisfied EntryReader this) remove() is not supported. -
getEntry
Returns the next entry (paragraph) in the file. If no more entries are available, returns null.Entries are separated by one or two blank lines (two, if
EntryReader.EntryFormat.twoBlankLinesis true), unless the entry started withEntryReader.EntryFormat.entryStartRegex.- Returns:
- the next entry (paragraph) in the file
- Throws:
IOException- if there is a problem reading the file
-
putback
Puts the specified line back in the input. Only one line can be put back.- Parameters:
line- the line to be put back in the input
-
mark
public void mark(@GuardSatisfied EntryReader this, int readAheadLimit) - Overrides:
markin classLineNumberReader
-
read
public @org.checkerframework.checker.index.qual.GTENegativeOne int read(@GuardSatisfied EntryReader this) - Overrides:
readin classLineNumberReader
-
read
public @org.checkerframework.checker.index.qual.IndexOrLow({"#1"}) int read(@GuardSatisfied EntryReader this, char[] cbuf, int off, int len) - Overrides:
readin classLineNumberReader
-
reset
public void reset(@GuardSatisfied EntryReader this) - Overrides:
resetin classLineNumberReader
-
skip
public @org.checkerframework.checker.index.qual.NonNegative long skip(@GuardSatisfied EntryReader this, long n) - Overrides:
skipin classLineNumberReader
-
main
Simple usage example.- Parameters:
args- command-line arguments: filename [lineCommentStartRegex [includeRegex]]- Throws:
IOException- if there is a problem reading a file
-
EntryReader(InputStream,String,String,EntryFormat,String,String), passingUTF_8as the charset