Class NumericValue


  • public final class NumericValue
    extends Value
    A numeric (floating point) value
    • Constructor Detail

      • NumericValue

        public NumericValue​(double value)
        Constructor supplying a double
      • NumericValue

        public NumericValue​(java.lang.String s)
        Constructor supplying a String
    • Method Detail

      • asStringOLD

        public java.lang.String asStringOLD()
        Get the value as a String
        Returns:
        a String representation of the value
      • asString

        public java.lang.String asString()
        Get the value as a String
        Specified by:
        asString in class Value
        Returns:
        a String representation of the value
      • asNumber

        public double asNumber()
        Get the value as a number
        Specified by:
        asNumber in class Value
        Returns:
        the numeric value
      • asBoolean

        public boolean asBoolean()
        Convert the value to a boolean
        Specified by:
        asBoolean in class Value
        Returns:
        false if zero, true otherwise
      • getDataType

        public int getDataType()
        Determine the data type of the exprssion, if possible
        Specified by:
        getDataType in class Expression
        Returns:
        one of the values Value.STRING, Value.BOOLEAN, Value.NUMBER, Value.NODESET, Value.FRAGMENT, or Value.ANY (meaning not known in advance)
      • conversionPreference

        public int conversionPreference​(java.lang.Class required)
        Get conversion preference for this value to a Java class. A low result indicates higher preference.
        Specified by:
        conversionPreference in class Value
      • convertToJava

        public java.lang.Object convertToJava​(java.lang.Class target)
                                       throws XPathException
        Convert to Java object (for passing to external functions)
        Specified by:
        convertToJava in class Value
        Parameters:
        target - The class required by the external function
        Returns:
        an object of the target class
        Throws:
        XPathException
      • display

        public void display​(int level)
        Diagnostic print of expression structure
        Specified by:
        display in class Expression