Class ReadOptionsBuilder.DefaultReadOptions

java.lang.Object
com.cedarsoftware.util.io.ReadOptionsBuilder.DefaultReadOptions
All Implemented Interfaces:
ReadOptions
Enclosing class:
ReadOptionsBuilder

public static class ReadOptionsBuilder.DefaultReadOptions extends Object implements ReadOptions
  • Method Details

    • getClassLoader

      public ClassLoader getClassLoader()
      Specified by:
      getClassLoader in interface ReadOptions
      Returns:
      ClassLoader to be used when reading JSON to resolve String named classes.
    • isFailOnUnknownType

      public boolean isFailOnUnknownType()
      Specified by:
      isFailOnUnknownType in interface ReadOptions
      Returns:
      boolean true if an 'unknownTypeClass' is set, false if it is not sell (null).
    • getUnknownTypeClass

      public Class<?> getUnknownTypeClass()
      Specified by:
      getUnknownTypeClass in interface ReadOptions
      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 interface ReadOptions
      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 interface ReadOptions
      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

      public String getTypeNameAlias(String typeName)
      Alias Type Names, e.g. "ArrayList" instead of "java.util.ArrayList".
      Specified by:
      getTypeNameAlias in interface ReadOptions
      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

      public boolean isClassCoerced(String className)
      Specified by:
      isClassCoerced in interface ReadOptions
      Returns:
      boolean true if the passed in Class name is being coerced to another type, false otherwise.
    • getCoercedClass

      public Class<?> getCoercedClass(Class<?> c)
      Fetch the coerced class for the passed in fully qualified class name.
      Specified by:
      getCoercedClass in interface ReadOptions
      Parameters:
      c - Class to coerce
      Returns:
      Class destination (coerced) class or null if there is none.
    • getMissingFieldHandler

      public JsonReader.MissingFieldHandler getMissingFieldHandler()
      Specified by:
      getMissingFieldHandler in interface ReadOptions
      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

      public boolean isNonReferenceableClass(Class<?> clazz)
      Specified by:
      isNonReferenceableClass in interface ReadOptions
      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

      public boolean isNotCustomReaderClass(Class<?> clazz)
      Specified by:
      isNotCustomReaderClass in interface ReadOptions
      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

      public boolean isCustomReaderClass(Class<?> clazz)
      Specified by:
      isCustomReaderClass in interface ReadOptions
      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

      public JsonReader.ClassFactory getClassFactory(Class<?> c)
      Get the ClassFactory associated to the passed in class.
      Specified by:
      getClassFactory in interface ReadOptions
      Parameters:
      c - Class for which to fetch the ClassFactory.
      Returns:
      JsonReader.ClassFactory instance associated to the passed in class.
    • getCustomReader

      public JsonReader.JsonClassReader getCustomReader(Class<?> c)
      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 interface ReadOptions
      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 interface ReadOptions
      Returns:
      true if returning items in basic JSON object format
    • isReturningJavaObjects

      public boolean isReturningJavaObjects()
      Specified by:
      isReturningJavaObjects in interface ReadOptions
      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

      public Map<String,Injector> getDeepInjectorMap(Class<?> classToTraverse)
      Specified by:
      getDeepInjectorMap in interface ReadOptions
    • clearCaches

      public void clearCaches()
      Specified by:
      clearCaches in interface ReadOptions
    • getDeepDeclaredFields

      public Map<String,Field> getDeepDeclaredFields(Class<?> c)
      Gets the declared fields for the full class hierarchy of a given class
      Specified by:
      getDeepDeclaredFields in interface ReadOptions
      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 interface ReadOptions
    • buildDeepFieldMap

      public Map<String,Field> buildDeepFieldMap(Class<?> c)
      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.