Package net.sf.saxon.value
Class BooleanValue
- java.lang.Object
-
- net.sf.saxon.value.AtomicValue
-
- net.sf.saxon.value.BooleanValue
-
- All Implemented Interfaces:
java.lang.Comparable<XPathComparable>
,java.lang.Iterable<AtomicValue>
,AtomicMatchKey
,XPathComparable
,AtomicSequence
,GroundedValue
,IdentityComparable
,Item
,Sequence
,ConversionResult
,ContextFreeAtomicValue
public final class BooleanValue extends AtomicValue implements XPathComparable, AtomicMatchKey, ContextFreeAtomicValue
A boolean XPath value
-
-
Field Summary
Fields Modifier and Type Field Description static BooleanValue
FALSE
The boolean value FALSEstatic BooleanValue
TRUE
The boolean value TRUE-
Fields inherited from class net.sf.saxon.value.AtomicValue
typeLabel
-
-
Constructor Summary
Constructors Constructor Description BooleanValue(boolean value, AtomicType typeLabel)
Create a new Boolean value with a user-supplied type label.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(XPathComparable other)
Compare the value to another boolean valueAtomicValue
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value (usually so that the type label can be changed).boolean
effectiveBooleanValue()
Get the effective boolean value of this expressionboolean
equals(java.lang.Object other)
Determine whether two boolean values are equalstatic ConversionResult
fromString(UnicodeString s)
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
getBooleanValue()
Get the valueUnicodeString
getPrimitiveStringValue()
Convert to stringBuiltInAtomicType
getPrimitiveType()
Determine the primitive type of the value.XPathComparable
getXPathComparable()
Get an XPathComparable object that supports the semantics of context-free eq and lt comparisons between atomic values.XPathComparable
getXPathComparable(StringCollator collator, int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.AtomicMatchKey
getXPathMatchKey(StringCollator collator, int implicitTimezone)
Get a Comparable value that implements the XPath ordering comparison semantics for this value.int
hashCode()
Get a hash code for comparing two BooleanValuesjava.lang.String
show()
Diagnostic display of this value as a string-
Methods inherited from class net.sf.saxon.value.AtomicValue
asAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, getCanonicalLexicalRepresentation, getCardinality, getComponent, getGenre, getItemType, getLength, getUnicodeStringValue, getUType, head, identityHashCode, isIdentical, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, toShortString, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.sort.AtomicMatchKey
asAtomic
-
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
-
Methods inherited from interface net.sf.saxon.om.Item
getStringValue, isStreamed, reduce, subsequence
-
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
-
-
-
Field Detail
-
TRUE
public static final BooleanValue TRUE
The boolean value TRUE
-
FALSE
public static final BooleanValue FALSE
The boolean value FALSE
-
-
Constructor Detail
-
BooleanValue
public BooleanValue(boolean value, AtomicType typeLabel)
Create a new Boolean value with a user-supplied type label. It is the caller's responsibility to ensure that the value is valid for the subtype- Parameters:
value
- the boolean valuetypeLabel
- the type label, xs:boolean or a subtype
-
-
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
-
copyAsSubType
public AtomicValue copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value (usually so that the type label can be changed). The type label of the copy will be reset to the primitive type.- Specified by:
copyAsSubType
in classAtomicValue
- Parameters:
typeLabel
- the atomic type label to be added to the copied value- Returns:
- the copied value
-
fromString
public static ConversionResult fromString(UnicodeString s)
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 a ValidationFailure if not.
-
getBooleanValue
public boolean getBooleanValue()
Get the value- Returns:
- true or false, the actual boolean value of this BooleanValue
-
effectiveBooleanValue
public boolean effectiveBooleanValue()
Get the effective boolean value of this expression- Specified by:
effectiveBooleanValue
in interfaceGroundedValue
- Overrides:
effectiveBooleanValue
in classAtomicValue
- Returns:
- the boolean value
-
getPrimitiveType
public BuiltInAtomicType getPrimitiveType()
Determine the primitive type of the value. This delivers the same answer as getItemType().getPrimitiveItemType(). The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration, and xs:untypedAtomic. For external objects, the result is AnyAtomicType.- Specified by:
getPrimitiveType
in classAtomicValue
- Returns:
- the primitive type
-
getPrimitiveStringValue
public UnicodeString getPrimitiveStringValue()
Convert to string- Specified by:
getPrimitiveStringValue
in classAtomicValue
- Returns:
- "true" or "false"
-
getXPathMatchKey
public AtomicMatchKey getXPathMatchKey(StringCollator collator, int implicitTimezone)
Get a Comparable value that implements the XPath ordering comparison semantics for this value. Returns null if the value is not comparable according to XPath rules. The default implementation returns null. This is overridden for types that allow ordered comparisons in XPath: numeric, boolean, string, date, time, dateTime, yearMonthDuration, dayTimeDuration, and anyURI.- Specified by:
getXPathMatchKey
in classAtomicValue
- Parameters:
collator
- the collation to be used when comparing stringsimplicitTimezone
- the XPath dynamic evaluation context, used in cases where the comparison is context sensitive- Returns:
- an Object whose equals() and hashCode() methods implement the XPath comparison semantics with respect to this atomic value. If ordered is specified, the result will either be null if no ordering is defined, or will be a Comparable
-
getXPathComparable
public XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone)
Description copied from class:AtomicValue
Get an object value that implements the XPath equality and ordering comparison semantics for this value. A collation is supplied for comparing strings, and an implicit timezone for comparing date/time values that have no saved timezone. An atomic value may return itself as the result, provided that its ordering rules are independent of the collation and timezone, and provided that it implements the XPathComparable interface: which means that its compareTo, equals, and hashCode methods must be compatible with the rules for XPath value comparisons.- Specified by:
getXPathComparable
in classAtomicValue
- Parameters:
collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing dates/times with and without timezone- Returns:
- an Object that implements the XPath value comparison semantics with respect to this atomic value. For an atomic type that is not ordered (according to XPath rules), return null.
-
getXPathComparable
public XPathComparable getXPathComparable()
Description copied from interface:ContextFreeAtomicValue
Get an XPathComparable object that supports the semantics of context-free eq and lt comparisons between atomic values. Note that in many cases the returned XPathComparable will be the AtomicValue itself; however because of the constraints of the genericComparable
interface, this cannot be assumed.- Specified by:
getXPathComparable
in interfaceContextFreeAtomicValue
- Returns:
- an XPathComparable that can be used in comparisons with other atomic values.
-
compareTo
public int compareTo(XPathComparable other)
Compare the value to another boolean value- Specified by:
compareTo
in interfacejava.lang.Comparable<XPathComparable>
- 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:
java.lang.ClassCastException
- if the other value is not a BooleanValue (the parameter is declared as Object to satisfy the Comparable interface)
-
equals
public boolean equals(java.lang.Object other)
Determine whether two boolean values are equal- Overrides:
equals
in classAtomicValue
- 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:
java.lang.ClassCastException
- if other value is not xs:boolean or derived therefrom
-
hashCode
public int hashCode()
Get a hash code for comparing two BooleanValues- Overrides:
hashCode
in classAtomicValue
- Returns:
- the hash code
-
show
public java.lang.String show()
Diagnostic display of this value as a string- Overrides:
show
in classAtomicValue
- Returns:
- a string representation of this value: "true()" or "false()"
-
-