org.onelab.filter
Class Key

java.lang.Object
  extended by org.onelab.filter.Key
All Implemented Interfaces:
Comparable, Writable, WritableComparable

public class Key
extends Object
implements WritableComparable

The general behavior of a key that must be stored in a filter.

See Also:
The general behavior of a filter

Constructor Summary
Key()
          default constructor - use with readFields
Key(byte[] value)
          Constructor.
Key(byte[] value, double weight)
          Constructor.
 
Method Summary
 int compareTo(Object o)
          
 boolean equals(Object o)
          
 byte[] getBytes()
           
 double getWeight()
           
 int hashCode()
          
 void incrementWeight()
          Increments the weight of this key by one.
 void incrementWeight(double weight)
          Increments the weight of this key with a specified value.
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Key

public Key()
default constructor - use with readFields


Key

public Key(byte[] value)
Constructor.

Builds a key with a default weight.

Parameters:
value - The byte value of this key.

Key

public Key(byte[] value,
           double weight)
Constructor.

Builds a key with a specified weight.

Parameters:
value - The value of this key.
weight - The weight associated to this key.
Method Detail

getBytes

public byte[] getBytes()
Returns:
byte[] The value of this key.

getWeight

public double getWeight()
Returns:
Returns the weight associated to this key.

incrementWeight

public void incrementWeight(double weight)
Increments the weight of this key with a specified value.

Parameters:
weight - The increment.

incrementWeight

public void incrementWeight()
Increments the weight of this key by one.


equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

write

public void write(DataOutput out)
           throws IOException
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Deserialize 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
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable


Copyright © 2006 The Apache Software Foundation