java.lang.Object
org.bzdev.util.JSUtilities.JSON.Parser
org.bzdev.util.JSUtilities.YAML.Parser
- Enclosing class:
- JSUtilities.YAML
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.util.JSUtilities.JSON.Parser
JSUtilities.JSON.Parser.CommentMode
-
Field Summary
Fields inherited from class org.bzdev.util.JSUtilities.JSON.Parser
column, lineno, locator
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Parser
(Reader r, JSUtilities.YAML.TagSpec... yamlTags) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the object generated by a parser.boolean
hasNext()
Determine ifgetResults()
can be called again to obtain another object.protected String
parseString
(boolean isIdent) Parse a string.protected String
Parse a string whose delimiters are single quotes.protected Object
Parse a JSON value.protected Object
parseValue
(int prevIndent, int nextIndent) Parse the input from the current character.Methods inherited from class org.bzdev.util.JSUtilities.JSON.Parser
getColumn, getLineIndentation, getLocationMap, hasComment, nextChar, parseArray, parseNumber, parseObject, parseString, parseValue, parseValueJS, pushChar, pushString, readLine, setColumn, setCommentMode, skipWhitespace, skipWhitespace1, stripComment, tagLocation
-
Constructor Details
-
Parser
Constructor.- Parameters:
r
- a reader.- Throws:
IOException
- if an IO error occurred
-
Parser
Constructor.- Parameters:
r
- a reader.yamlTags
- YAML tag specifications- Throws:
IOException
- if an IO error occurred
-
-
Method Details
-
hasNext
public boolean hasNext()Determine ifgetResults()
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
Get the object generated by a parser. If the parser was created with a tag specification, additional types may be returned.- Overrides:
getResults
in classJSUtilities.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
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 classJSUtilities.JSON.Parser
- Returns:
- a parsed object
- Throws:
IOException
- an error occurred
-
parseValue
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 indentationnextIndent
- the next line indentation- Returns:
- the object created by parsing
- Throws:
IOException
- if an IO error occurred
-
parseString
Parse a string. This method is part of the implementation and is only used internally.- Overrides:
parseString
in classJSUtilities.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
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
-