com.ihr.xbrl.om.instance
Class XBRLNumericValue

java.lang.Object
  extended by com.ihr.xbrl.om.instance.XBRLNumericValue
All Implemented Interfaces:
XBRLNumber, java.lang.Cloneable

public class XBRLNumericValue
extends java.lang.Object
implements java.lang.Cloneable, XBRLNumber

A XBRLNumericValue object is the representation of a number inside a numeric fact item. This means that it contains a Number object which is the value, and the value of the number precision. This class provides methods to operate with XBRL Numbers and compare them.

Starting on 8/4/2009. In order to implement the functionality that this object can be created without a value and the value can be set later, this object now has a flag indicating whether the numeric value is set of is blank.

Author:
Ignacio

Field Summary
 
Fields inherited from interface com.ihr.xbrl.om.instance.XBRLNumber
DECIMALS, INF, PRECISION
 
Constructor Summary
XBRLNumericValue(XBRLFactNumeric fact)
          Creation of an empty XBRLNumericValue (Blank) This is useful for editing purposes.
XBRLNumericValue(XBRLFactNumeric fact, java.lang.Number value, int precisionOrDecimals)
          Creation from Java Number object
XBRLNumericValue(XBRLFactNumeric fact, net.sf.saxon.value.NumericValue value, int precisionOrDecimals)
          Creation from a Saxon NumericValue object
 
Method Summary
 XBRLNumericValue clone()
           
 boolean eq(XBRLNumber value2)
           
 boolean equals(java.lang.Object other)
           
 java.math.BigDecimal getBigDecimal()
          returns the internal representation of this value as a BigDecimal
 java.lang.String getDecimals()
          Convert precision value into decimals value if needed and returns the decimals value It is returned as a string because "INF" is a valid value.
static int getExponent(java.lang.String strValue)
           
 XBRLFactNumeric getFact()
          Access to the XBRLFactNumeric that is the container of this XBRLNumericValue.
 int getInferredPrecision()
          Gets the inferred precision for this numeric value
 java.lang.String getPrecision()
          The value of the precision for this numeric value.
 java.lang.Number getValue()
          Access to the surrounding number value this object is encapsulating.
static net.sf.saxon.value.NumericValue getValue(XBRLXSDTypeDefinition type, java.lang.Object value)
          Returns a NumericValue representation of the value according to the type definition in the parameter
 int hashCode()
           
static int inferredDecimals(int precision, java.lang.String strValue)
           
static int inferredDecimalsBug368(int precision, java.lang.String rawStrValue)
           
static int inferredPrecision(java.lang.String decimalsStr, java.lang.String strValue)
           
 boolean isBlank()
          true if this XBRLNumericValue has no value assigned
 XBRLNumericValue multiply(double weight)
           
 boolean ne(XBRLNumber value2)
           
static java.lang.String numericValueToString(java.lang.Number value)
          Calculates a string representation of an object value.
 XBRLNumericValue plus(XBRLNumber value2)
           
 XBRLNumericValue roundTo(int precision2)
           
 void setDecimals(int decimals)
           
 void setFact(XBRLFactNumeric factNumeric)
           
 void setPrecision(int precision)
           
 void setValue(java.lang.Number value)
           
 java.lang.String toString()
          Returns a human readable representation of this number.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XBRLNumericValue

public XBRLNumericValue(XBRLFactNumeric fact)
Creation of an empty XBRLNumericValue (Blank) This is useful for editing purposes. The fact item cannot be serialized if the content is blank

Parameters:
fact - the parent fact, may be null

XBRLNumericValue

public XBRLNumericValue(XBRLFactNumeric fact,
                        java.lang.Number value,
                        int precisionOrDecimals)
Creation from Java Number object

Parameters:
fact - the XBRLFactNumeric instance for which this is the XBRLNumericValue
value - Java Number or derived from Number object instance
precisionOrDecimals - integer, depending on the bug368 the value goes to the precision or decimals property

XBRLNumericValue

public XBRLNumericValue(XBRLFactNumeric fact,
                        net.sf.saxon.value.NumericValue value,
                        int precisionOrDecimals)
Creation from a Saxon NumericValue object

Parameters:
fact - the XBRLFactNumeric instance for which this is the XBRLNumericValue
value - NumericValue form saxonica library
precisionOrDecimals - integer
Method Detail

getFact

