java.io.PushbackReader to abstract line/offset counting
and push back support.
Note that this class does not leverage java.io.LineNumberReader as we
need to un-roll the line number on push back and we need to have the logic to
deal with newline combinations anyhow.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BUFFER_PADDING
The additional buffer padding--this is to add to the fact that the pushback buffer may have to be larger than user specified characters a CR/LF combo is 2 characters, but logically one newline. |
| public static final int | DEFAULT_BUFFER_SIZE
The default buffer size |
| private int | |
| private LinkedList | m_columns
This offset stack is for pushing back characters that unroll lines and keeps our offset/line number counts correct. |
| private long | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | IonCharacterReader(final Reader
The underlying reader to wrap. in, final int The size of the push back buffer. size)Constructs a character reader with an explicit buffer size. |
| public | IonCharacterReader(final Reader
The underlying reader to wrap. in)Constructs a character reader with the default buffer size. |
| Modifier and Type | Method and Description |
|---|---|
| public final int | Returns: The offset, 1-based.Returns the offset within the line based on the last call to read(). |
| public final long | Returns: The logical number of consumed characters.Returns the logical number of consumed characters. |
| public final int | Returns: The line number, 1-based.Returns the current line number in the stream based on the last call to read(). |
| private final int | |
| private final void | |
| public int | read()
Overrides java. Uses the push back implementation but normalizes newlines to "\n". |
| public int | read(char[]
Destination buffer cbuf, int Offset at which to start storing characters off, int Maximum number of characters to read len)Overrides java. Readers a buffer's worth of data. |
| public long | skip(final long
The number of characters to skip n)Overrides java. Skips over some number of characters. |
| public void | unread(char[]
Character array cbuf, int Offset of first character to push back off, int Number of characters to push back len)Overrides java. Delegates to |
| public void | unread(char[]
Character array to push back cbuf)Overrides java. Delegates to |
| public void | unread(int
The int value representing a character to be pushed back c)Overrides java. Will unread a character and update the line number if necessary. |
| private void | unreadImpl(int
the character to unread. c, boolean Whether or not we actually update the line number. updateCounts)Performs ths actual unread operation. |
| BUFFER_PADDING | back to summary |
|---|---|
| public static final int BUFFER_PADDING The additional buffer padding--this is to add to the fact that the pushback buffer may have to be larger than user specified characters a CR/LF combo is 2 characters, but logically one newline. FIXME does this properly account for surrogates?
| |
| DEFAULT_BUFFER_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_BUFFER_SIZE The default buffer size
| |
| m_column | back to summary |
|---|---|
| private int m_column | |
| m_columns | back to summary |
|---|---|
| private LinkedList<Integer> m_columns This offset stack is for pushing back characters that unroll lines and keeps our offset/line number counts correct. This is essentially a pushback stack for character offsets. | |
| m_consumed | back to summary |
|---|---|
| private long m_consumed | |
| m_line | back to summary |
|---|---|
| private int m_line | |
| m_size | back to summary |
|---|---|
| private int m_size | |
| IonCharacterReader | back to summary |
|---|---|
| public IonCharacterReader(final Reader in, final int size) Constructs a character reader with an explicit buffer size. Note that this is a minimum and the implementation is allowed to make it larger for internal operations.
| |
| IonCharacterReader | back to summary |
|---|---|
| public IonCharacterReader(final Reader in) Constructs a character reader with the default buffer size.
| |
| getColumn | back to summary |
|---|---|
| public final int getColumn() Returns the offset within the line based on the last call to read().
| |
| getConsumedAmount | back to summary |
|---|---|
| public final long getConsumedAmount() Returns the logical number of consumed characters. This does not necessarily equal to the number of actual characters read as newline combinations are treated as one.
| |
| getLineNumber | back to summary |
|---|---|
| public final int getLineNumber() Returns the current line number in the stream based on the last call to read().
| |
| popColumn | back to summary |
|---|---|
| private final int popColumn() throws IOException | |
| pushColumn | back to summary |
|---|---|
| private final void pushColumn(final int offset) | |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides java. Uses the push back implementation but normalizes newlines to "\n".
| |
| read | back to summary |
|---|---|
| public int read(char[] cbuf, int off, int len) throws IOException Overrides java. Readers a buffer's worth of data. This implementation
simply leverages
| |
| skip | back to summary |
|---|---|
| public long skip(final long n) throws IOException Overrides java. Skips over some number of characters.
This is implemented as a series of
| |
| unread | back to summary |
|---|---|
| public void unread(char[] cbuf, int off, int len) throws IOException Overrides java. Delegates to
| |
| unread | back to summary |
|---|---|
| public void unread(char[] cbuf) throws IOException Overrides java. Delegates to
| |
| unread | back to summary |
|---|---|
| public void unread(int c) throws IOException Overrides java. Will unread a character and update the line number if necessary. This will throw an exception if a carriage return is given as this character is never yielded from this stream.
| |
| unreadImpl | back to summary |
|---|---|
| private void unreadImpl(int c, boolean updateCounts) throws IOException Performs ths actual unread operation.
| |