net.sf.cb2java.copybook.data
Class FloatingData

java.lang.Object
  extended bynet.sf.cb2java.copybook.data.Data
      extended bynet.sf.cb2java.copybook.data.ValueData
          extended bynet.sf.cb2java.copybook.data.FloatingData

public class FloatingData
extends ValueData

Floating point representations are hardware specific so the precision that is supported by the underlying type may vary from platform to platform. For most normal uses Java floats or doubles should be safe to use but it's possible that there may be a loss of precision if the underlying platform does not follow the IEEE 754 spec.

Because not all floating types are the same in COBOL BigDecimal is the 'natural' type for this class, however, numbers with fraction portions that are not representable in binary will be rounded on setting the data.

Author:
James Watson

Constructor Summary
FloatingData(Floating definition)
          constructor
 
Method Summary
 java.math.BigDecimal getBigDecimal()
          gets the big decimal representation of the value
protected  double getDouble()
          returns the internal data as a BigDecimal
protected  float getFloat()
          returns the internal data as a BigDecimal
 java.lang.Object getValue()
          returns the internal data as a BigDecimal
 void setValue(java.math.BigDecimal data)
           
 void setValueImpl(java.lang.Object data)
          called by setData after validate is called
 java.lang.String toString()
           
protected  java.lang.Object translate(java.lang.String data)
          Converts the String to the underlying Data type's 'natural' type.
 
Methods inherited from class net.sf.cb2java.copybook.data.ValueData
getChildren, isLeaf, toString
 
Methods inherited from class net.sf.cb2java.copybook.data.Data
getDefinition, getName, setValue, setValue, validate, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FloatingData

public FloatingData(Floating definition)
constructor

Parameters:
definition - the underlying definition for the type in the copybook defintion
Method Detail

getBigDecimal

public java.math.BigDecimal getBigDecimal()
gets the big decimal representation of the value


setValueImpl

public void setValueImpl(java.lang.Object data)
Description copied from class: Data
called by setData after validate is called

Specified by:
setValueImpl in class Data
Parameters:
data - the data to set

setValue

public void setValue(java.math.BigDecimal data)

toString

public java.lang.String toString()
Specified by:
toString in class ValueData

getValue

public java.lang.Object getValue()
returns the internal data as a BigDecimal

Specified by:
getValue in class Data

getFloat

protected float getFloat()
returns the internal data as a BigDecimal


getDouble

protected double getDouble()
returns the internal data as a BigDecimal


translate

protected java.lang.Object translate(java.lang.String data)
Description copied from class: Data
Converts the String to the underlying Data type's 'natural' type. The String must be understood by the data type.

Specified by:
translate in class Data
Parameters:
data - the string to use to set this data's value
Returns:
an instance of the Data type's 'natural' type