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 classvoidgetClassFactory(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.ConverterOptionsgetCustomReader(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) intgetTypeNameAlias(String typeName) Alias Type Names, e.g.Class<?>booleanisClassCoerced(String className) booleanbooleanisCustomReaderClass(Class<?> clazz) booleanbooleanisNonReferenceableClass(Class<?> clazz) booleanisNotCustomReaderClass(Class<?> clazz) booleanbooleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.cedarsoftware.util.io.ReadOptions
isAllowNanAndInfinity
-
Method Details
-
getClassLoader
- Specified by:
getClassLoaderin interfaceReadOptions- Returns:
- ClassLoader to be used when reading JSON to resolve String named classes.
-
isFailOnUnknownType
public boolean isFailOnUnknownType()- Specified by:
isFailOnUnknownTypein interfaceReadOptions- Returns:
- boolean true if an 'unknownTypeClass' is set, false if it is not sell (null).
-
getUnknownTypeClass
- Specified by:
getUnknownTypeClassin interfaceReadOptions- Returns:
- the Class which will have unknown fields set upon it. Typically this is a Map derivative.
-
isCloseStream
public boolean isCloseStream()- Specified by:
isCloseStreamin 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:
getMaxDepthin 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:
getTypeNameAliasin 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:
isClassCoercedin 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:
getCoercedClassin interfaceReadOptions- Parameters:
c- Class to coerce- Returns:
- Class destination (coerced) class or null if there is none.
-
getMissingFieldHandler
- Specified by:
getMissingFieldHandlerin 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:
isNonReferenceableClassin 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:
isNotCustomReaderClassin 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:
isCustomReaderClassin 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:
getClassFactoryin 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:
getCustomReaderin 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:
isReturningJsonObjectsin interfaceReadOptions- Returns:
- true if returning items in basic JSON object format
-
isReturningJavaObjects
public boolean isReturningJavaObjects()- Specified by:
isReturningJavaObjectsin 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:
getDeepInjectorMapin interfaceReadOptions
-
clearCaches
public void clearCaches()- Specified by:
clearCachesin interfaceReadOptions
-
getDeepDeclaredFields
Gets the declared fields for the full class hierarchy of a given class- Specified by:
getDeepDeclaredFieldsin 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:
getConverterOptionsin 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.
-