Class BooleanValue

  • All Implemented Interfaces:
    AttributeValue, PrimitiveValue, Value

    public final class BooleanValue
    extends StringParseableValue<Boolean>
    Representation of a xs:boolean value. This class supports parsing xs:boolean values. All objects of this class are immutable and all methods of the class are thread-safe. The choice of the Java type boolean is based on JAXB schema-to-Java mapping spec: https://docs.oracle.com/javase/tutorial/jaxb/intro/bind.html
    Version:
    $Id: $
    • Field Detail

      • TRUE

        public static final BooleanValue TRUE
        Single instance of BooleanAttributeValue that represents true. Initialized by the static initializer below.
      • FALSE

        public static final BooleanValue FALSE
        Single instance of BooleanAttributeValue that represents false. Initialized by the static initializer below.
    • Constructor Detail

      • BooleanValue

        public BooleanValue​(Boolean value)
        Creates a new BooleanAttributeValue that represents the boolean value supplied.

        This constructor is private because it should not be used by anyone other than the static initializer in this class. Instead, please use one of the getInstance methods, which will ensure that only two BooleanAttributeValue objects are created, thus avoiding excess object creation.

        Parameters:
        value - boolean value
    • Method Detail

      • getInstance

        public static BooleanValue getInstance​(String s)
                                        throws IllegalArgumentException
        Convert a boolean value from string, according to the XML Schema definition. Adapted from BooleanValue.fromString(CharSequence), but without whitespace trimming. This is meant to replace DatatypeConverter.parseBoolean(String) which is flawed and does not comply with XSD definition of boolean type as of now (JDK7/8). See https://java.net/jira/browse/JAXB-901, and https://java.net/jira/browse/JAXB-902. E.g. DatatypeConverter.parseBoolean("not") throws NullPointerException instead of IllegalArgumentException as expected according to javadoc.
        Parameters:
        s - XSD-compliant string representation of boolean
        Returns:
        boolean value corresponding to s
        Throws:
        IllegalArgumentException - if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
      • valueOf

        public static BooleanValue valueOf​(boolean b)
        Get TRUE (resp. FALSE ) instance if b (resp. if ! b)
        Parameters:
        b - boolean input
        Returns:
        instance
      • printXML

        public String printXML()
        Converts the internal value (accessible via SimpleValue.getUnderlyingValue()) to a valid lexical representation for XML marshalling. Equivalent to the 'printMethod' in JAXB 'javaType' binding customizations. Implementations of this typically call DatatypeConverter. This method is called by SimpleValue.getContent() and its result cached by the same method for later use. Therefore, no need to cache the result in the implementation.
        Specified by:
        printXML in class SimpleValue<Boolean>
        Returns:
        XML-valid lexical representation.
      • getXdmItem

        public net.sf.saxon.s9api.XdmItem getXdmItem()
        Returns:
        corresponding XPath (XDM) value