Class ContentType


  • public final class ContentType
    extends java.lang.Object
    Represents a immutable MIME ContentType value (RFC 2616 §3.7)

    media-type = type "/" subtype *( ";" parameter ) type = token
    subtype = token

    Rule M1.13 : Package implementers shall only create and only recognize parts with a content type; format designers shall specify a content type for each part included in the format. Content types for package parts shall fit the definition and syntax for media types as specified in RFC 2616, \§3.7.

    Rule M1.14: Content types shall not use linear white space either between the type and subtype or between an attribute and its value. Content types also shall not have leading or trailing white spaces. Package implementers shall create only such content types and shall require such content types when retrieving a part from a package; format designers shall specify only such content types for inclusion in the format.

    See Also:
    http://www.ietf.org/rfc/rfc2045.txt, http://www.ietf.org/rfc/rfc2616.txt
    • Constructor Summary

      Constructors 
      Constructor Description
      ContentType​(java.lang.String contentType)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getParameter​(java.lang.String key)
      Gets the value associated to the specified key.
      java.lang.String[] getParameterKeys()
      Return the parameter keys
      java.lang.String getSubType()
      Get the subtype.
      java.lang.String getType()
      Get the type.
      int hashCode()  
      boolean hasParameters()
      Does this content type have any parameters associated with it?
      java.lang.String toString()
      Returns the content type as a string, including parameters
      java.lang.String toString​(boolean withParameters)  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ContentType

        public ContentType​(java.lang.String contentType)
                    throws InvalidFormatException
        Constructor. Check the input with the RFC 2616 grammar.
        Parameters:
        contentType - The content type to store.
        Throws:
        InvalidFormatException - If the specified content type is not valid with RFC 2616.
    • Method Detail

      • toString

        public final java.lang.String toString()
        Returns the content type as a string, including parameters
        Overrides:
        toString in class java.lang.Object
      • toString

        public final java.lang.String toString​(boolean withParameters)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getSubType

        public java.lang.String getSubType()
        Get the subtype.
        Returns:
        The subtype of this content type.
      • getType

        public java.lang.String getType()
        Get the type.
        Returns:
        The type of this content type.
      • hasParameters

        public boolean hasParameters()
        Does this content type have any parameters associated with it?
      • getParameterKeys

        public java.lang.String[] getParameterKeys()
        Return the parameter keys
      • getParameter

        public java.lang.String getParameter​(java.lang.String key)
        Gets the value associated to the specified key.
        Parameters:
        key - The key of the key/value pair.
        Returns:
        The value associated to the specified key.