@NotThreadSafe public static class JsonReader.Parser extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
JsonReader.Parser.FunctionCall |
protected static class |
JsonReader.Parser.FunctionParameter |
Constructor and Description |
---|
JsonReader.Parser(JsonReader.Tokenizer tokenizer,
DocumentValueFactory values,
JsonReader.ValueMatcher valueMatcher)
Create a new JsonReader that uses the supplied
JsonReader.Tokenizer instance. |
Modifier and Type | Method and Description |
---|---|
Object |
evaluateFunction(JsonReader.Parser.FunctionCall function)
Method that is called to evaluate the supplied function.
|
protected Object |
evaluateUnknownFunction(JsonReader.Parser.FunctionCall function)
Method that is called when the function call described by the parameter could not be evaluated.
|
protected boolean |
isReservedFieldName(String fieldName) |
protected BasicDocument |
newDocument() |
BasicArray |
parseArray()
Parse the JSON array on the stream, beginning with the '[' character until the ']' character, which is consumed.
|
Document |
parseDocument()
Parse the stream for the next JSON document.
|
protected Document |
parseDocument(AtomicBoolean hasReservedFieldNames,
boolean failIfNotValidDocument)
Parse the stream for the next JSON document.
|
Document |
parseDocument(boolean failIfNotValidDocument)
Parse the stream for the next JSON document.
|
Object |
parseFunction()
Parse a function call on the stream.
|
protected Number |
parseNumber(String value)
Parse the number represented by the supplied value.
|
protected Object |
parseUnknownValue(String value,
int lineNumber,
int columnNumber)
Override this method if custom value types are expected.
|
Object |
parseValue()
Parse the stream for the next field value, which can be one of the following values:
a nested document
an array of values
a string literal, surrounded by single-quote characters
a string literal, surrounded by double-quote characters
a string literal date of the form
"yyyy-MM-ddTHH:mm:ss"
where T is a literal character
a string literal date of the form "yyyy-MM-ddTHH:mm:ssZ"
where T and Z are literal characters
a string literal date of the form
"yyyy-MM-ddTHH:mm:ssGMT+00:00" where
T , and GMT are literal characters
a string literal date of the form "/Date(millisOrIso)/"
a string literal date of the form "\/Date(millisOrIso)\/"
a date literal of the form new Date(millisOrIso)
a date literal of the form Date(millisOrIso)
a function of the form new functionName(parameters) where parameters
consists of one or more values as parsed by this method
Note that in the date forms listed above, millisOrIso is either a long value representing the
number of milliseconds since epoch or a string literal in ISO-8601 format representing a date and time. |
Object |
parseValue(String value,
int lineNumber,
int columnNumber)
Parse the value given by the supplied string located at the supplied line and column numbers.
|
protected Object |
processDocumentWithReservedFieldNames(Document doc) |
public JsonReader.Parser(JsonReader.Tokenizer tokenizer, DocumentValueFactory values, JsonReader.ValueMatcher valueMatcher)
JsonReader.Tokenizer
instance.tokenizer
- the tokenizer that tokenizes the stream of JSON content; may not be nullvalues
- the factory for creating value objects; may not be nullvalueMatcher
- the component that looks for patterns within string values to create alternative objects; may not
be nullpublic Document parseDocument() throws ParsingException
ParsingException
- if there is a problem parsing the valuepublic Document parseDocument(boolean failIfNotValidDocument) throws ParsingException
failIfNotValidDocument
- true if this method should throw an exception if the stream does not contain a valid
document, or false if null should be returned if there is no valid document on the streamParsingException
- if there is a problem parsing the valueprotected BasicDocument newDocument()
protected Document parseDocument(AtomicBoolean hasReservedFieldNames, boolean failIfNotValidDocument) throws ParsingException
hasReservedFieldNames
- the flag that should be set if this document contains field names that are reservedfailIfNotValidDocument
- true if this method should throw an exception if the stream does not contain a valid
document, or false if null should be returned if there is no valid document on the streamParsingException
- if there is a problem parsing the valueprotected final boolean isReservedFieldName(String fieldName)
public BasicArray parseArray() throws ParsingException
ParsingException
- if there is a problem parsing the valuepublic Object parseValue() throws ParsingException
"yyyy-MM-ddTHH:mm:ss"
where T
is a literal character"yyyy-MM-ddTHH:mm:ssZ"
where T
and Z
are literal characters"yyyy-MM-ddTHH:mm:ssGMT+00:00"
where
T
, and GMT
are literal characters"/Date(millisOrIso)/"
"\/Date(millisOrIso)\/"
new Date(millisOrIso)
Date(millisOrIso)
new functionName(parameters)
where parameters
consists of one or more values as parsed by this method
millisOrIso
is either a long value representing the
number of milliseconds since epoch or a string literal in ISO-8601 format representing a date and time.ParsingException
- if there is a problem parsing the valuepublic Object parseValue(String value, int lineNumber, int columnNumber) throws ParsingException
parseUnknownValue(String, int, int)
.value
- the string representation of the valuelineNumber
- the line number for the beginning of the valuecolumnNumber
- the column number for the beginning of the valueParsingException
- if there is a problem parsing the valueprotected Number parseNumber(String value)
parseValue(String, int, int)
method.value
- the string representation of the valueprotected Object parseUnknownValue(String value, int lineNumber, int columnNumber) throws ParsingException
value
- the string representation of the valuelineNumber
- the line number at which the value startscolumnNumber
- the column number at which the value startsParsingException
- if there is a problem parsing the valuepublic Object parseFunction() throws ParsingException
ParsingException
- if there is a problem parsing the valuepublic Object evaluateFunction(JsonReader.Parser.FunctionCall function) throws ParsingException
function
- the function definitionParsingException
- if there is a problem parsing the valueprotected Object evaluateUnknownFunction(JsonReader.Parser.FunctionCall function) throws ParsingException
function
- the function definitionParsingException
- if there is a problem parsing the valueCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.