CAR (Context-Aware Retrieval) v1.0

Class Value

java.lang.Object
  |
  +--Value
All Implemented Interfaces:
CarFace, java.io.Serializable

public class Value
extends java.lang.Object
implements java.io.Serializable, CarFace

A Value holds a value (string, numeric etc) that can take a variety of forms, see STICK-E NOTES: the Context Matcher User Manual (Brown) for a complete list.

To access an individual value it's necessary to first determine its type - this can be done with the int method getValType() which returns one of the following types: DOUBLE_LITERAL, STRING_LITERAL, STRINGVALUE_LITERAL, BOOLEAN_LITERAL (only used in the Session File), MARKUP. A STRING_LITERAL contains a string that originated in quotes (a quoted string), while a STRINGVALUE_LITERAL originated as an unquoted non-numeric non-boolean value. A MARKUP value is also a string that originated between MARKUP start/end tags. Each of these three string types can have embedded spaces. Once the type is known then an appropriate method can be called to extract the particular value e.g. getNumericValue().

However, for numeric values only (DOUBLE_LITERAL) it's also necessary to first check whether the value is a range value. The following are valid textual expressions of range values: '1.2..3.4' '..3.4' '1.2..' '..'. So a range value can have either or both values open-ended. To check for a range use the boolean method range(). To check whether the low value is open-ended use the boolean method isLowValueOpen() and similarly isHighValueOpen() for the high value. To get the low value use the double method getLowNumericValue() and similarly getHighNumericValue() for the high value (if low value is open the double of Math.MIN_VALUE is returned, if the high value is open the double of Math.MAX_VALUE is returned).

See the Basic Terminology section of the User Manual for a description of how a value fits into CAR's data structure.

See Also:
Serialized Form

Fields inherited from interface CarFace
BOOLEAN_LITERAL, COLLECTION, DOUBLE_LITERAL, EXTERNAL, grammarNames, INTERNAL, KEYPHRASE, LITERALcapacityIncrement, LITERALinitialCapacity, MARKUP, SERIAL, SESSION, STRING_LITERAL, STRINGVALUE_LITERAL
 
Constructor Summary
Value(java.lang.Double val)
          constructs a Value of type DOUBLE_LITERAL with the provided value double
Value(int vType, java.lang.Object val)
          constructs a non-range Value of the provided type and value
Value(int vType, java.lang.Object loV, java.lang.Object hiV)
          constructs a range Value of the provided type and low and high values
Value(int vType, java.lang.Object val, java.lang.String syval)
          constructs a non-range Value for numeric type with leading zero/s.
Value(java.lang.String val)
          constructs a Value of type STRINGVALUE_LITERAL with the provided value string
 
Method Summary
 java.lang.Object clone()
          gets a clone (copy) of this Value
 boolean getBooleanValue()
          for system programmer's use only
 double getHighNumericValue()
          returns the high numeric value of a range (Double.MAX_VALUE if high value is open)
 double getLowNumericValue()
          returns the low numeric value of a range (Double.MIN_VALUE if low value is open)
 double getNumericValue()
          returns the double value (low value if a range) of a numeric, else returns 0.0
 Value getStringedValue()
          returns the string if the Value is of type STRING_LITERAL, else returns null
 java.lang.String getStringValue()
          returns Value as a string value (low value if a range, Double.MIN_VALUE if low value is open).
 int getValType()
          gets the value type
 boolean isHighValueOpen()
          indicates whether the high numeric value of a range is open
 boolean isLowValueOpen()
          indicates whether the low numeric value of a range is open
 boolean range()
          indicates the Value is a range
 boolean sameValue(Value v)
          indicates whether this Value is the same value as the provided Value
 double score(Value query)
          An input query Value is 'scored' against a target Value.
 void setHiMax()
          set hiMax (a boolean indicating that the high value of a range is open)
 void setLoMin()
          set loMin (a boolean indicating that the low value of a range is open)
static void t(java.lang.String s)
          Provides trace output of string if -dValue on command line of CAR run
 java.lang.String toString()
          converts Value to a string.
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Value

public Value(int vType,
             java.lang.Object loV,
             java.lang.Object hiV)
constructs a range Value of the provided type and low and high values
Parameters:
vType - DOUBLE_LITERAL or BOOLEAN_LITERAL (only used in the Session File by system programmer)
loV - a Double or Boolean low value
hiV - a Double or Boolean high value

Value

public Value(int vType,
             java.lang.Object val)
constructs a non-range Value of the provided type and value
Parameters:
vType - one of the following types: DOUBLE_LITERAL, STRING_LITERAL, STRINGVALUE_LITERAL, BOOLEAN_LITERAL (only used in the Session File by system programmer), MARKUP
val - a Double, String. or Boolean value

Value

public Value(int vType,
             java.lang.Object val,
             java.lang.String syval)
constructs a non-range Value for numeric type with leading zero/s. This constructor is needed so that information about leading zeros is not lost e.g. for telephone or location numbers.
Parameters:
vType - must be DOUBLE_LITERAL
val - a Double
syval - a string representation of the value

Value

public Value(java.lang.String val)
constructs a Value of type STRINGVALUE_LITERAL with the provided value string

Value

public Value(java.lang.Double val)
constructs a Value of type DOUBLE_LITERAL with the provided value double
Method Detail

t

public static final void t(java.lang.String s)
Provides trace output of string if -dValue on command line of CAR run

clone

public java.lang.Object clone()
gets a clone (copy) of this Value
Overrides:
clone in class java.lang.Object

getValType

public final int getValType()
gets the value type
Returns:
one of DOUBLE_LITERAL, STRING_LITERAL, STRINGVALUE_LITERAL, BOOLEAN_LITERAL (only used in the Session File), MARKUP

setLoMin

public final void setLoMin()
set loMin (a boolean indicating that the low value of a range is open)

setHiMax

public final void setHiMax()
set hiMax (a boolean indicating that the high value of a range is open)

range

public final boolean range()
indicates the Value is a range

getBooleanValue

public final boolean getBooleanValue()
for system programmer's use only

getNumericValue

public final double getNumericValue()
returns the double value (low value if a range) of a numeric, else returns 0.0

getStringValue

public final java.lang.String getStringValue()
returns Value as a string value (low value if a range, Double.MIN_VALUE if low value is open). A numeric value is converted to its string equivalent

getStringedValue

public final Value getStringedValue()
returns the string if the Value is of type STRING_LITERAL, else returns null

getLowNumericValue

public final double getLowNumericValue()
returns the low numeric value of a range (Double.MIN_VALUE if low value is open)

getHighNumericValue

public final double getHighNumericValue()
returns the high numeric value of a range (Double.MAX_VALUE if high value is open)

isLowValueOpen

public final boolean isLowValueOpen()
indicates whether the low numeric value of a range is open

isHighValueOpen

public final boolean isHighValueOpen()
indicates whether the high numeric value of a range is open

sameValue

public final boolean sameValue(Value v)
indicates whether this Value is the same value as the provided Value

score

public final double score(Value query)
An input query Value is 'scored' against a target Value. Scores range from 0.0 to 2.0. The 'this' instance is the target, the argument is the query. Default rules are as follows.

toString

public java.lang.String toString()
converts Value to a string. The format of the string is consistent with the textual representation of a value, as read from file by CAR.
Overrides:
toString in class java.lang.Object
Returns:
a string represention of the Value.

CAR (Context-Aware Retrieval) v1.0

Submit bugs to Lindsey