Class JsonTokenizer
java.lang.Object
com.aquima.interactions.foundation.json.reader.JsonTokenizer
Simple class to read Json (JavaScript Object Notation) via a tokenizer interface.
- Since:
- 7.0
- Author:
- J. Gorter, Jon van Leuven
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if an array is ended at the current position.boolean
Return true if an array is started at the current position.boolean
Return true if a boolean at the current position.boolean
isComma()
Return true if a comma at the current position.boolean
isNull()
Return true if a null value at the current position.boolean
isNumber()
Return true if a number at the current position.boolean
Return true if an object ends at the current position.boolean
Return true if an object starts at the current position.boolean
isString()
Return true if a string start (or ends) at the current position.void
The method reads an array end.void
The method reads an array start.boolean
The method reads a boolean.void
The method reads a colon (:).void
The method reads a comma.void
readNull()
The method reads a null value.The method reads a number.void
The method reads an object end character '}'.void
The method reads an object start character '{'.The method reads a string.The method reads a value.void
This methods skips json members with their values.void
This methods skips a json object.void
This methods skips a json value.
-
Constructor Details
-
JsonTokenizer
-
-
Method Details
-
skipValue
public void skipValue()This methods skips a json value.- Throws:
InvalidStateException
- When an unexpected character is read.
-
skipObject
public void skipObject()This methods skips a json object.- Throws:
InvalidStateException
- When an unexpected character is read.
-
skipMembers
public void skipMembers()This methods skips json members with their values.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isObjectStart
public boolean isObjectStart()Return true if an object starts at the current position.- Returns:
- True if an object starts.
- Throws:
InvalidStateException
- When no character could be read.
-
readObjectStart
public void readObjectStart()The method reads an object start character '{'.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isObjectEnd
public boolean isObjectEnd()Return true if an object ends at the current position.- Returns:
- True if an object ends.
- Throws:
InvalidStateException
- When no character could be read.
-
readObjectEnd
public void readObjectEnd()The method reads an object end character '}'.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isString
public boolean isString()Return true if a string start (or ends) at the current position.- Returns:
- True if current position contains a string start (or end).
- Throws:
InvalidStateException
- When no character could be read.
-
readString
The method reads a string.- Returns:
- the read string.
- Throws:
InvalidStateException
- When an unexpected character is read.
-
isBoolean
public boolean isBoolean()Return true if a boolean at the current position.- Returns:
- True if current position contains a boolean.
- Throws:
InvalidStateException
- When no character could be read.
-
readBoolean
public boolean readBoolean()The method reads a boolean.- Returns:
- the read boolean.
- Throws:
InvalidStateException
- When an unexpected character is read.
-
isNull
public boolean isNull()Return true if a null value at the current position.- Returns:
- True if current position contains a null value.
- Throws:
InvalidStateException
- When no character could be read.
-
readNull
public void readNull()The method reads a null value.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isNumber
public boolean isNumber()Return true if a number at the current position.- Returns:
- True if current position contains a number.
- Throws:
InvalidStateException
- When no character could be read.
-
readNumber
The method reads a number.Possible return objects:
- Long
- Double
- Returns:
- the read number.
- Throws:
InvalidStateException
- When an unexpected character is read.
-
readColon
public void readColon()The method reads a colon (:).- Throws:
InvalidStateException
- When an unexpected character is read.
-
readValue
The method reads a value.
Possible return objects:
- String
- Long
- Double
- Boolean
- Array of String
- Returns:
- the read object, may be null.
- Throws:
InvalidStateException
- When an unexpected character is read.
-
isComma
public boolean isComma()Return true if a comma at the current position.- Returns:
- True if current position contains a comma.
- Throws:
InvalidStateException
- When no character could be read.
-
readComma
public void readComma()The method reads a comma.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isArrayStart
public boolean isArrayStart()Return true if an array is started at the current position.- Returns:
- True if current position contains an array start character.
- Throws:
InvalidStateException
- When no character could be read.
-
readArrayStart
public void readArrayStart()The method reads an array start.- Throws:
InvalidStateException
- When an unexpected character is read.
-
isArrayEnd
public boolean isArrayEnd()Return true if an array is ended at the current position.- Returns:
- True if current position contains an array end character.
- Throws:
InvalidStateException
- When no character could be read.
-
readArrayEnd
public void readArrayEnd()The method reads an array end.- Throws:
InvalidStateException
- When an unexpected character is read.
-