com.google.enterprise.adaptor
Class Metadata

java.lang.Object
  extended by com.google.enterprise.adaptor.Metadata
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>

public class Metadata
extends Object
implements Iterable<Map.Entry<String,String>>

Allows storing multiple metadata values to a single key.

Null keys are invalid as arguments. Null values are invalid as arguments.

This class is mutable and not thread-safe.


Constructor Summary
Metadata()
          Create empty instance.
Metadata(Iterable<Map.Entry<String,String>> m)
          Duplicate.
 
Method Summary
 void add(String k, String v)
          Increases values mapped to k with v.
 boolean equals(Object o)
          True if exactly the same key-values are represented.
 Set<String> getAllValues(String key)
          Gives unmodifiable reference to inserted values for key, empty if none.
 Set<String> getKeys()
          Get modifiable set of all keys with at least one value.
 String getOneValue(String key)
          One of the inserted values, or null if none.
 int hashCode()
           
 boolean isEmpty()
          True with 0 entries.
 Iterator<Map.Entry<String,String>> iterator()
          Provides every key and value in immutable entries sorted alphabetically, first by key, and secondly by value.
 void set(Iterable<Map.Entry<String,String>> it)
          Replaces entries inside of this metadata with provided ones.
 void set(String k, Set<String> v)
          Make copy of v be the values associated with key.
 void set(String k, String v)
          Make v be only value associated with key.
 String toString()
          Contains every key and value pair; useful for debugging.
 Metadata unmodifiableView()
          Get a reference to an unmodifiable view of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Metadata

public Metadata()
Create empty instance.


Metadata

public Metadata(Iterable<Map.Entry<String,String>> m)
Duplicate.

Method Detail

set

public void set(String k,
                String v)
Make v be only value associated with key.


set

public void set(String k,
                Set<String> v)
Make copy of v be the values associated with key.


add

public void add(String k,
                String v)
Increases values mapped to k with v.


set

public void set(Iterable<Map.Entry<String,String>> it)
Replaces entries inside of this metadata with provided ones.


getAllValues

public Set<String> getAllValues(String key)
Gives unmodifiable reference to inserted values for key, empty if none.


getOneValue

public String getOneValue(String key)
One of the inserted values, or null if none.


getKeys

public Set<String> getKeys()
Get modifiable set of all keys with at least one value.


iterator

public Iterator<Map.Entry<String,String>> iterator()
Provides every key and value in immutable entries sorted alphabetically, first by key, and secondly by value.

Behaviour is undefined if backing Metadata instance is modified during iteration.

remove() is unsupported on returned iterator.

Specified by:
iterator in interface Iterable<Map.Entry<String,String>>

equals

public boolean equals(Object o)
True if exactly the same key-values are represented.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
True with 0 entries.


toString

public String toString()
Contains every key and value pair; useful for debugging.

Overrides:
toString in class Object

unmodifiableView

public Metadata unmodifiableView()
Get a reference to an unmodifiable view of this object.