Interface StreamAwareMarshaller

  • All Known Subinterfaces:
    PersistenceMarshaller

    @ThreadSafe
    public interface StreamAwareMarshaller
    A minimal interface that facilitates the marshalling/unmarshalling of objects from the provided InputStream/OutputStream. Unlike the deprecated StreamingMarshaller this interface does not rely on the use of ObjectInput and ObjectOutput to read/write objects, which provides greater flexibility when marshalling objects to streams using third party libraries.
    Since:
    10.0
    Author:
    Ryan Emerson
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean isMarshallable​(java.lang.Object o)
      A method that checks whether the given object is marshallable as per the rules of this marshaller.
      MediaType mediaType()  
      java.lang.Object readObject​(java.io.InputStream in)
      Unmarshall an object from the InputStream
      int sizeEstimate​(java.lang.Object o)
      An method that provides an estimate of the buffer size that will be required once the object has been marshalled.
      void writeObject​(java.lang.Object o, java.io.OutputStream out)
      Marshall an object to the OutputStream
    • Method Detail

      • writeObject

        void writeObject​(java.lang.Object o,
                         java.io.OutputStream out)
                  throws java.io.IOException
        Marshall an object to the OutputStream
        Parameters:
        o - the object to write to the OutputStream
        out - the OutputStream to write the object to
        Throws:
        java.io.IOException - if the object cannot be marshalled to the OutputStream due to some I/O error
      • readObject

        java.lang.Object readObject​(java.io.InputStream in)
                             throws java.lang.ClassNotFoundException,
                                    java.io.IOException
        Unmarshall an object from the InputStream
        Parameters:
        in - the InputStream to unmarshall an object from
        Returns:
        the unmarshalled object instance
        Throws:
        java.io.IOException - if unmarshalling cannot complete due to some I/O error
        java.lang.ClassNotFoundException - if the class of the object trying to unmarshall is not found
      • isMarshallable

        boolean isMarshallable​(java.lang.Object o)
        A method that checks whether the given object is marshallable as per the rules of this marshaller.
        Parameters:
        o - object to verify whether it's marshallable or not
        Returns:
        true if the object is marshallable, otherwise false
      • sizeEstimate

        int sizeEstimate​(java.lang.Object o)
        An method that provides an estimate of the buffer size that will be required once the object has been marshalled.
        Parameters:
        o - instance that will be stored in the buffer.
        Returns:
        int representing the next predicted buffer size.
      • mediaType

        MediaType mediaType()
        Returns:
        the MediaType associated with the content produced by the marshaller