com.devexperts.qd.kit
Class DecimalField

java.lang.Object
  extended by com.devexperts.qd.kit.DecimalField
All Implemented Interfaces:
DataField, DataIntField

public class DecimalField
extends java.lang.Object

The DecimalField represents a decimal field with compact serialized form. See Decimal for description of internal representation. It can be used for fields which are usually represented with floating point values, such as prices, amounts, etc.


Constructor Summary
DecimalField(int index, java.lang.String name)
           
 
Method Summary
 boolean equals(int value1, int value2)
          Compares two specified field values for equality.
 int getIndex()
          Returns index of this field in its parent DataRecord.
 java.lang.String getLocalName()
          Returns local name of this field -- the name of this field that is unique withing the record.
 java.lang.String getName()
          Returns name of this field.
 DataRecord getRecord()
          Returns parent DataRecord of this field.
 SerialFieldType getSerialType()
          Returns serial type of this field.
 int parseString(java.lang.String value)
          Parses string representation of specified field value.
 int readInt(java.io.DataInput in)
          Reads field value from specified data intput and returns it to the caller.
protected  int readIntFast(com.devexperts.io.BufferedInput in)
           
 void setRecord(DataRecord record)
          Sets reference to parent data record.
 double toDouble(int value)
          Converts raw QD int-value to meaningful double value, or to Double.NaN if inapplicable.
 int toInt(double value)
          Converts meaningful double value to raw QD int-value, or to 0 if inapplicable.
 java.lang.String toString()
           
 java.lang.String toString(int value)
          Returns string representation of specified field value.
 void writeInt(java.io.DataOutput out, int value)
          Writes specified field value into specified data output.
protected  void writeIntFast(com.devexperts.io.BufferedOutput out, int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.devexperts.qd.DataField
getIndex, getLocalName, getName, getRecord
 

Constructor Detail

DecimalField

public DecimalField(int index,
                    java.lang.String name)
Method Detail

toString

public java.lang.String toString(int value)
Returns string representation of specified field value. This method is used for debugging purposes. This implementation returns Integer.toString(value).

Specified by:
toString in interface DataIntField

parseString

public int parseString(java.lang.String value)
Parses string representation of specified field value. This method is used for debugging purposes. This implementation returns Integer.parseInt(value).

Specified by:
parseString in interface DataIntField

toDouble

public double toDouble(int value)
Converts raw QD int-value to meaningful double value, or to Double.NaN if inapplicable.

Specified by:
toDouble in interface DataIntField

toInt

public int toInt(double value)
Converts meaningful double value to raw QD int-value, or to 0 if inapplicable.

Specified by:
toInt in interface DataIntField

writeInt

public final void writeInt(java.io.DataOutput out,
                           int value)
                    throws java.io.IOException
Writes specified field value into specified data output.

Specified by:
writeInt in interface DataIntField
Throws:
java.io.IOException - as specified data output does.

writeIntFast

protected final void writeIntFast(com.devexperts.io.BufferedOutput out,
                                  int value)
                           throws java.io.IOException
Throws:
java.io.IOException

readInt

public final int readInt(java.io.DataInput in)
                  throws java.io.IOException
Reads field value from specified data intput and returns it to the caller.

Specified by:
readInt in interface DataIntField
Throws:
java.io.IOException - as specified data input does.

readIntFast

protected final int readIntFast(com.devexperts.io.BufferedInput in)
                         throws java.io.IOException
Throws:
java.io.IOException

getSerialType

public final SerialFieldType getSerialType()
Description copied from interface: DataField
Returns serial type of this field. It describes the serialized form of this field in QTP protocol with enough detail to skip the serialized value of this field if neccessary.


equals

public boolean equals(int value1,
                      int value2)
Compares two specified field values for equality. This method is used for implementation of ticker contract. This implementation returns value1 == value2.

Specified by:
equals in interface DataIntField

setRecord

public final void setRecord(DataRecord record)
Sets reference to parent data record.

Throws:
java.lang.IllegalStateException - if parent record already set to different instance.

toString

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

getRecord

public final DataRecord getRecord()
Description copied from interface: DataField
Returns parent DataRecord of this field.

Specified by:
getRecord in interface DataField

getIndex

public final int getIndex()
Description copied from interface: DataField
Returns index of this field in its parent DataRecord.

Specified by:
getIndex in interface DataField

getName

public final java.lang.String getName()
Description copied from interface: DataField
Returns name of this field. The name must be unique within the whole DataScheme. It is required that this full field name consists of its parent record name followed by dot ('.') followed by local name of this filed like these: "FooRecord.Category", "FooRecord.Amount", etc.

Specified by:
getName in interface DataField

getLocalName

public java.lang.String getLocalName()
Description copied from interface: DataField
Returns local name of this field -- the name of this field that is unique withing the record.

Specified by:
getLocalName in interface DataField
See Also:
DataField.getName()