Class MockJsonParser
- java.lang.Object
-
- com.google.api.client.json.JsonParser
-
- com.google.api.client.testing.json.MockJsonParser
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
@Beta public class MockJsonParser extends JsonParser
- Since:
- 1.15 (since 1.11 as com.google.api.client.testing.http.json.MockJsonParser)
-
-
Field Summary
Fields Modifier and Type Field Description private JsonFactory
factory
private boolean
isClosed
-
Constructor Summary
Constructors Constructor Description MockJsonParser(JsonFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the parser and the underlying input stream or reader, and releases any memory associated with it.java.math.BigInteger
getBigIntegerValue()
Returns theBigInteger
value of the current token.byte
getByteValue()
Returns the byte value of the current token.java.lang.String
getCurrentName()
Returns the most recent field name ornull
for array values or for root-level values.JsonToken
getCurrentToken()
Returns the token the parser currently points to ornull
for none (at start of input or after end of input).java.math.BigDecimal
getDecimalValue()
Returns theBigDecimal
value of the current token.double
getDoubleValue()
Returns the double value of the current token.JsonFactory
getFactory()
Returns the JSON factory from which this generator was created.float
getFloatValue()
Returns the float value of the current token.int
getIntValue()
Returns the int value of the current token.long
getLongValue()
Returns the long value of the current token.short
getShortValue()
Returns the short value of the current token.java.lang.String
getText()
Returns a textual representation of the current token ornull
ifJsonParser.getCurrentToken()
isnull
.boolean
isClosed()
Returns whetherclose()
was called.JsonToken
nextToken()
Returns the next token from the stream ornull
to indicate end of input.JsonParser
skipChildren()
Skips to the matchingJsonToken.END_ARRAY
if current token isJsonToken.START_ARRAY
, the matchingJsonToken.END_OBJECT
if the current token isJsonToken.START_OBJECT
, else does nothing.-
Methods inherited from class com.google.api.client.json.JsonParser
parse, parse, parse, parse, parse, parse, parseAndClose, parseAndClose, parseAndClose, parseAndClose, parseArray, parseArray, parseArray, parseArray, parseArrayAndClose, parseArrayAndClose, parseArrayAndClose, parseArrayAndClose, skipToKey, skipToKey
-
-
-
-
Field Detail
-
isClosed
private boolean isClosed
-
factory
private final JsonFactory factory
-
-
Constructor Detail
-
MockJsonParser
public MockJsonParser(JsonFactory factory)
-
-
Method Detail
-
getFactory
public JsonFactory getFactory()
Description copied from class:JsonParser
Returns the JSON factory from which this generator was created.- Specified by:
getFactory
in classJsonParser
-
close
public void close() throws java.io.IOException
Description copied from class:JsonParser
Closes the parser and the underlying input stream or reader, and releases any memory associated with it.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classJsonParser
- Throws:
java.io.IOException
-
nextToken
public JsonToken nextToken() throws java.io.IOException
Description copied from class:JsonParser
Returns the next token from the stream ornull
to indicate end of input.- Specified by:
nextToken
in classJsonParser
- Throws:
java.io.IOException
-
getCurrentToken
public JsonToken getCurrentToken()
Description copied from class:JsonParser
Returns the token the parser currently points to ornull
for none (at start of input or after end of input).- Specified by:
getCurrentToken
in classJsonParser
-
getCurrentName
public java.lang.String getCurrentName() throws java.io.IOException
Description copied from class:JsonParser
Returns the most recent field name ornull
for array values or for root-level values.- Specified by:
getCurrentName
in classJsonParser
- Throws:
java.io.IOException
-
skipChildren
public JsonParser skipChildren() throws java.io.IOException
Description copied from class:JsonParser
Skips to the matchingJsonToken.END_ARRAY
if current token isJsonToken.START_ARRAY
, the matchingJsonToken.END_OBJECT
if the current token isJsonToken.START_OBJECT
, else does nothing.- Specified by:
skipChildren
in classJsonParser
- Throws:
java.io.IOException
-
getText
public java.lang.String getText() throws java.io.IOException
Description copied from class:JsonParser
Returns a textual representation of the current token ornull
ifJsonParser.getCurrentToken()
isnull
.- Specified by:
getText
in classJsonParser
- Throws:
java.io.IOException
-
getByteValue
public byte getByteValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the byte value of the current token.- Specified by:
getByteValue
in classJsonParser
- Throws:
java.io.IOException
-
getShortValue
public short getShortValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the short value of the current token.- Specified by:
getShortValue
in classJsonParser
- Throws:
java.io.IOException
-
getIntValue
public int getIntValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the int value of the current token.- Specified by:
getIntValue
in classJsonParser
- Throws:
java.io.IOException
-
getFloatValue
public float getFloatValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the float value of the current token.- Specified by:
getFloatValue
in classJsonParser
- Throws:
java.io.IOException
-
getLongValue
public long getLongValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the long value of the current token.- Specified by:
getLongValue
in classJsonParser
- Throws:
java.io.IOException
-
getDoubleValue
public double getDoubleValue() throws java.io.IOException
Description copied from class:JsonParser
Returns the double value of the current token.- Specified by:
getDoubleValue
in classJsonParser
- Throws:
java.io.IOException
-
getBigIntegerValue
public java.math.BigInteger getBigIntegerValue() throws java.io.IOException
Description copied from class:JsonParser
Returns theBigInteger
value of the current token.- Specified by:
getBigIntegerValue
in classJsonParser
- Throws:
java.io.IOException
-
getDecimalValue
public java.math.BigDecimal getDecimalValue() throws java.io.IOException
Description copied from class:JsonParser
Returns theBigDecimal
value of the current token.- Specified by:
getDecimalValue
in classJsonParser
- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Returns whetherclose()
was called.- Since:
- 1.15
-
-