gov.nist.nlpir.irf.de
Class DeDouble

java.lang.Object
  |
  +--gov.nist.nlpir.irf.InfoObj
        |
        +--gov.nist.nlpir.irf.de.DeDouble

public class DeDouble
extends InfoObj
implements java.io.Serializable, DataElem

Representation of a double as a DataElem. This class will allow the use doubles as data elements, and to index them so that queries can take them into account. As this class is concrete, all abstract methods of DataElem are implemented here.

Version:
$Revision: 1.3 $
Author:
This software was produced by NIST, an agency of the U.S. government, and by statute is not subject to copyright in the United States. Recipients of this software assume all responsibilities associated with its operation, modification and maintenance.
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
          serial version universal id - put here so Java does not insert one which may change due to revisions and make it impossible to deserialize earlier versions of serialized objects
private  double value
          The double this DeDouble represents.
 
Constructor Summary
DeDouble(double v)
          Builds a DeDouble that represents the given value.
DeDouble(java.lang.String v)
          Builds a DeDouble that represents the given value.
 
Method Summary
 void addHTML(java.lang.StringBuffer baseString, int i, boolean form)
          Adds the value to the HTML text given.
 int compareTo(DataElem o)
          Compares this DE-Double and the given DeDouble.
 boolean equals(java.lang.Object o)
          Compares DeDoubles as compareTo(), but gives a boolean result.
 boolean exactMatch(DataElem de)
          Compares this DeDouble to another.
 java.util.Vector getIndexingFeatures(ProxyDocument source, IndexingModalities im, DataElem field)
          Extract indexing features from this data element according to the indexing modalities
 double getValue()
          Returns the value of the represented double.
 java.lang.String getValueAsString()
          Returns a string representation of the double
 int hashCode()
          Redefines the default object.hashCode().
 void HTML_ShowDoc(java.lang.StringBuffer baseString)
          Appends the value to the given string in order to create an HTML doc.
 float match(DataElem de)
          Matches the score of this DeDouble with another Object.
 void present()
          Displays the represented value surrounded by spaces..
 void presentBrief()
          Same as present(), but with no space.
 void setValue(double v)
          Sets the value of the represented double
 java.lang.String toString()
          Returns string representation of the double
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
serial version universal id - put here so Java does not insert one which may change due to revisions and make it impossible to deserialize earlier versions of serialized objects

value

private double value
The double this DeDouble represents.
Constructor Detail

DeDouble

public DeDouble(double v)
Builds a DeDouble that represents the given value.
Parameters:
v - the value that the DeDouble will represent.

DeDouble

public DeDouble(java.lang.String v)
Builds a DeDouble that represents the given value.
Parameters:
v - the value that the DeDouble will represent - starting with a string
Method Detail

getValue

public final double getValue()
Returns the value of the represented double.
Returns:
the value of the represented double.

setValue

public final void setValue(double v)
Sets the value of the represented double
Parameters:
v - the new value the DeDouble represents.

present

public void present()
Displays the represented value surrounded by spaces..
Specified by:
present in interface DataElem

presentBrief

public void presentBrief()
Same as present(), but with no space.
Specified by:
presentBrief in interface DataElem

match

public float match(DataElem de)
Matches the score of this DeDouble with another Object. For the method to succeed, the object must be a DeDouble also.
Specified by:
match in interface DataElem
Parameters:
de - the DeDouble this is compared with.
Returns:
the score of the matching process.

exactMatch

public boolean exactMatch(DataElem de)
Compares this DeDouble to another. Definition would be ExactMatch(DeDouble) if java allowed it.
Specified by:
exactMatch in interface DataElem
Parameters:
de - the DeDouble this is compared with.
Returns:
true if the values are similar,
false otherwise or if de is not a DeDouble.

getIndexingFeatures

public java.util.Vector getIndexingFeatures(ProxyDocument source,
                                            IndexingModalities im,
                                            DataElem field)
Extract indexing features from this data element according to the indexing modalities
Specified by:
getIndexingFeatures in interface DataElem
Parameters:
s - source document of data element.
im - indexing modalities of index in which data element will be stored.
field - the document field from which this DE came
Returns:
Vector of indexing features for this.

getValueAsString

public final java.lang.String getValueAsString()
Returns a string representation of the double
Specified by:
getValueAsString in interface DataElem
Returns:
string representation of the double

toString

public final java.lang.String toString()
Returns string representation of the double
Specified by:
toString in interface DataElem
Returns:
string representation of teh double
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(DataElem o)
Compares this DE-Double and the given DeDouble.
Specified by:
compareTo in interface DataElem
Parameters:
o - the DeDouble this is compared to.
Returns:
the score as an int. It's the integer part of the difference between the two values. The result is Integer.MAX_VALUE if o2 is not a DeDouble.

equals

public boolean equals(java.lang.Object o)
Compares DeDoubles as compareTo(), but gives a boolean result.
Specified by:
equals in interface DataElem
Parameters:
o - the DeDouble this is compared with.
Returns:
true if their values are equal, of course,
false otherwise or if o2 is not a DeDouble.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Redefines the default object.hashCode(). The resulting hash code is based on the one of the represented double value.
Specified by:
hashCode in interface DataElem
Returns:
hash code of DeDouble, used for Index, and Hashtable
Overrides:
hashCode in class java.lang.Object
See Also:
Hashtable, Object

addHTML

public void addHTML(java.lang.StringBuffer baseString,
                    int i,
                    boolean form)
Adds the value to the HTML text given.
Specified by:
addHTML in interface DataElem
Parameters:
string - the HTML text the value will be appended to.
i - unused.
form - unused.

HTML_ShowDoc

public void HTML_ShowDoc(java.lang.StringBuffer baseString)
Appends the value to the given string in order to create an HTML doc.
Specified by:
HTML_ShowDoc in interface DataElem
Parameters:
baseString - the string which the value is added to.