public XBRLFactNumeric getFact()
Description copied from interface: XBRLNumber
Access to the XBRLFactNumeric that is the container of this XBRLNumericValue.

It may be null

Specified by:
getFact in interface XBRLNumber
Returns:
XBRLFactNumeric or null

isBlank

public boolean isBlank()
Description copied from interface: XBRLNumber
true if this XBRLNumericValue has no value assigned

Specified by:
isBlank in interface XBRLNumber
Returns:
the bBlank

toString

public java.lang.String toString()
Returns a human readable representation of this number.

The representation uses the decimal format #,##0.####;(#,##0.####) that is defined as a constant inside this class followed by p(n) which means precision n, n is the number precision (explicit or inferred) according to the XBRL 2.1 standard. This includes the constant INF that represents INFINITE precision.

Examples: -1,000,000 p(4) -1,000,000 p(INF)

Overrides:
toString in class java.lang.Object

getValue

public java.lang.Number getValue()
Access to the surrounding number value this object is encapsulating.

Return null if the value is nil and the fact is assigned and isNil() returns true otherwise this returns the value, that also may be null.

Returns:
Number

setValue

public void setValue(java.lang.Number value)
Parameters:
value - a Number to be set as the value

clone

public XBRLNumericValue clone()
Specified by:
clone in interface XBRLNumber
Overrides:
clone in class java.lang.Object
Returns:

getPrecision

public java.lang.String getPrecision()
The value of the precision for this numeric value. If the format is decimals, this function transforms from decimals to precision first. The value is returned as a string so "INF" is a valid value to be returned

Returns:
String

multiply

public XBRLNumericValue multiply(double weight)
Specified by:
multiply in interface XBRLNumber
Returns:

plus

public XBRLNumericValue plus(XBRLNumber value2)
Specified by:
plus in interface XBRLNumber
Returns:

ne

public boolean ne(XBRLNumber value2)
Specified by:
ne in interface XBRLNumber
Returns:

getInferredPrecision

public int getInferredPrecision()
Description copied from interface: XBRLNumber
Gets the inferred precision for this numeric value

Specified by:
getInferredPrecision in interface XBRLNumber
Returns:
integer

eq

public boolean eq(XBRLNumber value2)
Specified by:
eq in interface XBRLNumber
Returns:

roundTo

public XBRLNumericValue roundTo(int precision2)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getValue

public static net.sf.saxon.value.NumericValue getValue(XBRLXSDTypeDefinition type,
                                                       java.lang.Object value)
Returns a NumericValue representation of the value according to the type definition in the parameter

Parameters:
type - XBRLXSDTypeDefinition
Returns:
a NumericValue

numericValueToString

public static java.lang.String numericValueToString(java.lang.Number value)
Calculates a string representation of an object value. The pattern for formatting the number is DecimalFormat("################################.00000000000000000000000000000000",new DecimalFormatSymbols(Locale.US)) NaN is an accepted input value; in this case, the returned string is NaN.

Parameters:
value - a Number
Returns:
a string
Since:
2.6.10

getDecimals

public java.lang.String getDecimals()
Description copied from interface: XBRLNumber
Convert precision value into decimals value if needed and returns the decimals value It is returned as a string because "INF" is a valid value.

Specified by:
getDecimals in interface XBRLNumber
Returns:
String

inferredDecimals

public static int inferredDecimals(int precision,
                                   java.lang.String strValue)
Parameters:
precision -
strValue -
Returns:
integer

inferredDecimalsBug368

public static int inferredDecimalsBug368(int precision,
                                         java.lang.String rawStrValue)
Parameters:
precisionInt -
rawStrValue -
Returns:

inferredPrecision

public static int inferredPrecision(java.lang.String decimalsStr,
                                    java.lang.String strValue)
Parameters:
decimalsStr -
Returns:
integer

getExponent

public static int getExponent(java.lang.String strValue)
Parameters:
strValue - capitalized so the exponent will be the number after E
Returns:
int

setPrecision

public void setPrecision(int precision)

setDecimals

public void setDecimals(int decimals)

setFact

public void setFact(XBRLFactNumeric factNumeric)
Specified by:
setFact in interface XBRLNumber

hashCode

public int hashCode()
Specified by:
hashCode in interface XBRLNumber
Overrides:
hashCode in class java.lang.Object

getBigDecimal

public java.math.BigDecimal getBigDecimal()
returns the internal representation of this value as a BigDecimal



Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa