All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.vt.marian.common.WtdObj

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

public class WtdObj
extends FullID
implements Sortable
An object together with a weight (e.g., match to a query).

See Also:
FullID, Weight, Sortable

Variable Index

 o debug
this is just used for debugging
 o INVALID
the methods' return values
 o weight
the weight value for this object.

Constructor Index

 o WtdObj(BufferedReader, Debug)
Create a WtdObj from an input stream.
 o WtdObj(Debug)
Create an invalid WtdObj.
 o WtdObj(FullID, Weight, Debug)
Create a WtdObj from a FullID and a Weight.
 o WtdObj(int, int, Weight, Debug)
Create a WtdObj from atomic values.
 o WtdObj(WtdObj, Debug)
Create a WtdObj equal to another WtdObj in all ways.

Method Index

 o accum(double)
"Add" a double between 0..1 to the weight of this WtdObj.
 o accum(Weight)
"Add" a Weight to the weight of this WtdObj.
 o compare(Object)
The functional union of compare(WtdObj) and compare(Weight).
 o compare(Weight)
How does this compare to a constant weight?
 o compare(WtdObj)
How does this compare to w by weight?
 o getID()
Return the id portion of this WtdObj.
 o getWeight()
Return the weight of this WtdObj.
 o isValid()
Indicate whether or not the this WtdObj is valid.
 o readPacked(ByteArrayInputStream)
Unpack a WtdObj from a Byte array of small, fixed size.
 o scale(double)
Scale the weight of this WtdObj by a double between 0..1.
 o scale(Weight)
Scale the weight of this WtdObj by a Weight.
 o toStream(PrintWriter)
Print the content of this object to a stream.
 o toString()
Create a human-readable string for this.
 o writePacked(ByteArrayOutputStream)
Pack a WtdObj into a Byte array of small, fixed size.

Variables

 o weight
 protected Weight weight
the weight value for this object.

 o INVALID
 public static final int INVALID
the methods' return values

 o debug
 protected Debug debug
this is just used for debugging

Constructors

 o WtdObj
 public WtdObj(Debug debug)
Create an invalid WtdObj.

Parameters:
debug - -- used for debugging
 o WtdObj
 public WtdObj(WtdObj w,
               Debug debug)
Create a WtdObj equal to another WtdObj in all ways.

Parameters:
w - -- the WtdObj to be copied
debug - -- used for debugging
 o WtdObj
 public WtdObj(FullID id,
               Weight wt,
               Debug debug)
Create a WtdObj from a FullID and a Weight.

Parameters:
id - -- the (full) ID of this object;
wt - -- the weight assigned to this object;
debug - -- used for debugging
 o WtdObj
 public WtdObj(int clID,
               int instID,
               Weight wt,
               Debug debug)
Create a WtdObj from atomic values.

Parameters:
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
 o WtdObj
 public WtdObj(BufferedReader br,
               Debug debug)
Create a WtdObj from an input stream.

Parameters:
br - -- the stream from which to read out this object;
debug - -- used for debugging

Methods

 o isValid
 public boolean isValid()
Indicate whether or not the this WtdObj is valid.

Returns:
true / false
Overrides:
isValid in class FullID
 o compare
 public int compare(WtdObj w)
How does this compare to w by weight?

Parameters:
w - -- another WtdObj
Returns:
(< 0) lower weight
(== 0) same weight
(> 0) higher weight
 o compare
 public int compare(Weight wt)
How does this compare to a constant weight?

Parameters:
wt - -- a constant Weight
Returns:
(< 0) lower weight
(== 0) same weight
(> 0) higher weight
 o compare
 public int compare(Object obj)
The functional union of compare(WtdObj) and compare(Weight).

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

Parameters:
wt - -- the value to scale by.
 o scale
 public void scale(double f)
Scale the weight of this WtdObj by a double between 0..1.

Parameters:
f - -- the value to scale by.
 o accum
 public void accum(Weight wt)
"Add" a Weight to the weight of this WtdObj.

Parameters:
wt - -- the value to scale by.
 o accum
 public void accum(double f)
"Add" a double between 0..1 to the weight of this WtdObj.

Parameters:
f - -- the value to scale by.
 o getWeight
 public Weight getWeight()
Return the weight of this WtdObj.

Returns:
the value of this WtdObj as a (new) Weight.
 o getID
 public FullID getID()
Return the id portion of this WtdObj.

Returns:
the value of this WtdObj as a (new) FullID.
 o writePacked
 public int writePacked(ByteArrayOutputStream s)
Pack a WtdObj into a Byte array of small, fixed size.

Parameters:
s - -- the ByteArrayOutputStream into which to pack this.
Returns:
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. %lt;Wt>%lt;ClID>%lt;InstID>.

Overrides:
writePacked in class FullID
 o readPacked
 public int readPacked(ByteArrayInputStream s)
Unpack a WtdObj from a Byte array of small, fixed size.

Parameters:
s - -- the ByteArrayInputStream from which to unpack this.
Returns:
OK, NULL_STREAM, or INVALID

FORMAT: see writePacked().

Overrides:
readPacked in class FullID
 o toStream
 public int toStream(PrintWriter pw)
Print the content of this object to a stream.

Parameters:
pw - -- the stream to write this object
Returns:
OK -- the object has been written to the stream correctly
NULL_STREAM -- the parameter stream is null
Overrides:
toStream in class FullID
 o toString
 public String toString()
Create a human-readable string for this.

Returns:
A string of the format #classID:instanceID:weight# for any valid object, or @null@ for an invalid one.
Overrides:
toString in class FullID

All Packages  Class Hierarchy  This Package  Previous  Next  Index