Package org.apache.nutch.metadata

## Class MetaWrapper

- java.lang.Object
- - org.apache.hadoop.io.GenericWritable
  - - org.apache.nutch.util.GenericWritableConfigurable
    - - org.apache.nutch.crawl.NutchWritable
      - - org.apache.nutch.metadata.MetaWrapper

- All Implemented Interfaces:
    `Configurable`, `Writable`

      public class MetaWrapper
      extends NutchWritable

  This is a simple decorator that adds metadata to any Writable-s that can be serialized by `NutchWritable`. 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

    Constructors
    Constructor | Description
    --- | ---
    `MetaWrapper()` |
    `MetaWrapper​(Writable instance, Configuration conf)` |
    `MetaWrapper​(Metadata metadata, Writable instance, Configuration conf)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addMeta​(String name, String value)` | Add metadata.
    `String` | `getMeta​(String name)` | Get metadata value for a given key.
    `Metadata` | `getMetadata()` | Get all metadata.
    `String[]` | `getMetaValues​(String name)` | Get multiple metadata values for a given key.
    `void` | `readFields​(DataInput in)` |
    `void` | `setMeta​(String name, String value)` | Set metadata.
    `void` | `write​(DataOutput out)` |

    - ### Methods inherited from class org.apache.nutch.crawl.NutchWritable

      `getTypes`

    - ### Methods inherited from class org.apache.nutch.util.GenericWritableConfigurable

      `getConf, setConf`

    - ### Methods inherited from class org.apache.hadoop.io.GenericWritable

      `get, set, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MetaWrapper

          public MetaWrapper()

    - #### MetaWrapper

          public MetaWrapper​(Writable instance,
                             Configuration conf)

    - #### MetaWrapper

          public MetaWrapper​(Metadata metadata,
                             Writable instance,
                             Configuration conf)

  - ### Method Detail

    - #### getMetadata

          public Metadata getMetadata()

      Get all metadata.
      Returns:
        a populated `Metadata` object

    - #### addMeta

          public void addMeta​(String name,
                              String value)

      Add metadata.
      Parameters:
        `name` - metadata name to add
        `value` - metadata value to add
      See Also:
        `Metadata.add(String, String)`

    - #### setMeta

          public void setMeta​(String name,
                              String value)

      Set metadata.
      Parameters:
        `name` - metadata key to set
        `value` - metadata value to set
      See Also:
        `Metadata.set(String, String)`

    - #### getMeta

          public String getMeta​(String name)

      Get metadata value for a given key.
      Parameters:
        `name` - key to retrieve a value for
      Returns:
        metadata value
      See Also:
        `Metadata.getValues(String)`

    - #### getMetaValues

          public String[] getMetaValues​(String name)

      Get multiple metadata values for a given key.
      Parameters:
        `name` - key to retrieve values for
      Returns:
        a string array containing metadata values
      See Also:
        `Metadata.getValues(String)`

    - #### readFields

          public void readFields​(DataInput in)
                          throws IOException

      Specified by:
        `readFields` in interface `Writable`
      Overrides:
        `readFields` in class `GenericWritableConfigurable`
      Throws:
        `IOException`

    - #### write

          public void write​(DataOutput out)
                     throws IOException

      Specified by:
        `write` in interface `Writable`
      Overrides:
        `write` in class `GenericWritable`
      Throws:
        `IOException`