public interface JsonSource extends Closeable
JsonSource represents access to a sequence of characters to be used
used by a JsonPullParser. Characters may be consumed
one by one, or, for convenience,
multiple at a time, or
appended to a
StringBuilder.
Callers must or ensure, that the
desired amount of characters is available, before consuming them.
| Modifier and Type | Field and Description |
|---|---|
static char |
BYTE_ORDER_MARK
A
char that represents the Unicode byte order mark. |
| Modifier and Type | Method and Description |
|---|---|
void |
appendNextString(StringBuilder builder,
int length)
Consumes and appends the next characters in the character sequence to the
given
StringBuilder. |
int |
getAvailable()
Returns the amount of currently available characters.
|
int |
getColumn()
Returns the column that corresponds to the current position of this
JsonSource in the character sequence, as if the character source
was a regular file. |
String |
getFuture(int maximum)
Returns some of the characters havn't been consumed yet, beginning with
the next character to be consumed, if already available, or an empty
String otherwise. |
int |
getLine()
Returns the line that corresponds to the current position of this
JsonSource in the character sequence, as if the character source
was a regular file. |
String |
getPast(int maximum)
Returns some of the characters that already have been consumed, ending
with the last consumed character, if still available, or an empty
String otherwise. |
int |
makeAvailable()
Ensures that characters are available to be consumed, unless the
character sequence has reached its end.
|
boolean |
makeAvailable(int minimum)
Ensures that a given minimum of characters is available to be consumed.
|
char |
nextCharacter()
Consumes and returns the next character in the character sequence.
|
String |
nextString(int length)
Consumes and returns the next characters in the character sequence.
|
char |
peekCharacter(int offset)
Returns a future character in the character sequence, without consuming
it.
|
static final char BYTE_ORDER_MARK
char that represents the Unicode byte order mark. A leading
byte order mark in a character sequence should be ignored by a
JsonSource.int getAvailable()
int makeAvailable()
throws IOException
IOException - If something went wrong while ensuring that the desired
amount of available characters.boolean makeAvailable(int minimum)
throws IOException
minimum - The desired minimum.IOException - If something went wrong while ensuring that the desired
amount of available characters.char nextCharacter()
char peekCharacter(int offset)
Callers must ensure, that the
desired amount of characters is available.
offset - The amount of characters to look ahead. Must be non-negative.String nextString(int length)
Callers must ensure, that the
desired amount of characters is available.
length - The amount of characters to be consumed. Must be non-negative.void appendNextString(StringBuilder builder, int length)
StringBuilder.
Callers must ensure, that the
desired amount of characters is available.
builder - The string builder to add the characters to. Must be
non-negative.length - The amount of characters to be consumed.int getLine()
JsonSource in the character sequence, as if the character source
was a regular file.
The line is equal to the number of consumed \n-characters + 1.
int getColumn()
JsonSource in the character sequence, as if the character source
was a regular file.
The column is equal to the number of consumed characters + 1 in the
current line.
String getPast(int maximum)
String otherwise.maximum - The maximum amount of characters. Must be non-negative.String getFuture(int maximum)
String otherwise.maximum - The maximum amount of characters. Must be non-negative.Copyright © 2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.