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

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

public class DeIntern
extends java.lang.Object

Internal representation of a Data Element, this class, unlike DataElem, won't be inherited to describle every internal data element that may be encountered. This class is part of the PersistentDualKeyContainer scheme. It manages its own persistence mechanism with writeTo() and readFrom(). It could still be used with another scheme as it provides methods used by indexing and retrieving, for computation and storage of scores mainly.

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:
DataElem, PersistentDualKeyContainer

Field Summary
private  DataElem de
          A DataElem equivalent to all the DataElems this DeInterns represents.
private  boolean dirty
          A dirty bit for persistence purpose.
private  int nrOfSources
          Number of documents in which equivalent DataElements appear.
private  double score
          Score of the data element, calculated with different methods provided by the IdxIntern subclass used.
 
Constructor Summary
private DeIntern(BufferedRandomAccessFile in)
          This constructor is only used for persistence reasons.
  DeIntern(DataElem de)
          This constructor initializes the DeIntern to default values and positions the reference to the DataElem the DeIntern is linked to.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares this DeIntern to another object.
 void finalize()
          As a DeIntern maintains a reference to a ProxyDataElem, it needs a finalize() method to unregister from this Proxy.
 DataElem getDE()
          Retrieves the represented data element.
 int getFrequency(java.util.Vector features, int startIndex)
          Gives the number of times this appears in the given dictionary considered as a collection of DeIntern.
 int getNrOfSources()
          Gives the number of sources the internal data element appears in.
 double getScore()
          Gives the score of the represented data element.
 java.lang.String getValueAsString()
           
 int hashCode()
          Gives a hash code based on the value represented.
 boolean isDirty()
          Gets the dirty bit.
static DeIntern readFrom(BufferedRandomAccessFile in)
          The symmetric method of writeTo().
 void setDE(ProxyDataElem de)
          Sets the represented data element.
 void setNrOfSources(int i)
          Sets the number of sources to the value given.
 void setScore(double s)
          Sets the score of the data element linked to this.
 java.lang.String toString()
           
 void writeTo(BufferedRandomAccessFile out)
          Dematerializing method for the tuned serialization scheme used mainly by HashBlock.
 
Methods inherited from class java.lang.Object
, clone, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

nrOfSources

private int nrOfSources
Number of documents in which equivalent DataElements appear.

score

private double score
Score of the data element, calculated with different methods provided by the IdxIntern subclass used.
See Also:
IdxIntern

de

private DataElem de
A DataElem equivalent to all the DataElems this DeInterns represents.

dirty

private transient boolean dirty
A dirty bit for persistence purpose.
Constructor Detail

DeIntern

public DeIntern(DataElem de)
This constructor initializes the DeIntern to default values and positions the reference to the DataElem the DeIntern is linked to.

DeIntern

private DeIntern(BufferedRandomAccessFile in)
          throws java.io.IOException
This constructor is only used for persistence reasons. It is used by readFrom() to recreate the DeIntern from the file given as a parameter.
Method Detail

getValueAsString

public java.lang.String getValueAsString()
Returns:
only the representation of the internal data element.
caution: it is not the same function as toString().

toString

public java.lang.String toString()
Returns:
the representation of both the internal data element and the data element represented itself.
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Compares this DeIntern to another object. If the given object is a DeIntern, the function returns true if the represented DataElem are equals. If it is a data element, it returns true if this data element is the one represented by this DeIntern.
Returns:
true if the represented DataElem are equals
Overrides:
equals in class java.lang.Object
See Also:
ProxyDataElem.equals(java.lang.Object)

getDE

public final DataElem getDE()
Retrieves the represented data element.

setDE

public final void setDE(ProxyDataElem de)
Sets the represented data element.

getNrOfSources

public final int getNrOfSources()
Gives the number of sources the internal data element appears in.

setNrOfSources

public final void setNrOfSources(int i)
Sets the number of sources to the value given.

getScore

public final double getScore()
Gives the score of the represented data element.

setScore

public final void setScore(double s)
Sets the score of the data element linked to this.

getFrequency

public final int getFrequency(java.util.Vector features,
                              int startIndex)
Gives the number of times this appears in the given dictionary considered as a collection of DeIntern. Uses the values and doesn't compare the instances.
Parameters:
features - vector of indexing features.
startIndex - The index in the vector where the computation should start.
Returns:
frequency of this feature in supplied vector of indexing features.

hashCode

public final int hashCode()
Gives a hash code based on the value represented.
Overrides:
hashCode in class java.lang.Object

writeTo

public void writeTo(BufferedRandomAccessFile out)
             throws java.io.IOException
Dematerializing method for the tuned serialization scheme used mainly by HashBlock.

readFrom

public static DeIntern readFrom(BufferedRandomAccessFile in)
                         throws java.io.IOException
The symmetric method of writeTo().

isDirty

public final boolean isDirty()
Gets the dirty bit. Mainly used to know whether the DeIntern must be saved when it is dumped out of memory or not.

finalize

public void finalize()
As a DeIntern maintains a reference to a ProxyDataElem, it needs a finalize() method to unregister from this Proxy.
Overrides:
finalize in class java.lang.Object