Package com.cedarsoftware.util.io
Class ReadOptionsBuilder.DefaultReadOptions
java.lang.Object
com.cedarsoftware.util.io.ReadOptionsBuilder.DefaultReadOptions
- All Implemented Interfaces:
ReadOptions
- Enclosing class:
- ReadOptionsBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.cedarsoftware.util.io.ReadOptions
ReadOptions.ReturnType
-
Method Summary
Modifier and TypeMethodDescriptionbuildDeepFieldMap
(Class<?> c) Gets the declared fields for the full class hierarchy of a given classvoid
getClassFactory
(Class<?> c) Get the ClassFactory associated to the passed in class.Class<?>
getCoercedClass
(Class<?> c) Fetch the coerced class for the passed in fully qualified class name.com.cedarsoftware.util.convert.ConverterOptions
getCustomReader
(Class<?> c) Fetch the custom reader for the passed in Class.getDeepDeclaredFields
(Class<?> c) Gets the declared fields for the full class hierarchy of a given classgetDeepInjectorMap
(Class<?> classToTraverse) int
getTypeNameAlias
(String typeName) Alias Type Names, e.g.Class<?>
boolean
isClassCoerced
(String className) boolean
boolean
isCustomReaderClass
(Class<?> clazz) boolean
boolean
isNonReferenceableClass
(Class<?> clazz) boolean
isNotCustomReaderClass
(Class<?> clazz) boolean
boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.cedarsoftware.util.io.ReadOptions
isAllowNanAndInfinity
-
Method Details
-
getClassLoader
- Specified by:
getClassLoader
in interfaceReadOptions
- Returns:
- ClassLoader to be used when reading JSON to resolve String named classes.
-
isFailOnUnknownType
public boolean isFailOnUnknownType()- Specified by:
isFailOnUnknownType
in interfaceReadOptions
- Returns:
- boolean true if an 'unknownTypeClass' is set, false if it is not sell (null).
-
getUnknownTypeClass
- Specified by:
getUnknownTypeClass
in interfaceReadOptions
- Returns:
- the Class which will have unknown fields set upon it. Typically this is a Map derivative.
-
isCloseStream
public boolean isCloseStream()- Specified by:
isCloseStream
in interfaceReadOptions
- Returns:
- boolean 'true' if the InputStream should be closed when the reading is finished. The default is 'true.'
-
getMaxDepth
public int getMaxDepth()- Specified by:
getMaxDepth
in interfaceReadOptions
- Returns:
- int maximum level the JSON can be nested. Once the parsing nesting level reaches this depth, a JsonIoException will be thrown instead of a StackOverflowException. Prevents security risk from StackOverflow attack vectors.
-
getTypeNameAlias
Alias Type Names, e.g. "ArrayList" instead of "java.util.ArrayList".- Specified by:
getTypeNameAlias
in interfaceReadOptions
- Parameters:
typeName
- String name of type to fetch alias for. There are no default aliases.- Returns:
- String alias name or null if type name is not aliased.
-
isClassCoerced
- Specified by:
isClassCoerced
in interfaceReadOptions
- Returns:
- boolean true if the passed in Class name is being coerced to another type, false otherwise.
-
getCoercedClass
Fetch the coerced class for the passed in fully qualified class name.- Specified by:
getCoercedClass
in interfaceReadOptions
- Parameters:
c
- Class to coerce- Returns:
- Class destination (coerced) class or null if there is none.
-
getMissingFieldHandler
- Specified by:
getMissingFieldHandler
in interfaceReadOptions
- Returns:
- JsonReader.MissingFieldHandler to be called when a field in the JSON is read in, yet there is no corresponding field on the destination object to receive the field value.
-
isNonReferenceableClass
- Specified by:
isNonReferenceableClass
in interfaceReadOptions
- Parameters:
clazz
- Class to check to see if it is non-referenceable. Non-referenceable classes will always create a new instance when read in and never use @id/@ref. This uses more memory when the JSON is read in, as there will be a separate instance in memory for each occurrence. There are certain classes that json-io automatically treats as non-referenceable, like Strings, Enums, Class, and any Number instance (BigDecimal, AtomicLong, etc.) You can add to this list. Often, non-referenceable classes are useful for classes that can be defined in one line as a JSON, like a LocalDateTime, for example.- Returns:
- boolean true if the passed in class is considered a non-referenceable class.
-
isNotCustomReaderClass
- Specified by:
isNotCustomReaderClass
in interfaceReadOptions
- Parameters:
clazz
- Class to see if it is on the not-customized list. Classes are added to this list when a class is being picked up through inheritance, and you don't want it to have a custom reader associated to it.- Returns:
- boolean true if the passed in class is on the not-customized list, false otherwise.
-
isCustomReaderClass
- Specified by:
isCustomReaderClass
in interfaceReadOptions
- Parameters:
clazz
- Class to check to see if there is a custom reader associated to it.- Returns:
- boolean true if there is an associated custom reader class associated to the passed in class, false otherwise.
-
getClassFactory
Get the ClassFactory associated to the passed in class.- Specified by:
getClassFactory
in interfaceReadOptions
- Parameters:
c
- Class for which to fetch the ClassFactory.- Returns:
- JsonReader.ClassFactory instance associated to the passed in class.
-
getCustomReader
Fetch the custom reader for the passed in Class. If it is cached (already associated to the passed in Class), return the same instance, otherwise, make a call to get the custom reader and store that result.- Specified by:
getCustomReader
in interfaceReadOptions
- Parameters:
c
- Class of object for which fetch a custom reader- Returns:
- JsonClassReader for the custom class (if one exists), null otherwise.
-
isReturningJsonObjects
public boolean isReturningJsonObjects()- Specified by:
isReturningJsonObjects
in interfaceReadOptions
- Returns:
- true if returning items in basic JSON object format
-
isReturningJavaObjects
public boolean isReturningJavaObjects()- Specified by:
isReturningJavaObjects
in interfaceReadOptions
- Returns:
- true if returning items in full Java object formats. Useful for accurate reproduction of graphs into the orginal types such as when cloning objects.
-
getDeepInjectorMap
- Specified by:
getDeepInjectorMap
in interfaceReadOptions
-
clearCaches
public void clearCaches()- Specified by:
clearCaches
in interfaceReadOptions
-
getDeepDeclaredFields
Gets the declared fields for the full class hierarchy of a given class- Specified by:
getDeepDeclaredFields
in interfaceReadOptions
- Parameters:
c
- - given class.- Returns:
- Map - map of string fieldName to Field Object. This will have the deep list of fields for a given class.
-
getConverterOptions
public com.cedarsoftware.util.convert.ConverterOptions getConverterOptions()- Specified by:
getConverterOptions
in interfaceReadOptions
-
buildDeepFieldMap
Gets the declared fields for the full class hierarchy of a given class- Parameters:
c
- - given class.- Returns:
- Map - map of string fieldName to Field Object. This will have the deep list of fields for a given class.
-