net.obsearch.result
Class OBResultByte<O>

java.lang.Object
  extended by net.obsearch.AbstractOBResult<O>
      extended by net.obsearch.result.OBResultByte<O>
All Implemented Interfaces:
Comparable

public final class OBResultByte<O>
extends AbstractOBResult<O>

This class is used to store a single match result. A single result consists of the object found, the distance of this object with the query and an internal id.

Since:
0.7
Author:
Arnoldo Jose Muller Molina

Field Summary
protected  byte distance
          Distance of the object found and the query.
 
Fields inherited from class net.obsearch.AbstractOBResult
id, object
 
Constructor Summary
OBResultByte()
          Default constructor.
OBResultByte(O object, long id, byte distance)
          Create a new OBResultByte.
 
Method Summary
 int compareTo(Object o)
          We implement the interface comparable so we provide this method.
 byte getDistance()
           
 void setDistance(byte x)
          Sets the distance to a new value x.
 String toString()
          Return a human readable representation of the object.
 
Methods inherited from class net.obsearch.AbstractOBResult
getId, getObject, setId, setObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

distance

protected byte distance
Distance of the object found and the query.

Constructor Detail

OBResultByte

public OBResultByte()
Default constructor. Used mostly to minimize the amount of object creations.


OBResultByte

public OBResultByte(O object,
                    long id,
                    byte distance)
Create a new OBResultByte.

Parameters:
object - the result found.
id - The internal id of the result.
distance - Distance of the result and the original query.
Method Detail

getDistance

public final byte getDistance()
Returns:
The distance of the result and the original query.

setDistance

public final void setDistance(byte x)
Sets the distance to a new value x.

Parameters:
x - The new value to set.

compareTo

public int compareTo(Object o)
We implement the interface comparable so we provide this method. The only difference is that we return bigger objects first. (The comparable contract is multiplied by -1)

Parameters:
o - The object that will be compared.
Returns:
1 if this object is smaller than o 0 if this object is equal than o -1 if this object is greater than o

toString

public String toString()
Return a human readable representation of the object.

Overrides:
toString in class Object
Returns:
a human readable representation of the object.


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.