org.apache.nutch.metadata
Class MetaWrapper

java.lang.Object
  extended by org.apache.hadoop.io.ObjectWritable
      extended by org.apache.nutch.metadata.MetaWrapper
All Implemented Interfaces:
Configurable, Writable

public class MetaWrapper
extends ObjectWritable

This is a simple decorator that adds metadata to any Object-s that can be serialized by ObjectWritable. This is useful when data needs to be temporarily enriched during processing, but this temporary metadata doesn't need to be permanently stored after the job is done.

Author:
Andrzej Bialecki

Constructor Summary
MetaWrapper()
           
MetaWrapper(Metadata metadata, Object object, Configuration conf)
           
MetaWrapper(Object object, Configuration conf)
           
 
Method Summary
 void addMeta(String name, String value)
          Add metadata.
 String getMeta(String name)
          Get metadata.
 Metadata getMetadata()
          Get all metadata.
 String[] getMetaValues(String name)
          Get multiple metadata.
 void readFields(DataInput in)
          Reads the fields of this object from in.
 void setMeta(String name, String value)
          Set metadata.
 void write(DataOutput out)
          Writes the fields of this object to out.
 
Methods inherited from class org.apache.hadoop.io.ObjectWritable
get, getConf, getDeclaredClass, readObject, readObject, set, setConf, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaWrapper

public MetaWrapper()

MetaWrapper

public MetaWrapper(Object object,
                   Configuration conf)

MetaWrapper

public MetaWrapper(Metadata metadata,
                   Object object,
                   Configuration conf)
Method Detail

getMetadata

public Metadata getMetadata()
Get all metadata.


addMeta

public void addMeta(String name,
                    String value)
Add metadata. See Metadata.add(String, String) for more information.

Parameters:
name - metadata name
value - metadata value

setMeta

public void setMeta(String name,
                    String value)
Set metadata. See Metadata.set(String, String) for more information.

Parameters:
name -
value -

getMeta

public String getMeta(String name)
Get metadata. See Metadata.get(String) for more information.

Parameters:
name -
Returns:
metadata value

getMetaValues

public String[] getMetaValues(String name)
Get multiple metadata. See Metadata.getValues(String) for more information.

Parameters:
name -
Returns:
multiple values

readFields

public 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
Overrides:
readFields in class ObjectWritable
Throws:
IOException

write

public 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
Overrides:
write in class ObjectWritable
Throws:
IOException


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