Class Metadata

java.lang.Object
org.apache.nutch.metadata.Metadata
All Implemented Interfaces:
Writable, CreativeCommons, DublinCore, Feed, HttpHeaders, Nutch
Direct Known Subclasses:
CaseInsensitiveMetadata

public class Metadata extends Object implements Writable, CreativeCommons, DublinCore, HttpHeaders, Nutch, Feed
A multi-valued metadata container.
  • Field Details

    • metadata

      protected Map<String,String[]> metadata
      A map of all metadata attributes.
  • Constructor Details

    • Metadata

      public Metadata()
      Constructs a new, empty metadata.
  • Method Details

    • isMultiValued

      public boolean isMultiValued(String name)
      Returns true if named value is multivalued.
      Parameters:
      name - name of metadata
      Returns:
      true is named value is multivalued, false if single value or null
    • names

      public String[] names()
      Returns an array of the names contained in the metadata.
      Returns:
      Metadata names
    • get

      public String get(String name)
      Get the value associated to a metadata name. If many values are associated to the specified name, then the first one is returned.
      Parameters:
      name - of the metadata.
      Returns:
      the value associated to the specified metadata name.
    • getValues

      public String[] getValues(String name)
      Get the values associated to a metadata name.
      Parameters:
      name - of the metadata.
      Returns:
      the values associated to a metadata name.
    • add

      public void add(String name, String value)
      Add a metadata name/value mapping. Add the specified value to the list of values associated to the specified metadata name.
      Parameters:
      name - the metadata name.
      value - the metadata value.
    • addAll

      public void addAll(Metadata metadata)
      Add all name/value mappings (merge two metadata mappings). If a name already exists in current metadata the values are added to existing values.
      Parameters:
      metadata - other Metadata to be merged
    • setAll

      public void setAll(Properties properties)
      Copy All key-value pairs from properties.
      Parameters:
      properties - properties to copy from
    • set

      public void set(String name, String value)
      Set metadata name/value. Associate the specified value to the specified metadata name. If some previous values were associated to this name, they are removed.
      Parameters:
      name - the metadata name.
      value - the metadata value.
    • remove

      public void remove(String name)
      Remove a metadata and all its associated values.
      Parameters:
      name - metadata name to remove
    • size

      public int size()
      Returns the number of metadata names in this metadata.
      Returns:
      number of metadata names
    • clear

      public void clear()
      Remove all mappings from metadata.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(String separator, String keyValueSeparator)
      Parameters:
      separator - separator between Metadata's key-value pairs
      keyValueSeparator - separator between key and value
      Returns:
      list of all key-value pairs in Metadata using the provided separators
    • write

      public final void write(DataOutput out) throws IOException
      Specified by:
      write in interface Writable
      Throws:
      IOException
    • readFields

      public final void readFields(DataInput in) throws IOException
      Specified by:
      readFields in interface Writable
      Throws:
      IOException