edu.vt.marian.common
Class WtdEntireObj

java.lang.Object
  |
  +--edu.vt.marian.common.FullID
        |
        +--edu.vt.marian.common.WtdObj
              |
              +--edu.vt.marian.common.WtdEntireObj

public class WtdEntireObj
extends WtdObj

A Weighted Object that actually includes the full object! Unlike the class WtdObj, which only includes a FullID, a WtdEntireObj also includes a Java Object which is the actual instance selected by the FullID.

We actually use WtEntireObjs in two ways. In what might be thought of as the paradigmatic use, the Object is a digital information object and implements some sub-interface of DigInfObj. At several levels of MARIAN, however, this is overkill, and we simply need to more the raw object around, in the form of an unanalyzed string or stream, without creating a DigInfObj instance from it.


Field Summary
protected  boolean extracted
          whether obj is a raw string, or has been "extracted" and converted into a real DigInfObj.
static int NO_CAN_DO
           
protected  java.lang.Object obj
          either an object of class classID or a string from which such an object can be extracted.
static int OK
          return values of methods of this class
static int UNKNOWN_CLASS
           
 
Fields inherited from class edu.vt.marian.common.WtdObj
INVALID, weight
 
Fields inherited from class edu.vt.marian.common.FullID
BAD_PARAMS, classID, debug, instanceID, MAX_CLASS_ID, MAX_INSTANCE_ID, NULL_STREAM, OK
 
Constructor Summary
WtdEntireObj(java.io.BufferedReader br, Debug debug)
          method description: this constructor will create a WtdEntireObj object from the specified stream
WtdEntireObj(FullID id, Weight w, Document o, Debug debug)
          method description: this constructor will create a WtdEntireObj from the specified id, weight and document string uses the services of class(es):
 
Method Summary
 Document getDocument()
          return the (extracted) Document object.
 java.lang.String getRawObj()
          return the raw string of the document this object represents.
 int setDocument(Document o)
          set the entire object to (a clone of) an extracted object.
 int setRawObj(java.lang.String objectAsString)
          set this to a (non-extracted) String representation of the entire object.
 int toStream(java.io.PrintWriter pw)
          print the contents of this object to the specified stream.
 
Methods inherited from class edu.vt.marian.common.WtdObj
accum, accum, compare, compare, getID, getWeight, isValid, readPacked, scale, scale, toString, writePacked
 
Methods inherited from class edu.vt.marian.common.FullID
equals, getClassID, getInstanceID, hashCode, setClassID, setInstanceID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

obj

protected java.lang.Object obj
either an object of class classID or a string from which such an object can be extracted.

extracted

protected boolean extracted
whether obj is a raw string, or has been "extracted" and converted into a real DigInfObj.

OK

public static final int OK
return values of methods of this class

UNKNOWN_CLASS

public static final int UNKNOWN_CLASS

NO_CAN_DO

public static final int NO_CAN_DO
Constructor Detail

WtdEntireObj

public WtdEntireObj(java.io.BufferedReader br,
                    Debug debug)
method description: this constructor will create a WtdEntireObj object from the specified stream
Parameters:
br - the stream to read out this document
debug - used for debugging

WtdEntireObj

public WtdEntireObj(FullID id,
                    Weight w,
                    Document o,
                    Debug debug)
method description: this constructor will create a WtdEntireObj from the specified id, weight and document string

uses the services of class(es):

Parameters:
id - this will be the id of this document
w - this will be the weight at which this document corresponds to a query
o - the Object that id stands for.
debug - used for debugging
Method Detail

toStream

public int toStream(java.io.PrintWriter pw)
print the contents of this object to the specified stream.
Parameters:
pw - the stream to write this object
Returns:
OK -- this object has been written to the stream correctly
NULL_STREAM -- the parameter stream is null
Overrides:
toStream in class WtdObj

getRawObj

public java.lang.String getRawObj()
return the raw string of the document this object represents.
Returns:
this document as a string

setRawObj

public int setRawObj(java.lang.String objectAsString)
set this to a (non-extracted) String representation of the entire object.
Parameters:
objectAsString - a String from which the entire object can be built.
Returns:
OK -- the new raw marc record has been set correctly
BAD_PARAMS -- the parameter is null

NOTE: What if this is of class String? Then you should use setEntireObj() instead of setRaw() to avoid confusion.


setDocument

public int setDocument(Document o)
set the entire object to (a clone of) an extracted object.
Parameters:
o - the object corresponding to this.id.
Returns:
OK -- the new object has been set correctly
BAD_PARAMS -- the parameter is null

getDocument

public Document getDocument()
return the (extracted) Document object.
Returns:
(a reference to) an object implementing Document.