gov.nist.nlpir.irf.index.braf
Class IoAddrIntern

java.lang.Object
  |
  +--gov.nist.nlpir.irf.index.braf.IoAddrIntern

public class IoAddrIntern
extends java.lang.Object

This class is the internal representation of a source, ie a document. It will be used as a key in the different indexes, but it also embeds information only used by indexes for retrieval: for instance, the score of the document, calculated by every index in a manner given by the index (IDF, keyword, ...), and the number of features this source refers to (in a text application, for example, the number of indexed terms found in this source for the considered fields -depending on the index). This class has been designed to be used in close conjunction with PersistentDualKeyContainer; it manages its own persistence mechanism, exactly like DeIntern. It may still be used in a different scheme in order to take advantage of the already implemented methods in IdxIntern and its subclasses without having to change them.

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.
See Also:
DeIntern, PersistentDualKeyContainer

Field Summary
private  boolean dirty
          Dirty bit.
private  ProxyDocument doc
          The actual source this IoAddrIntern deals with.
private  int nrOfFeatures
          Number of features found in the considered source.
private  double score
          Score of this source, computed with an index-dependant heuristic.
 
Constructor Summary
private IoAddrIntern(BufferedRandomAccessFile in)
          This constructor is only called by readFrom().
  IoAddrIntern(ProxyDocument doc)
          Constructor which initializes the source to doc, nrOfFeatures to 0 and score to 0.0.
 
Method Summary
 boolean equals(java.lang.Object o)
          Completely overrides the equals in Object so that it is the one called by Hashtable for example.
 void finalize()
          As this class contains a reference to a proxy, it needs a finalize method to complete housekeeping about references to proxies.
 ProxyDocument getDoc()
          Returns the ProxyDocument of the IoAddrIntern.
 int getNrOfFeatures()
          Returns the number of features of the IoAddrIntern.
 double getScore()
          Returns the score of the IoAddrIntern.
 int hashCode()
          Gives a hashcode based on the source document, otherwise indexing would encounter problems (features of the same source not indexed as being in the same source).
Note: The default hashCode can only be accessed via super.hashCode().
 boolean isDirty()
          Returns the dirty bit status.
static IoAddrIntern readFrom(BufferedRandomAccessFile in)
          Tuned deserialization mechanism.
 void setDoc(ProxyDocument doc)
          Sets the ProxyDocument of the IoAddrIntern.
 void setNrOfFeatures(int n)
          Sets the number of features of the IoAddrIntern to the supplied value.
 void setScore(double s)
          Sets the score of the IoAddrIntern to the supplied value.
 java.lang.String toString()
          Generates the string representation of this IoAddrIntern.
 void writeTo(BufferedRandomAccessFile out)
          Tuned serialization mechanism.
 
Methods inherited from class java.lang.Object
, clone, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

nrOfFeatures

private int nrOfFeatures
Number of features found in the considered source.

score

private double score
Score of this source, computed with an index-dependant heuristic.

doc

private ProxyDocument doc
The actual source this IoAddrIntern deals with.

dirty

private transient boolean dirty
Dirty bit.
Constructor Detail

IoAddrIntern

public IoAddrIntern(ProxyDocument doc)
Constructor which initializes the source to doc, nrOfFeatures to 0 and score to 0.0.
Parameters:
anIO_Addr - a ProxyDocument.

IoAddrIntern

private IoAddrIntern(BufferedRandomAccessFile in)
              throws java.io.IOException
This constructor is only called by readFrom().
Method Detail

getScore

public final double getScore()
Returns the score of the IoAddrIntern.
Returns:
the score.

getNrOfFeatures

public final int getNrOfFeatures()
Returns the number of features of the IoAddrIntern.
Returns:
the number of features

setNrOfFeatures

public final void setNrOfFeatures(int n)
Sets the number of features of the IoAddrIntern to the supplied value.
Parameters:
n - number of features.

setScore

public final void setScore(double s)
Sets the score of the IoAddrIntern to the supplied value.
Parameters:
s - the score

getDoc

public final ProxyDocument getDoc()
Returns the ProxyDocument of the IoAddrIntern.
Returns:
the doc

setDoc

public final void setDoc(ProxyDocument doc)
Sets the ProxyDocument of the IoAddrIntern.

toString

public java.lang.String toString()
Generates the string representation of this IoAddrIntern.
Returns:
A string containing the number of features, score, doc and addr fields.
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Gives a hashcode based on the source document, otherwise indexing would encounter problems (features of the same source not indexed as being in the same source).
Note: The default hashCode can only be accessed via super.hashCode().
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Completely overrides the equals in Object so that it is the one called by Hashtable for example.
Returns:
true only if the given object is a IoAddrIntern and concerns the same document (instance comparison, assumes there is only one instance for a given document).
Overrides:
equals in class java.lang.Object

writeTo

public void writeTo(BufferedRandomAccessFile out)
             throws java.io.IOException
Tuned serialization mechanism. Uses the IdxFeatBrafBroker methods to write the correct information.

readFrom

public static IoAddrIntern readFrom(BufferedRandomAccessFile in)
                             throws java.io.IOException
Tuned deserialization mechanism. Also needs the IdxFeatBrafBroker mechanism to be able to read a IoAddrIntern back from disk.

isDirty

public final boolean isDirty()
Returns the dirty bit status.

finalize

public void finalize()
As this class contains a reference to a proxy, it needs a finalize method to complete housekeeping about references to proxies.
Overrides:
finalize in class java.lang.Object