gov.nist.nlpir.irf.de
Class DePersonName

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

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

Instances of this class represent a person name. As with all other DataElems, comparison, exact matching and presentation features are provided.

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
private  java.lang.String firstName
          First name of the person name represented
(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  java.lang.String surname
          Last name of the person name represented
 
Constructor Summary
DePersonName(char[] sur)
          Builds a DePersonName considering the only array of characters given as the String representing the person's surname.
DePersonName(char[] first, char[] sur)
          Treats the two arrays of characters as Strings and creates the DePersonName associated.
DePersonName(java.lang.String sur)
          Builds a DePersonName assuming the only string given is the person's surname.
DePersonName(java.lang.String first, java.lang.String sur)
          Assigns first and last name.
 
Method Summary
 void addHTML(java.lang.StringBuffer baseString, int maxNrOfChar, boolean form)
          Adds the name and surname to the HTML text given.
 int compareTo(DataElem o)
          Scores the comparison between this and the given DePersonName
 boolean equals(java.lang.Object o)
          Does the same comparison as compareTo(), but gives a boolean result.
 boolean exactMatch(DataElem de)
          Compares this DePersonName to another.
 java.lang.String getFirstName()
          Retrieves the first name as a string.
 java.util.Vector getIndexingFeatures(ProxyDocument source, IndexingModalities im, DataElem field)
          Extract indexing features from this person name
 java.lang.String getSurname()
          Retrieves the surname as a string.
 java.lang.String getValueAsString()
          Gives the same result as toString().
 int hashCode()
          Overrides Object.hashCode(), based on the hashCoding of the surname.
 void HTML_ShowDoc(java.lang.StringBuffer baseString)
          Adds the name and surname of the person to the HTML string given (in this order).
 float match(DataElem de)
          Scores the match of this DePersonName with another Object.
 void present()
          Prints a presentation of the DePersonName like this: Name: myname FirstName: myfirstName
 void presentBrief()
          Here, the presentation is briefer than with present(): myfirstName myname,
 void setValue(java.lang.String first, java.lang.String sur)
          Sets the two main variables of the DePersonName.
 java.lang.String toString()
          Returns a string representation of the person name.
 
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

firstName

private java.lang.String firstName
First name of the person name represented

surname

private java.lang.String surname
Last name of the person name represented
Constructor Detail

DePersonName

public DePersonName(java.lang.String sur)
Builds a DePersonName assuming the only string given is the person's surname. The first name will be null.
Parameters:
sur - the surname of the person.

DePersonName

public DePersonName(char[] sur)
Builds a DePersonName considering the only array of characters given as the String representing the person's surname. The first name will be null.
Parameters:
sur - considered as a string, will be the last name of the person.

DePersonName

public DePersonName(java.lang.String first,
                    java.lang.String sur)
Assigns first and last name.
Parameters:
first - person's first name.
sur - person's surname.

DePersonName

public DePersonName(char[] first,
                    char[] sur)
Treats the two arrays of characters as Strings and creates the DePersonName associated.
Method Detail

getFirstName

public final java.lang.String getFirstName()
Retrieves the first name as a string.

getSurname

public final java.lang.String getSurname()
Retrieves the surname as a string.

setValue

public final void setValue(java.lang.String first,
                           java.lang.String sur)
Sets the two main variables of the DePersonName.

present

public void present()
Prints a presentation of the DePersonName like this:
 Name: myname
 FirstName: myfirstName
Specified by:
present in interface DataElem

presentBrief

public void presentBrief()
Here, the presentation is briefer than with present():
 myfirstName myname, 
Specified by:
presentBrief in interface DataElem

exactMatch

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

match

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

hashCode

public int hashCode()
Overrides Object.hashCode(), based on the hashCoding of the surname.
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

compareTo

public int compareTo(DataElem o)
Scores the comparison between this and the given DePersonName
Specified by:
compareTo in interface DataElem
Parameters:
o - the DePersonName this is compared to.
Returns:
the score as an int:
If surnames are not the same, returns the comparison between them.
If they are, returns the comparison between first names.
In every case, if o is not a DePersonName, returns 0.
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 DePersonName this is compared with.
Returns:
true if both their surnames and first names are equal,
false otherwise or if o is not a DePersonName.
Overrides:
equals in class java.lang.Object

getIndexingFeatures

public java.util.Vector getIndexingFeatures(ProxyDocument source,
                                            IndexingModalities im,
                                            DataElem field)
Extract indexing features from this person name
Specified by:
getIndexingFeatures in interface DataElem
Parameters:
source - 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:
collection of indexing features for data element.

getValueAsString

public final java.lang.String getValueAsString()
Gives the same result as toString().
Specified by:
getValueAsString in interface DataElem
Returns:
a string representation of teh person name.

toString

public final java.lang.String toString()
Returns a string representation of the person name.
Specified by:
toString in interface DataElem
Returns:
string representation of object.
surname, firstname
Overrides:
toString in class java.lang.Object

addHTML

public void addHTML(java.lang.StringBuffer baseString,
                    int maxNrOfChar,
                    boolean form)
Adds the name and surname 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.
maxNrOfChar - maximum number of characters added, used only if form is false.
form - true if the HTML code must be used in a form.
Returns:
the new HTML string.

HTML_ShowDoc

public void HTML_ShowDoc(java.lang.StringBuffer baseString)
Adds the name and surname of the person to the HTML string given (in this order).
Specified by:
HTML_ShowDoc in interface DataElem
Parameters:
baseString - the String the two names will be added.