org.apache.nutch.metadata
Class Metadata

java.lang.Object
  extended by org.apache.nutch.metadata.Metadata
All Implemented Interfaces:
Writable, CreativeCommons, DublinCore, HttpHeaders, Nutch, Office
Direct Known Subclasses:
SpellCheckedMetadata

public class Metadata
extends Object
implements Writable, CreativeCommons, DublinCore, HttpHeaders, Nutch, Office

A multi-valued metadata container.

Author:
Chris Mattmann, Jérôme Charron

Field Summary
 
Fields inherited from interface org.apache.nutch.metadata.CreativeCommons
LICENSE_LOCATION, LICENSE_URL, WORK_TYPE
 
Fields inherited from interface org.apache.nutch.metadata.DublinCore
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRIPTION, FORMAT, IDENTIFIER, LANGUAGE, MODIFIED, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Fields inherited from interface org.apache.nutch.metadata.HttpHeaders
CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_TYPE, LAST_MODIFIED, LOCATION
 
Fields inherited from interface org.apache.nutch.metadata.Nutch
CACHING_FORBIDDEN_ALL, CACHING_FORBIDDEN_CONTENT, CACHING_FORBIDDEN_KEY, CACHING_FORBIDDEN_NONE, CHAR_ENCODING_FOR_CONVERSION, GENERATE_TIME_KEY, ORIGINAL_CHAR_ENCODING, PROTO_STATUS_KEY, SCORE_KEY, SEGMENT_NAME_KEY, SIGNATURE_KEY, WRITABLE_GENERATE_TIME_KEY, WRITABLE_PROTO_STATUS_KEY
 
Fields inherited from interface org.apache.nutch.metadata.Office
APPLICATION_NAME, AUTHOR, CHARACTER_COUNT, COMMENTS, KEYWORDS, LAST_AUTHOR, LAST_PRINTED, LAST_SAVED, PAGE_COUNT, REVISION_NUMBER, TEMPLATE, WORD_COUNT
 
Constructor Summary
Metadata()
          Constructs a new, empty metadata.
 
Method Summary
 void add(String name, String value)
          Add a metadata name/value mapping.
 boolean equals(Object o)
           
 String get(String name)
          Get the value associated to a metadata name.
 String[] getValues(String name)
          Get the values associated to a metadata name.
 int hashCode()
           
 boolean isMultiValued(String name)
          Returns true if named value is multivalued.
 String[] names()
          Returns an array of the names contained in the metadata.
 void readFields(DataInput in)
          Reads the fields of this object from in.
 void remove(String name)
          Remove a metadata and all its associated values.
 void set(String name, String value)
          Set metadata name/value.
 void setAll(Properties properties)
          Copy All key-value pairs from properties.
 int size()
          Returns the number of metadata names in this metadata.
 String toString()
           
 void write(DataOutput out)
          Writes the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Metadata

public Metadata()
Constructs a new, empty metadata.

Method Detail

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 assiociated 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.

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

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

write

public final void write(DataOutput out)
                 throws IOException
Description copied from interface: Writable
Writes the fields of this object to out.

Specified by:
write in interface Writable
Throws:
IOException

readFields

public final void readFields(DataInput in)
                      throws IOException
Description copied from interface: Writable
Reads the fields of this object from in. For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Throws:
IOException


Copyright © 2007, 2012, Oracle and/or its affiliates. All rights reserved.