org.jclarion.clarion
Class ClarionDecimal

java.lang.Object
  extended by org.jclarion.clarion.ClarionMemoryModel
      extended by org.jclarion.clarion.ClarionObject
          extended by org.jclarion.clarion.ClarionDecimal
All Implemented Interfaces:
Threaded

public class ClarionDecimal
extends ClarionObject

Model decimal. Internall stored as java.math.BigDecimal

Author:
barney

Nested Class Summary
static class ClarionDecimal.State
           
 
Field Summary
static int DECIMAL
           
static int PDECIMAL
           
 
Constructor Summary
ClarionDecimal()
          Create new clarion decimal.
ClarionDecimal(java.math.BigDecimal value)
           
ClarionDecimal(ClarionDecimal base, java.lang.Thread lock)
           
ClarionDecimal(int value)
          Create new clarion decimal with given size and zero precision.
ClarionDecimal(int size, int precision)
          Create new clarion decimal with given size and precision.
ClarionDecimal(int size, int precision, java.lang.Object value)
          Create new clarion decimal with given size and precision and value
ClarionDecimal(java.lang.String value)
          Create new clarion decimal with given value.
 
Method Summary
 ClarionDecimal abs()
          Return absolute value
 ClarionObject add(ClarionObject object)
          Do a numeric add.
 boolean boolValue()
          Return boolen representation of the object
 void clear(int method)
          Clear object value.
 int compareTo(ClarionObject object)
          Do a Comparison.
 void deserialize(java.io.InputStream is)
          Read object from memory as clarion would represent object in memory
 ClarionDecimal[] dim(int size)
          return array clone of the object based on size.
 ClarionDecimal[][] dim(int s1, int s2)
          return 2d array clone of the object based on size.
 ClarionObject divide(ClarionObject object)
          Do a numeric divide.
 ClarionObject genericLike()
           
 ClarionBool getBool()
          Convert to bool object
 ClarionDecimal getDecimal()
          Convert to decimal object
 java.lang.Object getLockedObject(java.lang.Thread t)
           
 ClarionNumber getNumber()
          Convert to number object
 int getPrecision()
           
 ClarionReal getReal()
          Convert to real object
 int getSize()
          Return max size of the object when represented as a string Used mainly by ASCII file driver
 ClarionString getString()
          Convert to string object
 void initThread()
           
 int intValue()
          Return integer representation of the object
 boolean isConstrained()
           
 boolean isDecimal()
           
 ClarionDecimal like()
          clone object
 ClarionObject modulus(ClarionObject object)
          Do a numeric modulus.
 ClarionObject multiply(ClarionObject object)
          Do a numeric multiply.
 ClarionObject negate()
          Do a numeric negation.
 ClarionObject power(ClarionObject object)
          Do a numeric power.
 ClarionDecimal round(ClarionObject object)
          Return rounded value.
 ClarionDecimal round(java.lang.Object object)
           
 void serialize(java.io.OutputStream is)
          Decimal encoding is based on nybbles.
 ClarionDecimal setEncoding(int encoding)
          Set memory model for encoding this object.
 ClarionDecimal setName(java.lang.String name)
          Set external name, used by sql drivers etc
 ClarionDecimal setOver(ClarionMemoryModel object)
          Overlay this object with specified object
 ClarionDecimal setThread()
           
 void setValue(ClarionObject object)
          Set object to given value
 ClarionObject subtract(ClarionObject object)
          Do a numeric subtract.
 java.math.BigDecimal toBigDecimal()
           
 java.lang.String toString()
           
 
Methods inherited from class org.jclarion.clarion.ClarionObject
add, clear, clearNull, compareTo, concat, concatSegment, decrement, decrement, divide, doSetName, doSetOver, doSetOver, equals, gcd, getName, getOwner, getValue, increment, increment, modulus, multiply, power, setNull, setOver, setOwner, setValue, stringAt, stringAt, stringAt, stringAt, subtract
 
Methods inherited from class org.jclarion.clarion.ClarionMemoryModel
addChangeListener, addChangeListener, castTo, getListenerCount, isAnyoneInterestedInChange, isThreaded, lock, notifyChange, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DECIMAL

public static final int DECIMAL
See Also:
Constant Field Values

PDECIMAL

public static final int PDECIMAL
See Also:
Constant Field Values
Constructor Detail

ClarionDecimal

public ClarionDecimal(ClarionDecimal base,
                      java.lang.Thread lock)

ClarionDecimal

public ClarionDecimal()
Create new clarion decimal. Unbounded size and precision. Defaults to 0


ClarionDecimal

public ClarionDecimal(java.lang.String value)
Create new clarion decimal with given value. Size and precision are unbounded


ClarionDecimal

public ClarionDecimal(java.math.BigDecimal value)

ClarionDecimal

public ClarionDecimal(int value)
Create new clarion decimal with given size and zero precision. Default value is 0


ClarionDecimal

public ClarionDecimal(int size,
                      int precision)
Create new clarion decimal with given size and precision. Default value is 0


ClarionDecimal

public ClarionDecimal(int size,
                      int precision,
                      java.lang.Object value)
Create new clarion decimal with given size and precision and value

Method Detail

initThread

public void initThread()
Specified by:
initThread in interface Threaded
Overrides:
initThread in class ClarionMemoryModel

getLockedObject

public java.lang.Object getLockedObject(java.lang.Thread t)

