public class JsonParserImpl extends java.lang.Object implements JsonParser
JsonParser.Event| Constructor and Description |
|---|
JsonParserImpl(java.io.InputStream in,
BufferPool bufferPool) |
JsonParserImpl(java.io.InputStream in,
java.nio.charset.Charset encoding,
BufferPool bufferPool) |
JsonParserImpl(java.io.Reader reader,
BufferPool bufferPool) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this parser and frees any resources associated with the
parser.
|
java.math.BigDecimal |
getBigDecimal()
Returns a JSON number as a
BigDecimal. |
int |
getInt()
Returns a JSON number as an integer.
|
JsonLocation |
getLastCharLocation() |
JsonLocation |
getLocation()
Return the location that corresponds to the parser's current state in
the JSON input source.
|
long |
getLong()
Returns a JSON number as a long.
|
java.lang.String |
getString()
Returns a
String for the name in a name/value pair,
for a string value or a number value. |
boolean |
hasNext()
Returns
true if there are more parsing states. |
boolean |
isIntegralNumber()
Returns true if the JSON number at the current parser state is a
integral number.
|
JsonParser.Event |
next()
Returns the event for the next parsing state.
|
public JsonParserImpl(java.io.Reader reader,
BufferPool bufferPool)
public JsonParserImpl(java.io.InputStream in,
BufferPool bufferPool)
public JsonParserImpl(java.io.InputStream in,
java.nio.charset.Charset encoding,
BufferPool bufferPool)
public java.lang.String getString()
JsonParserString for the name in a name/value pair,
for a string value or a number value. This method should only be called
when the parser state is JsonParser.Event.KEY_NAME, JsonParser.Event.VALUE_STRING,
or JsonParser.Event.VALUE_NUMBER.getString in interface JsonParserJsonParser.Event.KEY_NAME
a string value when the parser state is JsonParser.Event.VALUE_STRING
a number value when the parser state is JsonParser.Event.VALUE_NUMBERpublic boolean isIntegralNumber()
JsonParserBigDecimal may be used to store the value
internally and this method semantics are defined using its
scale(). If the scale is zero, then it is considered integral
type. This integral type information can be used to invoke an
appropriate accessor method to obtain a numeric value as in the
following example:
JsonParser parser = ...
if (parser.isIntegralNumber()) {
parser.getInt(); // or other methods to get integral value
} else {
parser.getBigDecimal();
}
isIntegralNumber in interface JsonParserpublic int getInt()
JsonParsernew BigDecimal(getString()).intValue(). Note that
this conversion can lose information about the overall magnitude
and precision of the number value as well as return a result with
the opposite sign. This method should only be called when the parser
state is JsonParser.Event.VALUE_NUMBER.getInt in interface JsonParserBigDecimal.intValue()public long getLong()
JsonParsernew BigDecimal(getString()).longValue(). Note that this
conversion can lose information about the overall magnitude and
precision of the number value as well as return a result with
the opposite sign. This method is only called when the parser state is
JsonParser.Event.VALUE_NUMBER.getLong in interface JsonParserBigDecimal.longValue()public java.math.BigDecimal getBigDecimal()
JsonParserBigDecimal. The BigDecimal
is created using new BigDecimal(getString()). This
method should only called when the parser state is
JsonParser.Event.VALUE_NUMBER.getBigDecimal in interface JsonParserBigDecimal for a JSON numberpublic JsonLocation getLocation()
JsonParsergetLocation in interface JsonParserpublic JsonLocation getLastCharLocation()
public boolean hasNext()
JsonParsertrue if there are more parsing states. This method returns
false if the parser reaches the end of the JSON text.hasNext in interface JsonParsertrue if there are more parsing states.public JsonParser.Event next()
JsonParsernext in interface JsonParserpublic void close()
JsonParserclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface JsonParserCopyright © 2013 Oracle. All Rights Reserved.