Class AsyncJSON.Factory
- java.lang.Object
-
- org.eclipse.jetty.util.ajax.AsyncJSON.Factory
-
- Enclosing class:
- AsyncJSON
public static class AsyncJSON.Factory extends java.lang.ObjectThe factory that creates AsyncJSON instances.
The factory can be configured with custom
JSON.Convertors, and with cached strings that will not be allocated if they can be looked up from the cache.
-
-
Constructor Summary
Constructors Constructor Description Factory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancache(java.lang.String value)protected java.lang.Stringcached(java.nio.ByteBuffer buffer)Attempts to return a cached string from the buffer bytes.java.util.function.Function<java.util.List<?>,java.lang.Object>getArrayConverter()JSON.ConvertorgetConvertor(java.lang.String className)Returns theJSON.Convertorassociated with the given class name, if any.booleanisDetailedParseException()AsyncJSONnewAsyncJSON()voidputConvertor(java.lang.String className, JSON.Convertor convertor)Associates the givenJSON.Convertorto the given class name.JSON.ConvertorremoveConvertor(java.lang.String className)Removes theJSON.Convertorassociated with the given class name.voidsetArrayConverter(java.util.function.Function<java.util.List<?>,java.lang.Object> arrayConverter)Sets the function to convert JSON arrays from their default Java representation, aList<Object>, to another Java data structure such as anObject[].voidsetDetailedParseException(boolean detailedParseException)
-
-
-
Method Detail
-
getArrayConverter
public java.util.function.Function<java.util.List<?>,java.lang.Object> getArrayConverter()
- Returns:
- the function to customize the Java representation of JSON arrays
- See Also:
setArrayConverter(Function)
-
setArrayConverter
public void setArrayConverter(java.util.function.Function<java.util.List<?>,java.lang.Object> arrayConverter)
Sets the function to convert JSON arrays from their default Java representation, a
List<Object>, to another Java data structure such as anObject[].- Parameters:
arrayConverter- the function to customize the Java representation of JSON arrays- See Also:
getArrayConverter()
-
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
public boolean cache(java.lang.String value)
- Parameters:
value- the string to cache- Returns:
- whether the value can be cached
-
cached
protected java.lang.String cached(java.nio.ByteBuffer buffer)
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,
nullis returned and the buffer position is left unaltered.- Parameters:
buffer- the buffer to lookup the string from- Returns:
- a cached string or
null
-
newAsyncJSON
public AsyncJSON newAsyncJSON()
- Returns:
- a new parser instance
-
putConvertor
public void putConvertor(java.lang.String className, JSON.Convertor convertor)Associates the given
JSON.Convertorto the given class name.- Parameters:
className- the domain class name such ascom.acme.Personconvertor- theJSON.Convertorthat convertsMapto domain objects
-
removeConvertor
public JSON.Convertor removeConvertor(java.lang.String className)
Removes the
JSON.Convertorassociated with the given class name.- Parameters:
className- the class name associated with theJSON.Convertor- Returns:
- the
JSON.Convertorassociated with the class name, ornull
-
getConvertor
public JSON.Convertor getConvertor(java.lang.String className)
Returns the
JSON.Convertorassociated with the given class name, if any.- Parameters:
className- the class name associated with theJSON.Convertor- Returns:
- the
JSON.Convertorassociated with the class name, ornull
-
-