net.sf.saxon.value
Class BooleanValue

java.lang.Object
  extended by net.sf.saxon.value.Value
      extended by net.sf.saxon.value.AtomicValue
          extended by net.sf.saxon.value.BooleanValue
All Implemented Interfaces:
Serializable, Comparable, Expression, Item

public final class BooleanValue
extends AtomicValue
implements Comparable

A boolean XPath value

See Also:
Serialized Form

Field Summary
static BooleanValue FALSE
          The boolean value FALSE
static BooleanValue TRUE
          The boolean value TRUE
 
Method Summary
 int compareTo(Object other)
          Compare the value to another boolean value
 int conversionPreference(Class required)
          Get conversion preference for this value to a Java class.
 AtomicValue convert(int requiredType)
          Convert to target data type
 Object convertToJava(Class target)
          Convert to Java object (for passing to external functions)
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of this expression
 boolean equals(Object other)
          Determine whether two boolean values are equal
static BooleanValue get(boolean value)
          Factory method: get a BooleanValue
 ItemType getItemType()
          Determine the data type of the expression
 String getStringValue()
          Convert to string
 boolean getValue()
          Get the value
 int hashCode()
          Get a hash code for comparing two BooleanValues
 String toString()
          Diagnostic display of this value as a string
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, convert, evaluateAsString, evaluateItem, getCardinality, getComponent, getPrimitiveValue, getTypedValue, iterate
 
Methods inherited from class net.sf.saxon.value.Value
analyze, asItem, asValue, collapseWhitespace, getDependencies, getSpecialProperties, getSubExpressions, inverse, normalizeWhitespace, promote, simplify, stringToInteger, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final BooleanValue TRUE
The boolean value TRUE


FALSE

public static final BooleanValue FALSE
The boolean value FALSE

Method Detail

get

public static BooleanValue get(boolean value)
Factory method: get a BooleanValue

Parameters:
value - true or false, to determine which boolean value is required
Returns:
the BooleanValue requested

getValue

public boolean getValue()
Get the value

Returns:
true or false, the actual boolean value of this BooleanValue

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Get the effective boolean value of this expression

Specified by:
effectiveBooleanValue in interface Expression
Overrides:
effectiveBooleanValue in class AtomicValue
Parameters:
context - dynamic evaluation context, not used in this implementation
Returns:
the boolean value

convert

public AtomicValue convert(int requiredType)
                    throws XPathException
Convert to target data type

Specified by:
convert in class AtomicValue
Parameters:
requiredType - an integer identifying the required atomic type
Returns:
an AtomicValue, a value of the required type
Throws:
XPathException - if the conversion is not possible

getStringValue

public String getStringValue()
Convert to string

Specified by:
getStringValue in interface Item
Returns:
"true" or "false"

getItemType

public ItemType getItemType()
Determine the data type of the expression

Specified by:
getItemType in interface Expression
Returns:
Type.BOOLEAN,

conversionPreference

public int conversionPreference(Class required)
Get conversion preference for this value to a Java class.

Overrides:
conversionPreference in class AtomicValue
Parameters:
required - the Java class to which the value is to be converted
Returns:
An integer giving the conversion preference. A low result indicates higher preference.

convertToJava

public Object convertToJava(Class target)
                     throws XPathException
Convert to Java object (for passing to external functions)

Overrides:
convertToJava in class AtomicValue
Parameters:
target - the Java class to which conversion is required
Returns:
An object of the specified Java class
Throws:
XPathException - if conversion is not possible or fails

compareTo

public int compareTo(Object other)
Compare the value to another boolean value

Specified by:
compareTo in interface Comparable
Parameters:
other - The other boolean value
Returns:
-1 if this one is the lower, 0 if they are equal, +1 if this one is the higher. False is considered to be less than true.
Throws:
ClassCastException - if the other value is not a BooleanValue (the parameter is declared as Object to satisfy the Comparable interface)

equals

public boolean equals(Object other)
Determine whether two boolean values are equal

Overrides:
equals in class Object
Parameters:
other - the value to be compared to this value
Returns:
true if the other value is a boolean value and is equal to this value

hashCode

public int hashCode()
Get a hash code for comparing two BooleanValues

Overrides:
hashCode in class Object
Returns:
the hash code

display

public void display(int level,
                    NamePool pool)
Diagnostic print of expression structure

Specified by:
display in interface Expression
Parameters:
level - indentation level of output

toString

public String toString()
Diagnostic display of this value as a string

Overrides:
toString in class Object
Returns:
a string representation of this value: "true()" or "false()"