edu.vt.marian.common
Class WtdObj

java.lang.Object
  |
  +--edu.vt.marian.common.FullID
        |
        +--edu.vt.marian.common.WtdObj
Direct Known Subclasses:
WtdEntireObj

public class WtdObj
extends FullID

class name: WtdObj

class description: an object together with a weight (e.g., match to a query).

uses the services of class(es):

designer(s): Robert France (france@vt.edu)

implementator(s): Robert France

finished time:

known bugs:

JDK version: 1.1.5

side effects:


Field Summary
static int INVALID
          the methods' return values
protected  Weight weight
          the weight value for this object.
 
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
WtdObj(java.io.BufferedReader br, Debug debug)
          method description: Create a WtdObj from an input stream.
WtdObj(Debug debug)
          method description: Create an invalid WtdObj.
WtdObj(FullID id, Weight wt, Debug debug)
          method description: Create a WtdObj from a FullID and a Weight.
WtdObj(int clID, int instID, Weight wt, Debug debug)
          method description: Create a WtdObj from atomic values.
WtdObj(WtdObj w, Debug debug)
          method description: Create a WtdObj equal to another WtdObj in all ways.
 
Method Summary
 void accum(double f)
          method description: "Add" a double between 0..1 to the weight of this WtdObj.
 void accum(Weight wt)
          method description: "Add" a Weight to the weight of this WtdObj.
 int compare(Weight wt)
           
 int compare(WtdObj w)
           
 FullID getID()
          method description: Return the id portion of this WtdObj.
 Weight getWeight()
          method description: Return the weight of this WtdObj.
 boolean isValid()
          method description: Indicate whether or not the this WtdObj is valid.
 int readPacked(java.io.ByteArrayInputStream s)
          method description: Unpack a WtdObj from a Byte array of small, fixed size.
 void scale(double f)
          method description: Scale the weight of this WtdObj by a double between 0..1.
 void scale(Weight wt)
          method description: Scale the weight of this WtdObj by a Weight.
 int toStream(java.io.PrintWriter pw)
          method description: Print the content of this object to a stream.
 java.lang.String toString()
          method description: Create a human-readable string for this.
 int writePacked(java.io.ByteArrayOutputStream s)
          method description: Pack a WtdObj into a Byte array of small, fixed size.
 
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

weight

protected Weight weight
the weight value for this object.

INVALID

public static final int INVALID
the methods' return values
Constructor Detail

WtdObj

public WtdObj(Debug debug)
method description: Create an invalid WtdObj.

uses the services of class(es): none

input parameter(s): debug -- used for debugging

output parameter(s): none

return value: none


WtdObj

public WtdObj(WtdObj w,
              Debug debug)
method description: Create a WtdObj equal to another WtdObj in all ways.

uses the services of class(es): none

input parameter(s): w -- the WtdObj to be copied debug -- used for debugging

output parameter(s): none

return value: none


WtdObj

public WtdObj(FullID id,
              Weight wt,
              Debug debug)
method description: Create a WtdObj from a FullID and a Weight.

uses the services of class(es): none

input parameter(s): id -- the (full) ID of this object; wt -- the weight assigned to this object; debug -- used for debugging

output parameter(s): none

return value: none


WtdObj

public WtdObj(int clID,
              int instID,
              Weight wt,
              Debug debug)
method description: Create a WtdObj from atomic values.

uses the services of class(es): none

input parameter(s): clID -- the class ID of this object; instID -- the instance ID of this object; wt -- the weight assigned to this object; debug -- used for debugging

output parameter(s): none

return value: none


WtdObj

public WtdObj(java.io.BufferedReader br,
              Debug debug)
method description: Create a WtdObj from an input stream.

uses the services of class(es):

input parameter(s): br -- the stream from which to read out this object; debug -- used for debugging

output parameter(s): none

return value: none

Method Detail

isValid

public boolean isValid()
method description: Indicate whether or not the this WtdObj is valid.

uses the services of class(es): none

input parameter(s): none

output parameter(s): none

return value: true / false

Overrides:
isValid in class FullID

compare

public int compare(WtdObj w)

compare

public int compare(Weight wt)

scale

public void scale(Weight wt)
method description: Scale the weight of this WtdObj by a Weight.

uses the services of class(es): none

input parameter(s): wt -- the value to scale by.

output parameter(s): none

return value: none


scale

public void scale(double f)
method description: Scale the weight of this WtdObj by a double between 0..1.

uses the services of class(es): none

input parameter(s): f -- the value to scale by.

output parameter(s): none

return value: none


accum

public void accum(Weight wt)
method description: "Add" a Weight to the weight of this WtdObj.

uses the services of class(es): none

input parameter(s): wt -- the value to scale by.

output parameter(s): none

return value: none


accum

public void accum(double f)
method description: "Add" a double between 0..1 to the weight of this WtdObj.

uses the services of class(es): none

input parameter(s): f -- the value to scale by.

output parameter(s): none

return value: none


getWeight

public Weight getWeight()
method description: Return the weight of this WtdObj.

uses the services of class(es): none

input parameter(s): none

output parameter(s): none

return value: the value of this WtdObj as a (new) Weight.


getID

public FullID getID()
method description: Return the id portion of this WtdObj.

uses the services of class(es): none

input parameter(s): none

output parameter(s): none

return value: the value of this WtdObj as a (new) FullID.


writePacked

public int writePacked(java.io.ByteArrayOutputStream s)
method description: Pack a WtdObj into a Byte array of small, fixed size.

uses the services of class(es): none

input parameter(s): s -- the ByteArrayOutputStream into which to pack this.

output parameter(s): s -- the ByteArrayOutputStream, with this packed in.

return value: OK or INVALID

FORMAT: classID and weight by design will each fit into two bytes. To minimize allignment problems, we pack those two first and the four-byte instanceID last. .

Overrides:
writePacked in class FullID

readPacked

public int readPacked(java.io.ByteArrayInputStream s)
method description: Unpack a WtdObj from a Byte array of small, fixed size.

uses the services of class(es): none

input parameter(s): s -- the ByteArrayInputStream from which to unpack this.

output parameter(s): none.

return value: OK, NULL_STREAM, or INVALID

FORMAT: see writePacked().

Overrides:
readPacked in class FullID

toStream

public int toStream(java.io.PrintWriter pw)
method description: Print the content of this object to a stream.

uses the services of class(es):

input parameter(s): pw -- the stream to write this object

output parameter(s): none

return value: OK -- the object has been written to the stream correctly NULL_STREAM -- the parameter stream is null

Overrides:
toStream in class FullID

toString

public java.lang.String toString()
method description: Create a human-readable string for this.

uses the services of class(es):

input parameter(s): none

output parameter(s): none

return value: A string of the format #classID:instanceID:weight# for any valid object, or @null@ for an invalid one.

Overrides:
toString in class FullID