org.apache.nutch.metadata
Class Metadata

java.lang.Object
  extended byorg.apache.nutch.metadata.Metadata
All Implemented Interfaces:
CreativeCommons, DublinCore, HttpHeaders, Nutch, Office, Writable

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

A syntax tolerant and multi-valued metadata container. All the static String fields declared by this class are used as reference names for syntax correction on meta-data naming.

Author:
Chris Mattmann, Jérôme Charron

Field Summary
static SimpleDateFormat DATE_FORMAT
          Used to format DC dates for the DATE metadata field
 
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
CHAR_ENCODING_FOR_CONVERSION, ORIGINAL_CHAR_ENCODING
 
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.
static String getNormalizedName(String name)
          Get the normalized name of metadata attribute name.
 String[] getValues(String name)
          Get the values associated to a metadata name.
 boolean isMultiValued(String name)
           
 String[] names()
          Returns an array of the names contained in the metadata.
 void readFields(DataInput 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)
           
 int size()
          Returns the number of metadata names in this metadata.
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final SimpleDateFormat DATE_FORMAT
Used to format DC dates for the DATE metadata field

Constructor Detail

Metadata

public Metadata()
Constructs a new, empty metadata.

Method Detail

isMultiValued

public boolean isMultiValued(String name)

names

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


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)

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.


size

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


equals

public boolean equals(Object o)

toString

public String toString()

getNormalizedName

public static String getNormalizedName(String name)
Get the normalized name of metadata attribute name. This method tries to find a well-known metadata name (one of the metadata names defined in this class) that matches the specified name. The matching is error tolerent. For instance, If no matching with a well-known metadata name is found, then the original name is returned.


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


Copyright © 2006 The Apache Software Foundation