Class BooleanValue

All Implemented Interfaces:
Serializable, Comparable, Expression, Item, ValueRepresentation

public final class BooleanValue extends AtomicValue implements Comparable
A boolean XPath value
See Also:
  • Field Details

    • TRUE

      public static final BooleanValue TRUE
      The boolean value TRUE
    • FALSE

      public static final BooleanValue FALSE
      The boolean value FALSE
  • Method Details

    • 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
    • fromString

      public static AtomicValue fromString(CharSequence 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 an ErrorValue if not.
    • getBooleanValue

      public boolean getBooleanValue()
      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
    • convertPrimitive

      public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
      Convert to target data type
      Specified by:
      convertPrimitive in class AtomicValue
      Parameters:
      requiredType - an integer identifying the required atomic type
      validate - 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

      public String getStringValue()
      Convert to string
      Specified by:
      getStringValue in interface Item
      Specified by:
      getStringValue in interface ValueRepresentation
      Specified by:
      getStringValue in class AtomicValue
      Returns:
      "true" or "false"
      See Also:
    • getItemType

      public ItemType getItemType(TypeHierarchy th)
      Determine the data type of the expression
      Specified by:
      getItemType in interface Expression
      Overrides:
      getItemType in class Value
      Parameters:
      th -
      Returns:
      Type.BOOLEAN,
    • convertToJava

      public Object convertToJava(Class target, XPathContext context) throws XPathException
      Convert to Java object (for passing to external functions)
      Overrides:
      convertToJava in class Value
      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 Value
      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
      Overrides:
      hashCode in class Value
      Returns:
      the hash code
    • toString

      public String toString()
      Diagnostic display of this value as a string
      Overrides:
      toString in class AtomicValue
      Returns:
      a string representation of this value: "true()" or "false()"