Class ArrayInput
- java.lang.Object
-
- com.electronwill.nightconfig.core.io.AbstractInput
-
- com.electronwill.nightconfig.core.io.ArrayInput
-
- All Implemented Interfaces:
CharacterInput
public final class ArrayInput extends AbstractInput
An implementation ofCharacterInputbased on an array of characters.
-
-
Field Summary
-
Fields inherited from class com.electronwill.nightconfig.core.io.AbstractInput
deque
-
-
Constructor Summary
Constructors Constructor Description ArrayInput(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intdirectRead()Tries to parse the next character without taking care of the peek deque.protected chardirectReadChar()Tries to parse the next character without taking care of the peek deque.CharsWrapperread(int n)Reads the next n characters, if possible.CharsWrapperreadChars(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, skipPeeks
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.electronwill.nightconfig.core.io.CharacterInput
readAndSkip, readCharAndSkip
-
-
-
-
Constructor Detail
-
ArrayInput
public ArrayInput(CharsWrapper chars)
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 Detail
-
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
protected char directReadChar() throws ParsingExceptionDescription 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
public CharsWrapper read(int n)
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
public CharsWrapper readChars(int n)
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
-
-