gov.nist.nlpir.irf.de
Class DeString

java.lang.Object
  |
  +--gov.nist.nlpir.irf.InfoObj
        |
        +--gov.nist.nlpir.irf.de.DeString
Direct Known Subclasses:
DeHtml

public class DeString
extends InfoObj
implements DataElem

Representation of a string as a DataElem.

This class will allow the use of strings 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. This class is mainly composed of a String. It is the string that a DeString object will refer to.

Version:
$Revision: 1.2 $
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.

Field Summary
protected static java.lang.String DELIMITERS
          Working constant for use in tokenizing strings
protected static Stemmer stemmer
          Working local alias for global stemmer to avoid repeated method calls
protected static StopWordTable stopWordTable
          Working local alias for global stop word table to avoid repeated method calls
protected  java.lang.String value
          The string which this class models
 
Constructor Summary
DeString(char[] v)
          Creates a DeString that refers to the given array of characters considered as a String.
DeString(java.lang.String v)
          Creates a DeString that refers to the given String.
 
Method Summary
 void addHTML(java.lang.StringBuffer baseString, int maxNumberOfChar, boolean form)
          Adds the string to the HTML text given.
 int compareTo(DataElem o)
          Scores the comparison between this and the given DeString
 boolean equals(java.lang.Object o)
          Does the same comparison as compareTo(), but gives a boolean result.
 boolean exactMatch(DataElem de)
          Compares this DeString to another.
 java.util.Vector getIndexingFeatures(ProxyDocument source, IndexingModalities im, DataElem field)
          Extracts Indexing Features from DeString.
 java.lang.String getValue()
          Retrieves the value of the represented String.
 java.lang.String getValueAsString()
          Returns the value of the represented string
 int hashCode()
          Computes a hash code for the DE_string based on the hashCode of the represented String.
 void HTML_ShowDoc(java.lang.StringBuffer baseString)
          Adds the value of the string between H1 tags to the given string.
 float match(DataElem de)
          Scores the match of this DeString with another Object.
 void present()
          Prints the represented String with a space before and a comma after.
 void presentBrief()
          Prints the value of the String.
 void setValue(char[] v)
          Sets the value of the represented String with the given array of chars.
 void setValue(java.lang.String v)
          Sets the value of the represented String.
 java.lang.String toString()
          Same as getValueAsString().
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

value

protected java.lang.String value
The string which this class models

stemmer

protected static final Stemmer stemmer
Working local alias for global stemmer to avoid repeated method calls

DELIMITERS

protected static final java.lang.String DELIMITERS
Working constant for use in tokenizing strings

stopWordTable

protected static final StopWordTable stopWordTable
Working local alias for global stop word table to avoid repeated method calls
Constructor Detail

DeString

public DeString(java.lang.String v)
Creates a DeString that refers to the given String.

DeString

public DeString(char[] v)
Creates a DeString that refers to the given array of characters considered as a String.
Method Detail

getValue

public final java.lang.String getValue()
Retrieves the value of the represented String.

setValue

public final void setValue(java.lang.String v)
Sets the value of the represented String.
Parameters:
v - the new value of the String.

setValue

public final void setValue(char[] v)
Sets the value of the represented String with the given array of chars.
Parameters:
v - the new value of the String.

getValueAsString

public final java.lang.String getValueAsString()
Returns the value of the represented string
Specified by:
getValueAsString in interface DataElem
Returns:
the value of the represented string.

toString

public final java.lang.String toString()
Same as getValueAsString().
Specified by:
toString in interface DataElem
Overrides:
toString in class java.lang.Object

present

public void present()
Prints the represented String with a space before and a comma after.
Specified by:
present in interface DataElem

presentBrief

public void presentBrief()
Prints the value of the String.
Specified by:
presentBrief in interface DataElem

exactMatch

public boolean exactMatch(DataElem de)
Compares this DeString to another.
Specified by:
exactMatch in interface DataElem
Parameters:
de - the DeString this is compared with.
Returns:
true if both represented Strings are the same,
false otherwise or if de is not a DeString.

match

public float match(DataElem de)
Scores the match of this DeString with another Object. For the function to succeed, the object must be a DeString also. Actually the result is 1 if the two objects exactly match, ie the Strings they represent are exactly the same, 0 otherwise.
Specified by:
match in interface DataElem
Parameters:
de - the DeString this is compared with.
Returns:
the score of the matching process.

compareTo

public int compareTo(DataElem o)
Scores the comparison between this and the given DeString
Specified by:
compareTo in interface DataElem
Parameters:
o - the DeString this is compared to.
Returns:
the score as an int: the result is the comparison between the o2 String value and the value of this. Returns Integer.MAX_VALUE if o2 is not a DeString.
See Also:
String.compareTo(java.lang.Object)

equals

public boolean equals(java.lang.Object o)
Does the same comparison as compareTo(), but gives a boolean result.
Specified by:
equals in interface DataElem
Parameters:
o - the DeString this is compared with.
Returns:
true if both Strings are equal,
false otherwise or if o is not a DeString.
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Computes a hash code for the DE_string based on the hashCode of the represented String.
Specified by:
hashCode in interface DataElem
Returns:
hash code for use in java.util.Hashtable.
Overrides:
hashCode in class java.lang.Object

getIndexingFeatures

public java.util.Vector getIndexingFeatures(ProxyDocument source,
                                            IndexingModalities im,
                                            DataElem field)
Extracts Indexing Features from DeString.
Specified by:
getIndexingFeatures in interface DataElem
Parameters:
source - object reference of source document.
im - indexing modalities to be used with this DeString.
field - the document field from which this DE came
Returns:
vector of IndexingFeatures.

addHTML

public void addHTML(java.lang.StringBuffer baseString,
                    int maxNumberOfChar,
                    boolean form)
Adds the string to the HTML text given. If it is to be read in a form, the HTML code will allow the entry of values.
Specified by:
addHTML in interface DataElem
Parameters:
baseString - the HTML text the value will be appended to.
maxNumberOfChar - maximum number of characters added, used only if form is false.
form - true if the HTML code must be used in a form, false otherwise.
Returns:
the new HTML string.

HTML_ShowDoc

public void HTML_ShowDoc(java.lang.StringBuffer baseString)
Adds the value of the string between H1 tags to the given string.
Specified by:
HTML_ShowDoc in interface DataElem