Class ContentHeaderHandler

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String boundary
      Decoded from the Content-Type if it exists.
      protected java.nio.charset.Charset charset
      Decoded from the Content-Type if it exists.
      protected java.lang.Long contentLength
      The Content-Length as read from the response header.
      protected java.lang.String mediaType
      Decoded from the Content-Type.
    • Constructor Summary

      Constructors 
      Constructor Description
      ContentHeaderHandler​(java.lang.String mediaType, java.nio.charset.Charset charset, java.lang.Long contentLength)
      Constructor used when Content-Headers have to be constructed.
      ContentHeaderHandler​(java.net.http.HttpHeaders httpHeaders)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contentIsJson()
      Check whether the mediaType is application/json
      java.lang.String getBoundary()  
      java.nio.charset.Charset getCharset()  
      java.lang.Long getContentLength()  
      java.lang.String getContentType()
      Constructs the Header Content-Type from the mediaType, charset or boundary.
      java.lang.String getMediaType()  
      boolean hasContentType()  
      void setBoundary​(java.lang.String boundary)  
      void setCharset​(java.nio.charset.Charset charset)  
      void setContentLength​(java.lang.Long contentLength)  
      void setContentType​(java.lang.String contentType)
      Decodes a Content-Type header and sets mediaType, charset and boundary from it.
      void setMediaType​(java.lang.String mediaType)  
      • Methods inherited from class java.lang.Object

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

      • contentLength

        protected java.lang.Long contentLength
        The Content-Length as read from the response header. This might be null when this header is missing.
      • mediaType

        protected java.lang.String mediaType
        Decoded from the Content-Type. Might be null.
      • charset

        protected java.nio.charset.Charset charset
        Decoded from the Content-Type if it exists. Might be null.
      • boundary

        protected java.lang.String boundary
        Decoded from the Content-Type if it exists. Might be null.
    • Constructor Detail

      • ContentHeaderHandler

        public ContentHeaderHandler​(java.net.http.HttpHeaders httpHeaders)
        Constructor. Creates this object with all its data from the incoming httpHeaders.
        Parameters:
        httpHeaders - The httpHeaders to decode.
      • ContentHeaderHandler

        public ContentHeaderHandler​(java.lang.String mediaType,
                                    java.nio.charset.Charset charset,
                                    java.lang.Long contentLength)
        Constructor used when Content-Headers have to be constructed.
        Parameters:
        mediaType - The mime type for the data.
        charset - The charset - if any. Can be null.
        contentLength - The length of the content - if any. Can be null.
    • Method Detail

      • setContentType

        public void setContentType​(java.lang.String contentType)
        Decodes a Content-Type header and sets mediaType, charset and boundary from it.
        Parameters:
        contentType - The content-type directly from a HTTP header.
        See Also:
        Documentation of Content-Type
      • getContentType

        public java.lang.String getContentType()
        Constructs the Header Content-Type from the mediaType, charset or boundary.
        Returns:
        The HTTP header value for Content-Type.
      • hasContentType

        public boolean hasContentType()
      • setContentLength

        public void setContentLength​(java.lang.Long contentLength)
      • setCharset

        public void setCharset​(java.nio.charset.Charset charset)
      • setMediaType

        public void setMediaType​(java.lang.String mediaType)
      • setBoundary

        public void setBoundary​(java.lang.String boundary)
      • getContentLength

        public java.lang.Long getContentLength()
      • getMediaType

        public java.lang.String getMediaType()
      • getCharset

        public java.nio.charset.Charset getCharset()
      • getBoundary

        public java.lang.String getBoundary()
      • contentIsJson

        public boolean contentIsJson()
        Check whether the mediaType is application/json
        Returns:
        true if contentType matches, false if not.