com.ihr.xbrl.om.instance

## Class XBRLNumericValue

- java.lang.Object
- - 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

    Constructors
    Constructor and Description
    `XBRLNumericValue(XBRLFactNumeric fact)` Creation of an empty XBRLNumericValue (Blank) This is useful for editing purposes.
    `XBRLNumericValue(XBRLFactNumeric fact, java.lang.Number value, int precisionOrDecimals, java.lang.String strValue)` Creation from Java Number object.
    `XBRLNumericValue(XBRLFactNumeric fact, net.sf.saxon.value.NumericValue value, int precisionOrDecimals)` Creation from a Saxon NumericValue object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `XBRLNumericValue` | `clone()` Clone.
    `boolean` | `eq(XBRLNumber value2)` Eq.
    `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)` Gets the exponent.
    `XBRLFactNumeric` | `getFact()` Access to the XBRLFactNumeric that is the container of this XBRLNumericValue.
    `java.lang.String` | `getFriendlyName(int flags, LabelsProvider lp)` Gets the friendly name.
    `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.String` | `getStringValue()` Gets the string 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()` Hash code.
    `static int` | `inferredDecimals(int precision, java.lang.String strValue)` Inferred decimals.
    `static int` | `inferredDecimalsBug368(int precision, java.lang.String rawStrValue)` Inferred decimals bug368.
    `static int` | `inferredPrecision(java.lang.String decimalsStr, java.lang.String strValue)` Inferred precision.
    `boolean` | `isBlank()` true if this XBRLNumericValue has no value assigned .
    `XBRLNumericValue` | `multiply(double weight)` Multiply.
    `boolean` | `ne(XBRLNumber value2)` Ne.
    `static java.lang.String` | `numericValueToString(java.lang.Number value)` Calculates a string representation of an object value.
    `XBRLNumericValue` | `plus(XBRLNumber value2)` Plus.
    `XBRLNumericValue` | `roundTo(int precisionOrDecimals)` Round to a specific value for the decimals attribute or number of characters in the precision attribute.
    `void` | `setDecimals(int decimals)` Sets the decimals.
    `void` | `setFact(XBRLFactNumeric factNumeric)` Sets the fact.
    `void` | `setPrecision(int precision)` Sets the precision.
    `void` | `setValue(java.lang.Number value, java.lang.String strValue)` Sets the 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,
                          java.lang.String strValue)

      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
        `strValue` - the str value

    - #### 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`
      Returns:
        the string

    - #### getFriendlyName

          public java.lang.String getFriendlyName(int flags,
                                         LabelsProvider lp)

      Description copied from interface: `XBRLNumber`
      Gets the friendly name.
      Specified by:
        `getFriendlyName` in interface `XBRLNumber`
      Parameters:
        `flags` - XMLFragment.HIDE_COMMON_ACCURACY can be used to remove suffixes
        `lp` - (can be null, it is not used)
      Returns:
        the friendly name

    - #### 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

    - #### getStringValue

          public java.lang.String getStringValue()

      Gets the string value.
      Returns:
        the strValue

    - #### setValue

          public void setValue(java.lang.Number value,
                      java.lang.String strValue)

      Sets the value.
      Parameters:
        `value` - a Number to be set as the value
        `strValue` - the string representation of value

    - #### clone

          public XBRLNumericValue clone()

      Description copied from interface: `XBRLNumber`
      Clone.
      Specified by:
        `clone` in interface `XBRLNumber`
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        the XBRL number

    - #### 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)

      Description copied from interface: `XBRLNumber`
      Multiply.
      Specified by:
        `multiply` in interface `XBRLNumber`
      Parameters:
        `weight` - the weight
      Returns:
        the XBRL number

    - #### plus

          public XBRLNumericValue plus(XBRLNumber value2)

      Description copied from interface: `XBRLNumber`
      Plus.
      Specified by:
        `plus` in interface `XBRLNumber`
      Parameters:
        `value2` - the multiply
      Returns:
        the XBRL number

    - #### ne

          public boolean ne(XBRLNumber value2)

      Description copied from interface: `XBRLNumber`
      Ne.
      Specified by:
        `ne` in interface `XBRLNumber`
      Parameters:
        `value2` - the sum item
      Returns:
        true, if successful

    - #### 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)

      Description copied from interface: `XBRLNumber`
      Eq.
      Specified by:
        `eq` in interface `XBRLNumber`
      Parameters:
        `value2` - the vb
      Returns:
        true, if successful

    - #### roundTo

          public XBRLNumericValue roundTo(int precisionOrDecimals)

      Round to a specific value for the decimals attribute or number of characters in the precision attribute. The same method works to round the value depending on what was set when the XBRLNumericValue was created.
      Parameters:
        `precisionOrDecimals` - the new value to round this value to.
      Returns:
        a new XBRL numeric value rounded

    - #### 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
        `value` - the value
      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)

      Inferred decimals.
      Parameters:
        `precision` - the precision
        `strValue` - the str value
      Returns:
        integer

    - #### inferredDecimalsBug368

          public static int inferredDecimalsBug368(int precision,
                                   java.lang.String rawStrValue)

      Inferred decimals bug368.
      Parameters:
        `precision` - the precision
        `rawStrValue` - the raw str value
      Returns:
        the int

    - #### inferredPrecision

          public static int inferredPrecision(java.lang.String decimalsStr,
                              java.lang.String strValue)

      Inferred precision.
      Parameters:
        `decimalsStr` - the decimals str
        `strValue` - the str value
      Returns:
        integer

    - #### getExponent

          public static int getExponent(java.lang.String strValue)

      Gets the exponent.
      Parameters:
        `strValue` - capitalized so the exponent will be the number after E
      Returns:
        int

    - #### setPrecision

          public void setPrecision(int precision)

      Sets the precision.
      Parameters:
        `precision` - the new precision

    - #### setDecimals

          public void setDecimals(int decimals)

      Sets the decimals.
      Parameters:
        `decimals` - the new decimals

    - #### setFact

          public void setFact(XBRLFactNumeric factNumeric)

      Description copied from interface: `XBRLNumber`
      Sets the fact.
      Specified by:
        `setFact` in interface `XBRLNumber`
      Parameters:
        `factNumeric` - the new fact

    - #### hashCode

          public int hashCode()

      Description copied from interface: `XBRLNumber`
      Hash code.
      Specified by:
        `hashCode` in interface `XBRLNumber`
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the int

    - #### getBigDecimal

          public java.math.BigDecimal getBigDecimal()

      returns the internal representation of this value as a BigDecimal.
      Returns:
        the big decimal