Class Metadata

  • Direct Known Subclasses:
    CharacterSet, Encoding, Language, MediaType

    public abstract class Metadata
    extends java.lang.Object
    Representations metadata for content negotiation. "Metadata is in the form of name-value pairs, where the name corresponds to a standard that defines the value's structure and semantics. Response messages may include both representation metadata and resource metadata: information about the resource that is not specific to the supplied representation." Roy T. Fielding
    Author:
    Jerome Louvel
    See Also:
    Preference, Source dissertation
    • Constructor Summary

      Constructors 
      Constructor Description
      Metadata​(java.lang.String name)
      Constructor.
      Metadata​(java.lang.String name, java.lang.String description)
      Constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      java.lang.String getDescription()
      Returns the description.
      java.lang.String getName()
      Returns the name (ex: "text/html" or "compress" or "iso-8851-1").
      abstract Metadata getParent()
      Returns the parent metadata if available or null.
      int hashCode()
      abstract boolean includes​(Metadata included)
      Indicates if a given metadata is included in the current one.
      boolean isCompatible​(Metadata otherMetadata)
      Checks if this metadata is compatible with the given metadata.
      java.lang.String toString()
      Returns the metadata name.
      • Methods inherited from class java.lang.Object

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

      • Metadata

        public Metadata​(java.lang.String name)
        Constructor.
        Parameters:
        name - The unique name.
      • Metadata

        public Metadata​(java.lang.String name,
                        java.lang.String description)
        Constructor.
        Parameters:
        name - The unique name.
        description - The description.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • getDescription

        public java.lang.String getDescription()
        Returns the description.
        Returns:
        The description.
      • getName

        public java.lang.String getName()
        Returns the name (ex: "text/html" or "compress" or "iso-8851-1").
        Returns:
        The name (ex: "text/html" or "compress" or "iso-8851-1").
      • getParent

        public abstract Metadata getParent()
        Returns the parent metadata if available or null.
        Returns:
        The parent metadata.
      • hashCode

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

        public abstract boolean includes​(Metadata included)
        Indicates if a given metadata is included in the current one. The test is true if both metadata are equal or if the given metadata is within the range of the current one. For example, MediaType.ALL includes all media types.

        Examples:

        • TEXT_ALL.includes(TEXT_PLAIN) returns true
        • TEXT_PLAIN.includes(TEXT_ALL) returns false
        Parameters:
        included - The metadata to test for inclusion.
        Returns:
        True if the given metadata is included in the current one.
        See Also:
        isCompatible(Metadata)
      • isCompatible

        public boolean isCompatible​(Metadata otherMetadata)
        Checks if this metadata is compatible with the given metadata.

        Examples:

        • TEXT_ALL.isCompatible(TEXT_PLAIN) returns true
        • TEXT_PLAIN.isCompatible(TEXT_ALL) returns true
        • TEXT_PLAIN.isCompatible(APPLICATION_ALL) returns false
        Parameters:
        otherMetadata - The other metadata to compare.
        Returns:
        True if the metadata are compatible.
        See Also:
        includes(Metadata)
      • toString

        public java.lang.String toString()
        Returns the metadata name.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The metadata name.