Package net.sf.saxon.value
Class BooleanValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.BooleanValue
- All Implemented Interfaces:
Serializable
,Comparable
,Expression
,Item
,ValueRepresentation
A boolean XPath value
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BooleanValue
The boolean value FALSEstatic final BooleanValue
The boolean value TRUEFields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionint
Compare the value to another boolean valueconvertPrimitive
(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data typeconvertToJava
(Class target, XPathContext context) Convert to Java object (for passing to external functions)boolean
effectiveBooleanValue
(XPathContext context) Get the effective boolean value of this expressionboolean
Determine whether two boolean values are equalstatic AtomicValue
Convert a string to a boolean value, using the XML Schema rules (including whitespace trimming)static BooleanValue
get
(boolean value) Factory method: get a BooleanValueboolean
Get the valueDetermine the data type of the expressionConvert to stringint
hashCode()
Get a hash code for comparing two BooleanValuestoString()
Diagnostic display of this value as a stringMethods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, display, evaluateAsString, evaluateItem, getCardinality, getComponent, getImplementationMethod, getLength, getPrimitiveValue, getStringValueCS, getTypedValue, hasBuiltInType, iterate, process
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
-
Field Details
-
TRUE
The boolean value TRUE -
FALSE
The boolean value FALSE
-
-
Method Details
-
get
Factory method: get a BooleanValue- Parameters:
value
- true or false, to determine which boolean value is required- Returns:
- the BooleanValue requested
-
fromString
Convert a string to a boolean value, using the XML Schema rules (including whitespace trimming)- Parameters:
s
- the input string- Returns:
- the relevant BooleanValue if validation succeeds; or an ErrorValue if not.
-
getBooleanValue
public boolean getBooleanValue()Get the value- Returns:
- true or false, the actual boolean value of this BooleanValue
-
effectiveBooleanValue
Get the effective boolean value of this expression- Specified by:
effectiveBooleanValue
in interfaceExpression
- Overrides:
effectiveBooleanValue
in classAtomicValue
- Parameters:
context
- dynamic evaluation context, not used in this implementation- Returns:
- the boolean value
-
convertPrimitive
public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data type- Specified by:
convertPrimitive
in classAtomicValue
- Parameters:
requiredType
- an integer identifying the required atomic typevalidate
- true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested.context
-- Returns:
- an AtomicValue, a value of the required type
-
getStringValue
Convert to string- Specified by:
getStringValue
in interfaceItem
- Specified by:
getStringValue
in interfaceValueRepresentation
- Specified by:
getStringValue
in classAtomicValue
- Returns:
- "true" or "false"
- See Also:
-
getItemType
Determine the data type of the expression- Specified by:
getItemType
in interfaceExpression
- Overrides:
getItemType
in classValue
- Parameters:
th
-- Returns:
- Type.BOOLEAN,
-
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJava
in classValue
- 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
Compare the value to another boolean value- Specified by:
compareTo
in interfaceComparable
- 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
Determine whether two boolean values are equal- Overrides:
equals
in classValue
- 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
- Throws:
ClassCastException
- if other value is not xs:boolean or derived therefrom
-
hashCode
public int hashCode()Get a hash code for comparing two BooleanValues -
toString
Diagnostic display of this value as a string- Overrides:
toString
in classAtomicValue
- Returns:
- a string representation of this value: "true()" or "false()"
-