gov.nist.nlpir.irf.de
Class DeInteger

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

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

Representation of a integer as a DataElem.

This class will allow the use of integers as data elements and indexing 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  int value
          The value represented by this DeInteger.
 
Constructor Summary
DeInteger(int v)
          Creates a DeInteger that represents the given integer.
DeInteger(java.lang.String v)
          Creates a DeInteger that represents the given integer.
 
Method Summary
 void addHTML(java.lang.StringBuffer baseString, int i, boolean form)
          Appends the string representation of this to the given HTML text.
Caution: string is modified by this function.
 int compareTo(DataElem o)
          Computes the difference between this and the given DeInteger.
 boolean equals(java.lang.Object o)
          Tests whether two DeIntegers have the same value.
 boolean exactMatch(DataElem de)
          Compares the values of this and the given DeInteger and sets the result.
 java.util.Vector getIndexingFeatures(ProxyDocument source, IndexingModalities im, DataElem field)
          Gets the (actually unique) indexing feature of this DeInteger.
 int getValue()
          Returns the value of the represented integer
 java.lang.String getValueAsString()
          Returns a string representation of the integer
 int hashCode()
          Redefines the default Object.hashCode().
 void HTML_ShowDoc(java.lang.StringBuffer baseString)
          Appends a string representation of this to the given string.
 float match(DataElem de)
          Computes the matching score between this and the given DeInteger.
 void present()
          Prints the value of the represented integer.
 void presentBrief()
          Exactly the same thing as present(): prints the value.
 void setValue(int v)
          Sets the value of the represented integer
 java.lang.String toString()
          Returns a string representation of the integer
 
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 int value
The value represented by this DeInteger.
Constructor Detail

DeInteger

public DeInteger(int v)
Creates a DeInteger that represents the given integer.
Parameters:
v - the value of the represented integer.

DeInteger

public DeInteger(java.lang.String v)
Creates a DeInteger that represents the given integer.
Parameters:
v - the value of the integer as a string.
Method Detail

getValue

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

setValue

public final void setValue(int v)
Sets the value of the represented integer
Parameters:
v - the new value of the represented integer.

present

public void present()
Prints the value of the represented integer.
Specified by:
present in interface DataElem

presentBrief

public void presentBrief()
Exactly the same thing as present(): prints the value.
Specified by:
presentBrief in interface DataElem

getValueAsString

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

toString

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

getIndexingFeatures

public java.util.Vector getIndexingFeatures(ProxyDocument source,
                                            IndexingModalities im,
                                            DataElem field)
Gets the (actually unique) indexing feature of this DeInteger.
Specified by:
getIndexingFeatures in interface DataElem
Parameters:
source - the Document from which the integer was read.
im - the controling indexing modalities
field - the document field from which this DE came
Returns:
a vector with one element: an indexing feature linking a String representing the value of this to an internal address linking this to the given Document.

exactMatch

public boolean exactMatch(DataElem de)
Compares the values of this and the given DeInteger and sets the result.
Specified by:
exactMatch in interface DataElem
Parameters:
de - the DeInteger this is compared to.
Returns:
true if this and de have the same value,
false otherwise or if de is not a DeInteger.

match

public float match(DataElem de)
Computes the matching score between this and the given DeInteger. Actually, it's 1 if both DeIntegers have the same value, 0 otherwise.
Specified by:
match in interface DataElem
Parameters:
de - the DeInteger this is compared to.
Returns:
1 if this and de have the same value,
0 otherwise.

compareTo

public int compareTo(DataElem o)
Computes the difference between this and the given DeInteger. The result is the mathematically defined difference.
Specified by:
compareTo in interface DataElem
Parameters:
o - the DeInteger this is compared to.
Returns:
the difference between this and compareTo, Integer.MAX_VALUE if compareTo is not a DeInteger.

equals

public boolean equals(java.lang.Object o)
Tests whether two DeIntegers have the same value. The result is true if both DeIntegers have the same value.
Specified by:
equals in interface DataElem
Parameters:
compareToObj - the DeInteger this is compared to.
Returns:
true if this and compareTo have the same value,
false otherwise.
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Redefines the default Object.hashCode().
Specified by:
hashCode in interface DataElem
Returns:
hash code of DeInteger, 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)
Appends the string representation of this to the given HTML text.
Caution: string is modified by this function.
Specified by:
addHTML in interface DataElem
Parameters:
baseString - the text to be extended by this. Caution: string itself is modified.
i - not used.
form - not used.
Returns:
the new string.

HTML_ShowDoc

public void HTML_ShowDoc(java.lang.StringBuffer baseString)
Appends a string representation of this to the given string.
Specified by:
HTML_ShowDoc in interface DataElem
Parameters:
baseString - the string to be completed.