Class DoubleValue
- java.lang.Object
-
- org.ow2.authzforce.core.pdp.api.value.SimpleValue<V>
-
- org.ow2.authzforce.core.pdp.api.value.StringParseableValue<N>
-
- org.ow2.authzforce.core.pdp.api.value.NumericValue<Double,DoubleValue>
-
- org.ow2.authzforce.core.pdp.api.value.DoubleValue
-
- All Implemented Interfaces:
Comparable<DoubleValue>
,AttributeValue
,PrimitiveValue
,Value
public final class DoubleValue extends NumericValue<Double,DoubleValue> implements Comparable<DoubleValue>
Representation of a xs:double value. This class supports parsing xs:double values. All objects of this class are immutable and all methods of the class are thread-safe. The choice of the Java type Double is based on JAXB schema-to-Java mapping spec: https://docs.oracle.com/javase/tutorial/jaxb/intro/bind.html- Version:
- $Id: $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ow2.authzforce.core.pdp.api.value.StringParseableValue
StringParseableValue.Factory<AV extends AttributeValue>
-
Nested classes/interfaces inherited from class org.ow2.authzforce.core.pdp.api.value.SimpleValue
SimpleValue.BaseFactory<AV extends AttributeValue>
-
-
Field Summary
Fields Modifier and Type Field Description static DoubleValue
ZERO
Value zero-
Fields inherited from class org.ow2.authzforce.core.pdp.api.value.SimpleValue
value
-
-
Constructor Summary
Constructors Constructor Description DoubleValue(Double value)
Creates a newDoubleAttributeValue
that represents the double value supplied.DoubleValue(String val)
Creates instance from string according to xsd:double definition
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleValue
abs()
Returns the absolute value ofthis
.DoubleValue
add(Deque<? extends DoubleValue> others)
Adds numbers to this.int
compareTo(DoubleValue o)
DoubleValue
divide(DoubleValue divisor)
Dividethis
by some other number.DoubleValue
floor()
floornet.sf.saxon.s9api.XdmItem
getXdmItem()
long
longValue()
Converts this double value to a long, as specified byDouble.longValue()
DoubleValue
multiply(Deque<? extends DoubleValue> others)
Multiplythis
by other numbers.String
printXML()
Converts the internal value (accessible viaSimpleValue.getUnderlyingValue()
) to a valid lexical representation for XML marshalling.DoubleValue
roundIEEE754Default()
Rounds the double using default IEEE754 rounding mode .DoubleValue
subtract(DoubleValue subtractedVal)
Subtract a number from this.-
Methods inherited from class org.ow2.authzforce.core.pdp.api.value.StringParseableValue
getXmlAttributes
-
Methods inherited from class org.ow2.authzforce.core.pdp.api.value.SimpleValue
equals, getContent, getUnderlyingValue, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ow2.authzforce.core.pdp.api.value.PrimitiveValue
getXdmValue
-
-
-
-
Field Detail
-
ZERO
public static final DoubleValue ZERO
Value zero
-
-
Constructor Detail
-
DoubleValue
public DoubleValue(Double value)
Creates a newDoubleAttributeValue
that represents the double value supplied.- Parameters:
value
- thedouble
value to be represented
-
DoubleValue
public DoubleValue(String val) throws NumberFormatException
Creates instance from string according to xsd:double definition- Parameters:
val
- A string containing lexical representation of xsd:double- Throws:
NumberFormatException
-val
is not a valid string representation of adouble
value
-
-
Method Detail
-
getXdmItem
public net.sf.saxon.s9api.XdmItem getXdmItem()
- Specified by:
getXdmItem
in interfacePrimitiveValue
- Returns:
- corresponding XPath (XDM) value
-
compareTo
public int compareTo(DoubleValue o)
- Specified by:
compareTo
in interfaceComparable<DoubleValue>
-
abs
public DoubleValue abs()
Returns the absolute value ofthis
. Used by the XACML "abs" functions.- Specified by:
abs
in classNumericValue<Double,DoubleValue>
- Returns:
- the absolute value
-
add
public DoubleValue add(Deque<? extends DoubleValue> others)
Adds numbers to this. Used by the XACML numeric *-add functions.- Specified by:
add
in classNumericValue<Double,DoubleValue>
- Parameters:
others
- values to add to this value- Returns:
- sum of this and the others.
-
multiply
public DoubleValue multiply(Deque<? extends DoubleValue> others)
Multiplythis
by other numbers. Used by the XACML "multiply" functions.- Specified by:
multiply
in classNumericValue<Double,DoubleValue>
- Parameters:
others
- other values to multiply by- Returns:
- product of this by the others
-
divide
public DoubleValue divide(DoubleValue divisor) throws ArithmeticException
Dividethis
by some other number. Used by XACML *-divide functions.- Specified by:
divide
in classNumericValue<Double,DoubleValue>
- Parameters:
divisor
- number by whichthis
is divided- Returns:
- the result quotient
- Throws:
ArithmeticException
- if divisor is zero
-
floor
public DoubleValue floor()
floor
- Returns:
- result of Math#floor(double) as AttributeValue
- See Also:
Math.floor(double)
-
roundIEEE754Default
public DoubleValue roundIEEE754Default()
Rounds the double using default IEEE754 rounding mode . According to XACML core spec, §7.5 Arithmetic evaluation, "rounding - is set to round-half-even (IEEE 854 §4.1)" (RoundingMode.HALF_EVEN
). This method usesMath.rint(double)
that does the equivalent of theRoundingMode.HALF_EVEN
.- Returns:
- result of Math#rint(double) as AttributeValue
-
subtract
public DoubleValue subtract(DoubleValue subtractedVal)
Subtract a number from this. Used by XACML numeric *-subtract functions.- Specified by:
subtract
in classNumericValue<Double,DoubleValue>
- Parameters:
subtractedVal
- value to be subtracted fromthis
- Returns:
- this - subtractedVal
-
longValue
public long longValue()
Converts this double value to a long, as specified byDouble.longValue()
- Returns:
this
as an integer
-
printXML
public String printXML()
Converts the internal value (accessible viaSimpleValue.getUnderlyingValue()
) to a valid lexical representation for XML marshalling. Equivalent to the 'printMethod' in JAXB 'javaType' binding customizations. Implementations of this typically callDatatypeConverter
. This method is called bySimpleValue.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 classSimpleValue<Double>
- Returns:
- XML-valid lexical representation.
-
-