Class AbstractContent

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractContent()
      Default Constructor which requires no arguments.
      AbstractContent​(Content content)
      Copy constructor from another content.
      AbstractContent​(java.lang.String contentType, java.util.Date lastModified, java.lang.Long length)
      Null values are replaced with defaults.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getContentType()
      The type of content.
      java.util.Date getLastModified()
      When the content was modified.
      java.lang.Long getLength()
      How much content there is.
      java.lang.String getSha256()
      Get the Sha256 hash.
      java.lang.String getSha256​(boolean computeIfMissing)
      Get or generate the MD5 hash of content.
      void setContentType​(java.lang.String contentType)
      Set the content mime type.
      void setLastModified​(java.util.Date lastModified)
      Set when this content was created.
      void setLength​(java.lang.Long length)
      Set the content length.
      void setSha256​(java.lang.String sha256)
      Set the sha256 hash of content.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractContent

        public AbstractContent​(java.lang.String contentType,
                               java.util.Date lastModified,
                               java.lang.Long length)
        Null values are replaced with defaults.
        Parameters:
        contentType - defaults to "text/plain".
        lastModified - defaults to new Date().
        length - defaults to -1L.
      • AbstractContent

        public AbstractContent​(Content content)
        Copy constructor from another content.
        Parameters:
        content - the content to copy.
      • AbstractContent

        public AbstractContent()
        Default Constructor which requires no arguments. Default values are used for all fields.
    • Method Detail

      • getContentType

        public java.lang.String getContentType()
        Description copied from interface: Content
        The type of content.
        Specified by:
        getContentType in interface Content
        Returns:
        the content mime type.
      • setContentType

        public void setContentType​(java.lang.String contentType)
        Set the content mime type.
        Parameters:
        contentType - the content mime type.
      • getLastModified

        public java.util.Date getLastModified()
        Description copied from interface: Content
        When the content was modified.
        Specified by:
        getLastModified in interface Content
        Returns:
        the content creation date.
      • setLastModified

        public void setLastModified​(java.util.Date lastModified)
        Set when this content was created.
        Parameters:
        lastModified - when this content was created.
      • getLength

        public java.lang.Long getLength()
        Description copied from interface: Content
        How much content there is.
        Specified by:
        getLength in interface Content
        Returns:
        the content length, or -1 if unknown.
      • setLength

        public void setLength​(java.lang.Long length)
        Set the content length.
        Parameters:
        length - long to set
      • getSha256

        public java.lang.String getSha256()
                                   throws java.lang.Exception
        Get the Sha256 hash.
        Specified by:
        getSha256 in interface Content
        Returns:
        base64 encoded sha256 of content bytes.
        Throws:
        java.lang.Exception - if error occurs
      • getSha256

        public java.lang.String getSha256​(boolean computeIfMissing)
                                   throws java.lang.Exception
        Get or generate the MD5 hash of content.
        Parameters:
        computeIfMissing - Use getInputStream to generate hash if missing.
        Returns:
        sha256 string
        Throws:
        java.lang.Exception - if error occurs
      • setSha256

        public void setSha256​(java.lang.String sha256)
        Set the sha256 hash of content.
        Parameters:
        sha256 - to set