Class JSUtilities.YAML.Parser

java.lang.Object
org.bzdev.util.JSUtilities.JSON.Parser
org.bzdev.util.JSUtilities.YAML.Parser
Enclosing class:
JSUtilities.YAML

public static class JSUtilities.YAML.Parser extends JSUtilities.JSON.Parser
Parser support class for YAML. This class is used by the static methods in the class JSUtilities.YAML. These static methods create a suitable Reader when necessary, pass that to the constructor for JSUtilities.YAML.Parser, and then call the method getResults() to obtain the results.

For YAML streams representing multiple objects, the constructor is used as described above. The method getResults() can be called as many times as needed, while the method hasNext() can be called to determine if there is another object available.

  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Determine if getResults() can be called again to obtain another object. This method is part of the implementation and is only used internally.
      Returns:
      true if there are more values; false otherwise
    • getResults

      public Object getResults() throws IOException
      Get the object generated by a parser. If the parser was created with a tag specification, additional types may be returned.
      Overrides:
      getResults in class JSUtilities.JSON.Parser
      Returns:
      the object (a Boolean, Integer, Long, Double, JSArray, JSObject, or the value null)
      Throws:
      IOException - if an IO error occurred
      See Also:
    • parseValue

      protected Object parseValue() throws IOException
      Description copied from class: JSUtilities.JSON.Parser
      Parse a JSON value. This method is part of the implementation and is only used internally.
      Overrides:
      parseValue in class JSUtilities.JSON.Parser
      Returns:
      a parsed object
      Throws:
      IOException - an error occurred
    • parseValue

      protected Object parseValue(int prevIndent, int nextIndent) throws IOException
      Parse the input from the current character. For characters to be used, their indentation must be larger than that provided by prevIndent. When a line's first character's indentation is less than or equal to the prevIndent argument, that character is not used in the results returned by this method and is instead left to the caller to handle. The nextIndent argument is the value to use as the prevIndent value in a recursive call.

      This method is part of the implementation and is only used internally.

      Parameters:
      prevIndent - the previous line indentation
      nextIndent - the next line indentation
      Returns:
      the object created by parsing
      Throws:
      IOException - if an IO error occurred
    • parseString

      protected String parseString(boolean isIdent) throws IOException
      Parse a string. This method is part of the implementation and is only used internally.
      Overrides:
      parseString in class JSUtilities.JSON.Parser
      Parameters:
      isIdent - true if the string is an identifier without double quotes; false otherwise
      Returns:
      the string throws IOException an error occurred, typically due to the input stream being read
      Throws:
      IOException - an error occurred
    • parseString1

      protected String parseString1() throws IOException
      Parse a string whose delimiters are single quotes. This method is part of the implementation and is only used internally.
      Returns:
      the string
      Throws:
      IOException - an error occurred, typically due to the input stream being read