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 of CharacterInput based on an array of characters.
  • Constructor Details

    • 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 input
      offset - 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: AbstractInput
      Tries to parse the next character without taking care of the peek deque.
      Specified by:
      directRead in class AbstractInput
      Returns:
      the next character, or -1 if the EOS has been reached
    • directReadChar

      protected char directReadChar() throws ParsingException
      Description copied from class: AbstractInput
      Tries to parse the next character without taking care of the peek deque.
      Specified by:
      directReadChar in class AbstractInput
      Returns:
      the next character
      Throws:
      ParsingException - if the EOS has been reached
    • read

      public CharsWrapper read(int n)
      Description copied from interface: CharacterInput
      Reads 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: CharacterInput
      Reads 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