Class PageReader
java.lang.Object
java.io.Reader
fc.web.page.PageReader
- All Implemented Interfaces:
Closeable, AutoCloseable, Readable
A Reader suitable for lexing. Supports all of: 1 4m 31337 h4x0r! ph33r |\/|y m4d sk1llz !!11! :-]
peek,
read and unread. (no JDK 1.5 reader class has
all of those). Mark/reset is not supported because it's too complex to
implement given the current fixed-buffer implementation of this
class. (on the flip-side this implementation does allow to read
very large files without risk of running out of JDK memory).
Note 1: If this class is invoked from the command line, setting the dbg
flag in the code to true is useful.
-
Constructor Summary
ConstructorsConstructorDescriptionPageReader(File file) Creates a reader using the UTF-8 encoding.PageReader(File file, String encoding) Creates a reader with the specified non-null encoding.PageReader(Reader r) Creates a new PageReader wrapping the specified reader -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetCol()intgetLine()voidinsertIntoStream(File file) Useful for inserting included files into the stream and then parsing that content in-line with the rest of the file.voidUseful for inserting included files into the stream and then parsing that content in-line with the rest of the file.static voidbooleanbooleanmatch(int target) Tries to read/consumes the specified char and returns true if successful.booleanTries to read/consumes the specified non-null string and returns true if successful.booleanmatchIgnoreCase(String target) intpeek()intread()intread(char[] buf, int start, int len) voidSkips all whitespace characters such that the nextread()will return the next non-whitespace character (or EOF if there are no more characters).voidunread()Unreads the current character (which could be EOF) so that the next read will return the current character (or EOF) again.voidunread(int count) Unreads the specified number of charactersMethods inherited from class Reader
mark, nullReader, of, read, read, readAllAsString, readAllLines, ready, reset, skip, transferTo
-
Constructor Details
-
PageReader
Creates a new PageReader wrapping the specified reader- Throws:
IOException
-
PageReader
Creates a reader with the specified non-null encoding.- Throws:
IOException
-
PageReader
Creates a reader using the UTF-8 encoding.- Throws:
IOException
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-
unread
Unreads the current character (which could be EOF) so that the next read will return the current character (or EOF) again.- Throws:
IOException
-
unread
Unreads the specified number of characters- Throws:
IOException
-
insertIntoStream
Useful for inserting included files into the stream and then parsing that content in-line with the rest of the file.- Throws:
IOException
-
insertIntoStream
Useful for inserting included files into the stream and then parsing that content in-line with the rest of the file.- Throws:
IOException
-
peek
- Throws:
IOException
-
skipWhitespace
Skips all whitespace characters such that the nextread()will return the next non-whitespace character (or EOF if there are no more characters).- Throws:
IOException
-
match
Tries to read/consumes the specified char and returns true if successful. If the specified char is not found, does not consume anything and returns false.- Throws:
IOException
-
match
Tries to read/consumes the specified non-null string and returns true if successful. If the specified string is not found, does not consume anything and returns false.- Throws:
IOException
-
matchIgnoreCase
- Throws:
IOException
-
markSupported
- Overrides:
markSupportedin classReader
-
getLine
-
getCol
-
main
- Throws:
IOException
-