net.obsearch.example.ted
Class OBTed

java.lang.Object
  extended by net.obsearch.example.ted.OBTed
All Implemented Interfaces:
OB, OBShort, Storable

public class OBTed
extends java.lang.Object
implements OBShort


Field Summary
protected  SliceForest tree
          The root node of the tree.
 
Constructor Summary
OBTed()
          Default constructor must be provided by every object that implements the interface OB.
OBTed(java.lang.String slice)
          Creates an slice object.
 
Method Summary
 short distance(OBShort object)
          Calculates the distance between two trees.
 boolean equals(java.lang.Object obj)
          Returns true of this.tree.equals(obj.tree).
 int hashCode()
          A hashCode based on the string representation of the tree.
 void load(byte[] in)
          Re-creates this object from the given byte stream
 int size()
          Returns the size (in nodes) of the tree.
 byte[] store()
          Stores this object into the given byte stream.
 java.lang.String toString()
           
protected  void updateTree(java.lang.String x)
          Internal method that updates the Tree from the String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

tree

protected SliceForest tree
The root node of the tree.

Constructor Detail

OBTed

public OBTed()
Default constructor must be provided by every object that implements the interface OB.


OBTed

public OBTed(java.lang.String slice)
      throws OBException
Creates an slice object.

Parameters:
slice - A string representation of a tree.
Throws:
OBException
Method Detail

distance

public final short distance(OBShort object)
                     throws OBException
Calculates the distance between two trees. TODO: traverse the smallest tree.

Specified by:
distance in interface OBShort
Parameters:
object - The other object to compare
Returns:
A short that indicates how similar or different the trees are.
Throws:
OBException - if something wrong happens.
See Also:
net.obsearch.OB#distance(net.obsearch.OB, net.obsearch.result.Dim)

updateTree

protected final void updateTree(java.lang.String x)
                         throws OBException
Internal method that updates the Tree from the String

Throws:
OBException

size

public final int size()
               throws OBException
Returns the size (in nodes) of the tree.

Returns:
The size of the tree.
Throws:
OBException - If something goes wrong.

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A String representation of the tree.

load

public final void load(byte[] in)
                throws OBException,
                       java.io.IOException
Re-creates this object from the given byte stream

Specified by:
load in interface Storable
Parameters:
in - A byte stream with the data that must be loaded.
Throws:
OBException - if the data cannot be loaded.
java.io.IOException
See Also:
net.obsearch.Storable#load(com.sleepycat.bind.tuple.TupleInput)

store

public final byte[] store()
                   throws java.io.IOException
Stores this object into the given byte stream.

Specified by:
store in interface Storable
Parameters:
out - The byte stream to be used
Throws:
java.io.IOException
See Also:
net.obsearch.Storable#store(com.sleepycat.bind.tuple.TupleOutput)

equals

public final boolean equals(java.lang.Object obj)
Returns true of this.tree.equals(obj.tree). For this distance function this.distance(obj) == 0 implies that this.equals(obj) == true

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare.
Returns:
true if this == obj

hashCode

public final int hashCode()
A hashCode based on the string representation of the tree.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code of the string representation of this tree.


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