public abstract class IntegerValue extends DecimalValue
Int64Value
, which accommodates values up to 2^63, and
BigIntegerValue
, which accommodates unlimited-length integers.Modifier and Type | Field and Description |
---|---|
static Int64Value |
MAX_LONG
IntegerValue representing the maximum value for a long
|
static Int64Value |
MIN_LONG
IntegerValue representing the minimum value for a long
|
static Int64Value |
MINUS_ONE
IntegerValue representing the value -1
|
static Int64Value |
PLUS_ONE
IntegerValue representing the value +1
|
static Int64Value |
ZERO
IntegerValue representing the value zero
|
NaN_MATCH_KEY, typeLabel
Constructor and Description |
---|
IntegerValue() |
Modifier and Type | Method and Description |
---|---|
abstract java.math.BigInteger |
asBigInteger()
Get the value as a BigInteger
|
static ValidationFailure |
castableAsInteger(java.lang.CharSequence input)
Determine whether a string is castable as an integer
|
static boolean |
checkBigRange(java.math.BigInteger big,
BuiltInAtomicType type)
Check that a BigInteger is within the required range for a given integer subtype.
|
static boolean |
checkRange(long value,
BuiltInAtomicType type)
Check that a value is in range for the specified subtype of xs:integer
|
abstract ValidationFailure |
convertToSubType(BuiltInAtomicType type,
boolean validate)
This class allows subtypes of xs:integer to be held, as well as xs:integer values.
|
abstract NumericValue |
div(IntegerValue other)
Divide by another integer
|
NumericValue |
div(IntegerValue other,
Location locator)
Divide by another integer, providing location information for any exception
|
abstract java.math.BigDecimal |
getDecimalValue()
Get the numeric value converted to a decimal
|
static IntegerValue |
getMaxInclusive(BuiltInAtomicType type)
Get the maxInclusive facet for a built-in integer subtype
|
static IntegerValue |
getMinInclusive(BuiltInAtomicType type)
Get the minInclusive facet for a built-in integer subtype
|
BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value.
|
abstract IntegerValue |
idiv(IntegerValue other)
Integer divide by another integer
|
IntegerValue |
idiv(IntegerValue other,
Location locator)
Integer divide by another integer, providing location information for any exception
|
boolean |
isIdentical(AtomicValue v)
Determine whether two atomic values are identical, as determined by XML Schema rules.
|
boolean |
isWholeNumber()
Determine whether the value is a whole number, that is, whether it compares
equal to some integer
|
static IntegerValue |
makeIntegerValue(java.math.BigInteger value)
Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied
|
static ConversionResult |
makeIntegerValue(double value)
Convert a double to an integer
|
static ConversionResult |
makeIntegerValue(DoubleValue doubleValue)
Convert a double to an integer
|
abstract IntegerValue |
minus(IntegerValue other)
Subtract another integer
|
abstract IntegerValue |
mod(IntegerValue other)
Take modulo another integer
|
IntegerValue |
mod(IntegerValue other,
Location locator)
Take modulo another integer, providing location information for any exception
|
abstract IntegerValue |
plus(IntegerValue other)
Add another integer
|
protected static int |
signum(int i)
Get the signum of an int
|
static ConversionResult |
stringToInteger(java.lang.CharSequence s)
Static factory method to convert strings to integers.
|
abstract IntegerValue |
times(IntegerValue other)
Multiply by another integer
|
abstract ValidationFailure |
validateAgainstSubType(BuiltInAtomicType type)
This class allows subtypes of xs:integer to be held, as well as xs:integer values.
|
abs, asSubscript, ceiling, compareTo, compareTo, equals, floor, getDoubleValue, getFloatValue, getXPathComparable, hashCode, isInteger, isNegativeZero, longValue, negate, parseNumber, round, roundHalfToEven, signum, toString
asAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, copyAsSubType, effectiveBooleanValue, getCanonicalLexicalRepresentation, getCardinality, getComponent, getItemType, getPrimitiveStringValue, getSchemaComparable, getStringValue, getStringValueCS, getUType, head, identityHashCode, isIdentical, isNaN, itemAt, iterate, iterator, process, setTypeLabel
getLength, isStreamed, reduce, subsequence
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asAtomic
getLength
reduce, subsequence
public static final Int64Value MINUS_ONE
public static final Int64Value ZERO
public static final Int64Value PLUS_ONE
public static final Int64Value MAX_LONG
public static final Int64Value MIN_LONG
public static IntegerValue makeIntegerValue(java.math.BigInteger value)
value
- the supplied integer valuepublic static ConversionResult makeIntegerValue(double value)
value
- the double to be convertedpublic static ConversionResult makeIntegerValue(DoubleValue doubleValue)
doubleValue
- the double to be convertedpublic abstract ValidationFailure convertToSubType(BuiltInAtomicType type, boolean validate)
type
- the subtype of integer requiredvalidate
- true if validation is required, false if the caller warrants that the value
is valid for the subtypepublic abstract ValidationFailure validateAgainstSubType(BuiltInAtomicType type)
type
- the subtype of integer requiredpublic static boolean checkRange(long value, BuiltInAtomicType type)
value
- the value to be checkedtype
- the required item type, a subtype of xs:integerpublic static IntegerValue getMinInclusive(BuiltInAtomicType type)
type
- the built-in type, which must be derived from xs:integerpublic static IntegerValue getMaxInclusive(BuiltInAtomicType type)
type
- the built-in type, which must be derived from xs:integerpublic static boolean checkBigRange(java.math.BigInteger big, BuiltInAtomicType type)
big
- the supplied BigIntegertype
- the derived type (a built-in restriction of xs:integer) to check the value againstpublic static ConversionResult stringToInteger(java.lang.CharSequence s)
s
- CharSequence representing the string to be convertedpublic static ValidationFailure castableAsInteger(java.lang.CharSequence input)
input
- the string to be testedpublic BuiltInAtomicType getPrimitiveType()
getPrimitiveType
in class AtomicValue
public abstract java.math.BigDecimal getDecimalValue()
getDecimalValue
in class NumericValue
public boolean isWholeNumber()
isWholeNumber
in class NumericValue
public abstract IntegerValue plus(IntegerValue other)
other
- the other integerpublic abstract IntegerValue minus(IntegerValue other)
other
- the other integerpublic abstract IntegerValue times(IntegerValue other)
other
- the other integerpublic abstract NumericValue div(IntegerValue other) throws XPathException
other
- the other integerXPathException
- if the other integer is zeropublic NumericValue div(IntegerValue other, Location locator) throws XPathException
other
- the other integerlocator
- the location of the expression, for use in diagnosticsXPathException
- if the other integer is zeropublic abstract IntegerValue mod(IntegerValue other) throws XPathException
other
- the other integerXPathException
- if the other integer is zeropublic IntegerValue mod(IntegerValue other, Location locator) throws XPathException
other
- the other integerlocator
- the location of the expression, for use in diagnosticsXPathException
- if the other integer is zeropublic abstract IntegerValue idiv(IntegerValue other) throws XPathException
other
- the other integerXPathException
- if the other integer is zeropublic IntegerValue idiv(IntegerValue other, Location locator) throws XPathException
other
- the other integerlocator
- the location of the expression, for use in diagnosticsXPathException
- if the other integer is zeropublic abstract java.math.BigInteger asBigInteger()
protected static int signum(int i)
i
- the intpublic boolean isIdentical(AtomicValue v)
Note that even this check ignores the type annotation of the value. The integer 3 and the short 3 are considered identical, even though they are not fully interchangeable. "Identical" means the same point in the value space, regardless of type annotation.
NaN is identical to itself.
isIdentical
in class AtomicValue
v
- the other value to be compared with this oneCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.