Class AbstractJacksonBackedStringSerializer<T>

  • Type Parameters:
    T - the type parameter
    All Implemented Interfaces:
    java.io.Serializable, org.apereo.cas.util.serialization.StringSerializer<T>

    public abstract class AbstractJacksonBackedStringSerializer<T>
    extends java.lang.Object
    implements org.apereo.cas.util.serialization.StringSerializer<T>
    Generic class to serialize objects to/from JSON based on jackson.
    Since:
    4.1
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static com.fasterxml.jackson.core.PrettyPrinter MINIMAL_PRETTY_PRINTER
      Minimal pretty printer instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configureObjectMapper​(com.fasterxml.jackson.databind.ObjectMapper mapper)
      Configure mapper.
      T from​(java.io.File json)  
      T from​(java.io.InputStream json)  
      T from​(java.io.Reader json)  
      T from​(java.io.Writer writer)  
      T from​(java.lang.String json)  
      java.util.List<T> fromList​(java.lang.String json)  
      protected com.fasterxml.jackson.core.JsonFactory getJsonFactory()
      Gets json factory.
      com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Gets object mapper and builds on if uninitialized.
      protected boolean isDefaultTypingEnabled()  
      protected java.lang.String readJsonFrom​(java.io.InputStream json)
      Read json from stream.
      protected T readObjectFromString​(java.lang.String jsonString)
      Read object from json.
      protected java.util.List<T> readObjectsFromString​(java.lang.String jsonString)  
      void to​(java.io.File out, T object)  
      void to​(java.io.OutputStream out, T object)  
      void to​(java.io.Writer out, T object)  
      java.lang.String toString​(T object)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apereo.cas.util.serialization.StringSerializer

        getContentTypes, getTypeToSerialize, load, load, supports, supports
    • Field Detail

      • MINIMAL_PRETTY_PRINTER

        protected static final com.fasterxml.jackson.core.PrettyPrinter MINIMAL_PRETTY_PRINTER
        Minimal pretty printer instance.
    • Constructor Detail

      • AbstractJacksonBackedStringSerializer

        protected AbstractJacksonBackedStringSerializer()
    • Method Detail

      • fromList

        public java.util.List<T> fromList​(java.lang.String json)
        Specified by:
        fromList in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • from

        public T from​(java.lang.String json)
        Specified by:
        from in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • from

        public T from​(java.io.File json)
        Specified by:
        from in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • from

        public T from​(java.io.Reader json)
        Specified by:
        from in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • from

        public T from​(java.io.Writer writer)
        Specified by:
        from in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • from

        public T from​(java.io.InputStream json)
        Specified by:
        from in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • readJsonFrom

        protected java.lang.String readJsonFrom​(java.io.InputStream json)
                                         throws java.io.IOException
        Read json from stream.
        Parameters:
        json - the json
        Returns:
        the string
        Throws:
        java.io.IOException - the io exception
      • to

        public void to​(java.io.OutputStream out,
                       T object)
        Specified by:
        to in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • to

        public void to​(java.io.Writer out,
                       T object)
        Specified by:
        to in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • to

        public void to​(java.io.File out,
                       T object)
        Specified by:
        to in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • toString

        public java.lang.String toString​(T object)
        Specified by:
        toString in interface org.apereo.cas.util.serialization.StringSerializer<T>
      • configureObjectMapper

        protected void configureObjectMapper​(com.fasterxml.jackson.databind.ObjectMapper mapper)
        Configure mapper.
        Parameters:
        mapper - the mapper
      • isDefaultTypingEnabled

        protected boolean isDefaultTypingEnabled()
      • getJsonFactory

        protected com.fasterxml.jackson.core.JsonFactory getJsonFactory()
        Gets json factory.
        Returns:
        the json factory
      • readObjectFromString

        protected T readObjectFromString​(java.lang.String jsonString)
        Read object from json.
        Parameters:
        jsonString - the json string
        Returns:
        the type
      • readObjectsFromString

        protected java.util.List<T> readObjectsFromString​(java.lang.String jsonString)
      • getObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        Gets object mapper and builds on if uninitialized.
        Returns:
        the object mapper