Class ArrayInput
java.lang.Object
com.electronwill.nightconfig.core.io.AbstractInput
com.electronwill.nightconfig.core.io.ArrayInput
- All Implemented Interfaces:
CharacterInput
An implementation of
CharacterInput based on an array of characters.-
Field Summary
Fields inherited from class com.electronwill.nightconfig.core.io.AbstractInput
deque -
Constructor Summary
ConstructorsConstructorDescriptionArrayInput(char[] chars) Creates a new ArrayInput based on the specified array.ArrayInput(char[] chars, int offset, int limit) Creates a new ArrayInput based on the specified array.ArrayInput(CharsWrapper chars) Creates a new ArrayInput based on the underlying array of the specified CharsWrapper. -
Method Summary
Modifier and TypeMethodDescriptionprotected intTries to parse the next character without taking care of the peek deque.protected charTries to parse the next character without taking care of the peek deque.read(int n) Reads the next n characters, if possible.readChars(int n) Reads the next n characters.Methods inherited from class com.electronwill.nightconfig.core.io.AbstractInput
consumeDeque, peek, peek, peekChar, peekChar, pushBack, read, readChar, readCharsUntil, readUntil, skipPeeksMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.electronwill.nightconfig.core.io.CharacterInput
readAndSkip, readCharAndSkip
-
Constructor Details
-
ArrayInput
Creates a new ArrayInput based on the underlying array of the specified CharsWrapper. Any modification to the wrapper is reflected in the input.- Parameters:
chars- the CharsWrapper to use as an input
-
ArrayInput
public ArrayInput(char[] chars) Creates a new ArrayInput based on the specified array. Any modification to the array is reflected in the input.- Parameters:
chars- the char array to use as an input
-
ArrayInput
public ArrayInput(char[] chars, int offset, int limit) Creates a new ArrayInput based on the specified array. Any modification to the array is reflected in the input.- Parameters:
chars- the char array to use as an inputoffset- the index to begin at (inclusive index)limit- the limit to stop at (exclusive index)
-
-
Method Details
-
directRead
protected int directRead()Description copied from class:AbstractInputTries to parse the next character without taking care of the peek deque.- Specified by:
directReadin classAbstractInput- Returns:
- the next character, or -1 if the EOS has been reached
-
directReadChar
Description copied from class:AbstractInputTries to parse the next character without taking care of the peek deque.- Specified by:
directReadCharin classAbstractInput- Returns:
- the next character
- Throws:
ParsingException- if the EOS has been reached
-
read
Description copied from interface:CharacterInputReads the next n characters, if possible. If there are less than n available characters, return all the remaining characters.- Parameters:
n- the number of characters to parse- Returns:
- an array containing at most n characters, not null
-
readChars
Description copied from interface:CharacterInputReads the next n characters. If there isn't n available characters, this method throws an exception.- Parameters:
n- the number of characters to parse- Returns:
- an array containing the next n characters, not null
-