Package org.eclipse.jetty.util.ajax
Class AsyncJSON.Factory
java.lang.Object
org.eclipse.jetty.util.ajax.AsyncJSON.Factory
- Enclosing class:
- AsyncJSON
The factory that creates AsyncJSON instances.
The factory can be configured with custom JSON.Convertor
s,
and with cached strings that will not be allocated if they can
be looked up from the cache.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Trie<AsyncJSON.Factory.CachedString>
private Map<String,
JSON.Convertor> private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected String
cached
(ByteBuffer buffer) Attempts to return a cached string from the buffer bytes.getConvertor
(String className) Returns theJSON.Convertor
associated with the given class name, if any.boolean
void
putConvertor
(String className, JSON.Convertor convertor) Associates the givenJSON.Convertor
to the given class name.removeConvertor
(String className) Removes theJSON.Convertor
associated with the given class name.void
setDetailedParseException
(boolean detailedParseException)
-
Field Details
-
cache
-
convertors
-
detailedParseException
private boolean detailedParseException
-
-
Constructor Details
-
Factory
public Factory()
-
-
Method Details
-
isDetailedParseException
public boolean isDetailedParseException()- Returns:
- whether a parse failure should report the whole JSON string or just the last chunk
-
setDetailedParseException
public void setDetailedParseException(boolean detailedParseException) - Parameters:
detailedParseException
- whether a parse failure should report the whole JSON string or just the last chunk
-
cache
- Parameters:
value
- the string to cache- Returns:
- whether the value can be cached
-
cached
Attempts to return a cached string from the buffer bytes.
In case of a cache hit, the string is returned and the buffer position updated.
In case of cache miss,
null
is returned and the buffer position is left unaltered.- Parameters:
buffer
- the buffer to lookup the string from- Returns:
- a cached string or
null
-
newAsyncJSON
- Returns:
- a new parser instance
-
putConvertor
Associates the given
JSON.Convertor
to the given class name.- Parameters:
className
- the domain class name such ascom.acme.Person
convertor
- theJSON.Convertor
that convertsMap
to domain objects
-
removeConvertor
Removes the
JSON.Convertor
associated with the given class name.- Parameters:
className
- the class name associated with theJSON.Convertor
- Returns:
- the
JSON.Convertor
associated with the class name, ornull
-
getConvertor
Returns the
JSON.Convertor
associated with the given class name, if any.- Parameters:
className
- the class name associated with theJSON.Convertor
- Returns:
- the
JSON.Convertor
associated with the class name, ornull
-