getSize

public int getSize()
Description copied from class: ClarionObject
Return max size of the object when represented as a string Used mainly by ASCII file driver

Specified by:
getSize in class ClarionObject
Returns:

getPrecision

public int getPrecision()

isConstrained

public boolean isConstrained()
Specified by:
isConstrained in class ClarionObject

toBigDecimal

public java.math.BigDecimal toBigDecimal()

setThread

public ClarionDecimal setThread()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

like

public ClarionDecimal like()
clone object

Returns:

dim

public ClarionDecimal[] dim(int size)
return array clone of the object based on size. Note java object array returned is one larger than specified as clarion starts arrays at offset '1' whilst java as offset '0'

Parameters:
size -
Returns:

dim

public ClarionDecimal[][] dim(int s1,
                              int s2)
return 2d array clone of the object based on size. Note java object array returned is one larger than specified as clarion starts arrays at offset '1' whilst java as offset '0'


add

public ClarionObject add(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric add. Result is returned as a new object

Specified by:
add in class ClarionObject
Returns:

compareTo

public int compareTo(ClarionObject object)
Description copied from class: ClarionObject
Do a Comparison. Comparison type is preferentially numeric but if either object is a non numeric string then comparsion is a lexical comparison

Specified by:
compareTo in class ClarionObject
Returns:

intValue

public int intValue()
Description copied from class: ClarionObject
Return integer representation of the object

Specified by:
intValue in class ClarionObject
Returns:

multiply

public ClarionObject multiply(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric multiply. Result is returned as a new object

Specified by:
multiply in class ClarionObject
Returns:

setValue

public void setValue(ClarionObject object)
Description copied from class: ClarionObject
Set object to given value

Specified by:
setValue in class ClarionObject

getBool

public ClarionBool getBool()
Description copied from class: ClarionObject
Convert to bool object

Specified by:
getBool in class ClarionObject
Returns:

getNumber

public ClarionNumber getNumber()
Description copied from class: ClarionObject
Convert to number object

Specified by:
getNumber in class ClarionObject
Returns:

getReal

public ClarionReal getReal()
Description copied from class: ClarionObject
Convert to real object

Specified by:
getReal in class ClarionObject
Returns:

getString

public ClarionString getString()
Description copied from class: ClarionObject
Convert to string object

Specified by:
getString in class ClarionObject
Returns:

divide

public ClarionObject divide(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric divide. Result is returned as a new object

Specified by:
divide in class ClarionObject
Returns:

modulus

public ClarionObject modulus(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric modulus. Result is returned as a new object

Specified by:
modulus in class ClarionObject
Returns:

power

public ClarionObject power(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric power. Result is returned as a new object

Specified by:
power in class ClarionObject
Returns:

subtract

public ClarionObject subtract(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric subtract. Result is returned as a new object

Specified by:
subtract in class ClarionObject
Returns:

boolValue

public boolean boolValue()
Description copied from class: ClarionObject
Return boolen representation of the object

Specified by:
boolValue in class ClarionObject
Returns:

clear

public void clear(int method)
Description copied from class: ClarionObject
Clear object value.

Specified by:
clear in class ClarionObject

negate

public ClarionObject negate()
Description copied from class: ClarionObject
Do a numeric negation. Result is returned as a new object

Specified by:
negate in class ClarionObject
Returns:

getDecimal

public ClarionDecimal getDecimal()
Description copied from class: ClarionObject
Convert to decimal object

Specified by:
getDecimal in class ClarionObject
Returns:

setName

public ClarionDecimal setName(java.lang.String name)
Set external name, used by sql drivers etc

Parameters:
name -
Returns:

setEncoding

public ClarionDecimal setEncoding(int encoding)
Set memory model for encoding this object. Two options exists DECIMAL and PDECIMAL

Parameters:
encoding -
Returns:

abs

public ClarionDecimal abs()
Return absolute value

Returns:

round

public ClarionDecimal round(ClarionObject object)
Return rounded value. Rounding to nearest value specified by object. This implementation differs from Clarion implementation in that it will round to nearest multiple of the value. i.e. rounding to 0.55 will round to nearest multiple of 0.55, whereas clarion will convert 0.55 to '1' and round to that. Rounding is Half Up based rounding.

Parameters:
object -
Returns:

round

public ClarionDecimal round(java.lang.Object object)

setOver

public ClarionDecimal setOver(ClarionMemoryModel object)
Overlay this object with specified object

Parameters:
object -
Returns:

deserialize

public void deserialize(java.io.InputStream is)
                 throws java.io.IOException
Description copied from class: ClarionMemoryModel
Read object from memory as clarion would represent object in memory

Specified by:
deserialize in class ClarionMemoryModel
Throws:
java.io.IOException

serialize

public void serialize(java.io.OutputStream is)
               throws java.io.IOException
Decimal encoding is based on nybbles. Nybble 0 = sign Nybble 1 = MSD (most significant decimal) Nybble 2 = LSD (least significant decimal) Decimal always encodes odd # of places.

Specified by:
serialize in class ClarionMemoryModel
Throws:
java.io.IOException

isDecimal

public boolean isDecimal()
Overrides:
isDecimal in class ClarionObject

genericLike

public ClarionObject genericLike()
Specified by:
genericLike in class ClarionObject


Copyright © 2010. All Rights Reserved.