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
-
debug
- this is just used for debugging
-
INVALID
- the methods' return values
-
weight
- the weight value for this object.
-
WtdObj(BufferedReader, Debug)
- Create a WtdObj from an input stream.
-
WtdObj(Debug)
- Create an invalid WtdObj.
-
WtdObj(FullID, Weight, Debug)
- Create a WtdObj from a FullID and a Weight.
-
WtdObj(int, int, Weight, Debug)
- Create a WtdObj from atomic values.
-
WtdObj(WtdObj, Debug)
- Create a WtdObj equal to another WtdObj in all ways.
-
accum(double)
- "Add" a double between 0..1 to the weight of this WtdObj.
-
accum(Weight)
- "Add" a Weight to the weight of this WtdObj.
-
compare(Object)
- The functional union of compare(WtdObj) and compare(Weight).
-
compare(Weight)
- How does this compare to a constant weight?
-
compare(WtdObj)
- How does this compare to w by weight?
-
getID()
- Return the id portion of this WtdObj.
-
getWeight()
- Return the weight of this WtdObj.
-
isValid()
- Indicate whether or not the this WtdObj is valid.
-
readPacked(ByteArrayInputStream)
- Unpack a WtdObj from a Byte array of small, fixed size.
-
scale(double)
- Scale the weight of this WtdObj by a double between 0..1.
-
scale(Weight)
- Scale the weight of this WtdObj by a Weight.
-
toStream(PrintWriter)
- Print the content of this object to a stream.
-
toString()
- Create a human-readable string for this.
-
writePacked(ByteArrayOutputStream)
- Pack a WtdObj into a Byte array of small, fixed size.
weight
protected Weight weight
- the weight value for this object.
INVALID
public static final int INVALID
- the methods' return values
debug
protected Debug debug
- this is just used for debugging
WtdObj
public WtdObj(Debug debug)
- Create an invalid WtdObj.
- Parameters:
- debug - -- used for debugging
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
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
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
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
isValid
public boolean isValid()
- Indicate whether or not the this WtdObj is valid.
- Returns:
- true / false
- Overrides:
- isValid in class FullID
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
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
compare
public int compare(Object obj)
- The functional union of compare(WtdObj) and compare(Weight).
scale
public void scale(Weight wt)
- Scale the weight of this WtdObj by a Weight.
- Parameters:
- wt - -- the value to scale by.
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.
accum
public void accum(Weight wt)
- "Add" a Weight to the weight of this WtdObj.
- Parameters:
- wt - -- the value to scale by.
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.
getWeight
public Weight getWeight()
- Return the weight of this WtdObj.
- Returns:
- the value of this WtdObj as a (new) Weight.
getID
public FullID getID()
- Return the id portion of this WtdObj.
- Returns:
- the value of this WtdObj as a (new) FullID.
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
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
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
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