public final class CharacterArrayJsonSource extends Object implements JsonSource
BYTE_ORDER_MARK| Constructor and Description |
|---|
CharacterArrayJsonSource(char[] characters)
Creates a new
CharacterArrayJsonSource for the given
String. |
| 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. |
void |
close() |
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.
|
public CharacterArrayJsonSource(char[] characters)
throws IllegalArgumentException
CharacterArrayJsonSource for the given
String.characters - The char[] to be used.IllegalArgumentException - If the given String is null.public int getAvailable()
JsonSourcegetAvailable in interface JsonSourcepublic int makeAvailable()
throws IOException
JsonSourcemakeAvailable in interface JsonSourceIOException - If something went wrong while ensuring that the desired
amount of available characters.public boolean makeAvailable(int minimum)
throws IOException
JsonSourcemakeAvailable in interface JsonSourceminimum - The desired minimum.IOException - If something went wrong while ensuring that the desired
amount of available characters.public char nextCharacter()
JsonSourcenextCharacter in interface JsonSourcepublic char peekCharacter(int offset)
JsonSource
Callers must ensure, that the
desired amount of characters is available.
peekCharacter in interface JsonSourceoffset - The amount of characters to look ahead. Must be non-negative.public String nextString(int length)
JsonSource
Callers must ensure, that the
desired amount of characters is available.
nextString in interface JsonSourcelength - The amount of characters to be consumed. Must be non-negative.public void appendNextString(StringBuilder builder, int length)
JsonSourceStringBuilder.
Callers must ensure, that the
desired amount of characters is available.
appendNextString in interface JsonSourcebuilder - The string builder to add the characters to. Must be
non-negative.length - The amount of characters to be consumed.public String getPast(int maximum)
JsonSourceString otherwise.getPast in interface JsonSourcemaximum - The maximum amount of characters. Must be non-negative.public String getFuture(int maximum)
JsonSourceString otherwise.getFuture in interface JsonSourcemaximum - The maximum amount of characters. Must be non-negative.public int getLine()
JsonSourceJsonSource 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.
getLine in interface JsonSourcepublic int getColumn()
JsonSourceJsonSource 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.
getColumn in interface JsonSourcepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.