@@ -0,0 +1,3106 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.nutch.metadata;%0A%0Aimport java.io.DataInput;%0Aimport java.io.DataOutput;%0Aimport java.io.IOException;%0A%0Aimport org.apache.hadoop.conf.Configuration;%0Aimport org.apache.hadoop.io.ObjectWritable;%0A%0A/**%0A * This is a simple decorator that adds metadata to any Object-s that can be%0A * serialized by %3Ctt%3EObjectWritable%3C/tt%3E. This is useful when data needs to be%0A * temporarily enriched during processing, but this%0A * temporary metadata doesn't need to be permanently stored after the job is done.%0A * %0A * @author Andrzej Bialecki%0A */%0Apublic class MetaWrapper extends ObjectWritable %7B%0A  private Metadata metadata;%0A  %0A  public MetaWrapper() %7B%0A    super();%0A    metadata = new Metadata();%0A  %7D%0A  %0A  public MetaWrapper(Object object, Configuration conf) %7B%0A    super(object);%0A    metadata = new Metadata();%0A    setConf(conf);%0A  %7D%0A  %0A  public MetaWrapper(Metadata metadata, Object object, Configuration conf) %7B%0A    super(object);%0A    if (metadata == null) metadata = new Metadata();%0A    this.metadata = metadata;%0A    setConf(conf);%0A  %7D%0A%0A  /**%0A   * Get all metadata.%0A   */%0A  public Metadata getMetadata() %7B%0A    return metadata;%0A  %7D%0A  %0A  /**%0A   * Add metadata. See %7B@link Metadata#add(String, String)%7D for more information.%0A   * @param name metadata name%0A   * @param value metadata value%0A   */%0A  public void addMeta(String name, String value) %7B%0A    metadata.add(name, value);%0A  %7D%0A  %0A  /**%0A   * Set metadata. See %7B@link Metadata#set(String, String)%7D for more information.%0A   * @param name%0A   * @param value%0A   */%0A  public void setMeta(String name, String value) %7B%0A    metadata.set(name, value);%0A  %7D%0A  %0A  /**%0A   * Get metadata. See %7B@link Metadata#get(String)%7D for more information.%0A   * @param name%0A   * @return metadata value%0A   */%0A  public String getMeta(String name) %7B%0A    return metadata.get(name);%0A  %7D%0A  %0A  /**%0A   * Get multiple metadata. See %7B@link Metadata#getValues(String)%7D for more information.%0A   * @param name%0A   * @return multiple values%0A   */%0A  public String%5B%5D getMetaValues(String name) %7B%0A    return metadata.getValues(name);%0A  %7D%0A  %0A  public void readFields(DataInput in) throws IOException %7B%0A    super.readFields(in);%0A    metadata = new Metadata();%0A    metadata.readFields(in);%0A  %7D%0A%0A  public void write(DataOutput out) throws IOException %7B%0A    super.write(out);%0A    metadata.write(out);%0A  %7D%0A%7D

Add an ObjectWritable decorator.