biz.onixs.fix.parser
Class Message

java.lang.Object
  extended by biz.onixs.fix.parser.Message
All Implemented Interfaces:
FixBlock

public class Message
extends Object
implements FixBlock

FIX message


Field Summary
protected  boolean allowEmptyValues
           
protected static String APPL_VER_ID_ANCHOR
           
protected static byte[] APPL_VER_ID_ANCHOR_BYTES
           
protected static byte[] CHECK_SUM_ANCHOR_BYTES
           
protected  byte[] checksumField
           
protected  biz.onixs.util.ByteBuffer contents
           
protected static ValuePtr DATETIME
           
protected static String DEF_APPL_VER_ID_ANCHOR
           
protected static byte[] DEF_APPL_VER_ID_ANCHOR_BYTES
           
protected  biz.onixs.fix.parser.InstanceDescription descr
           
protected static biz.onixs.fix.parser.StandardDictionary DICTIONARY
           
protected  boolean enableUnknownFields
           
protected  int[] fieldIndexes
           
protected  int[] fieldLengths
           
protected  Group[] groups
           
protected static ValuePtr LOGON_MSG_TYPE
           
protected static ValuePtr MAX_SEQ_NUM
           
protected  String msgType
           
protected static ValuePtr ONE
           
protected  Map<Integer,biz.onixs.fix.parser.Message.UserDefinedField> userFields
           
protected  boolean validateNumInGroupCount
           
protected  Version version
           
protected static ValuePtr ZERO
           
 
Constructor Summary
Message()
           
Message(byte[] rawMessage)
          Parses the raw FIX message and creates the corresponding class instance.
Message(byte[] rawMsg, int length, boolean enableUnknownFields, boolean allowEmptyValues, boolean validateNumInGroupCount, boolean verifyLength, boolean verifyCheckSum)
           
Message(biz.onixs.util.ByteBuffer rawMsg, boolean enableUnknownFields, boolean allowEmptyValues, boolean validateNumInGroupCount, boolean verifyLength, boolean verifyCheckSum)
           
Message(Message rh)
           
Message(String rawMessage)
          Parses the raw FIX message and creates the corresponding class instance.
Message(String rawMessage, boolean enableUnknownFields, boolean allowEmptyValues, boolean validateNumInGroupCount)
           
Message(String type, Version version)
          Creates a message.
Message(String type, Version version, boolean enableUnknownFields)
          Creates a message.
Message(String type, Version version, boolean enableUnknownFields, boolean allowEmptyValues)
          Creates a message.
Message(Version version, byte[] rawMsg, int length, boolean enableUnknownFields, boolean allowEmptyValues, boolean validateNumInGroupCount, boolean verifyLength, boolean verifyCheckSum)
           
Message(Version version, biz.onixs.util.ByteBuffer buffer)
           
Message(Version version, String rawMessage)
          Creates a message.
 
Method Summary
 void assemble(biz.onixs.util.ByteBuffer bb)
           
 boolean contains(int tag)
          Returns whether the field with the specified tag number is set.
 String get(int tag)
          Returns the field value as string.
 boolean get(int tag, ValuePtr valuePtr)
          Returns field value.
 byte[] getBytes(int tag)
          Returns the field value as a byte array.
protected  biz.onixs.fix.parser.InstanceDescriptionImpl getDictionary(String msgType, Version version)
           
 double getDouble(int tag)
          Returns the field value as double.
 Group getGroup(int numberOfInstancesTag)
          Returns the repeating group.
 int getInteger(int tag)
          Returns the field value as integer.
 long getLong(int tag)
          Returns the field value as long.
 String getSenderCompID()
          Returns assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).
 long getSeqNum()
          Returns message sequence number (the MsgSeqNum (tag=34) field value).
 String getTargetCompID()
          Returns assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).
 String getType()
          Returns message type (the MsgType (tag=35) field value).
 boolean getValidateFieldValues()
           
 ValuePtr getValuePtr(int tag)
          Returns the field value.
 Version getVersion()
          Financial Interface eXchange (FIX) protocol version.
 boolean hasFlag(int tag)
          Returns the flag value.
protected  void init()
           
 void init(Message rh)
           
 boolean isOriginal()
           
 boolean isSessionLevel()
           
 boolean remove(int tag)
          Removes the field.
 void reset()
           
 boolean set(int tag, byte[] value)
          Sets field value.
 boolean set(int tag, biz.onixs.util.ByteBuffer buffer)
          Sets the field value.
 boolean set(int tag, double value)
          Sets the field value as double.
 boolean set(int tag, int value)
          Sets the field value as integer.
 boolean set(int tag, long value)
          Sets the long field value.
 boolean set(int tag, String value)
          Sets the field value as string.
 boolean set(int tag, ValuePtr valuePtr)
          Sets field value.
protected  void setCommonFields()
           
 boolean setFlag(int tag, boolean value)
          Sets the flag tag value - "Y" or "N".
 Group setGroup(int numberOfInstancesTag, int numberOfIntances)
          Creates a new repeating group or changes the number of instances in the existing repeatign group.
 void setSenderCompID(String newValue)
          Sets assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).
 void setSeqNum(long value)
          Sets message sequence number (the MsgSeqNum (tag=34) field value).
 void setTargetCompID(String newValue)
          Sets assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).
 void setValidateFieldValues(boolean validateFieldValues)
           
 String toString()
          Returns the <tag>=<value> representation of the message.
 String toString(char delimiter)
          Returns the <tag>=<value> representation of the message using the given delimiter.
 void updateChecksum()
           
 void validate()
          Performs the message validation.
 void validate(boolean validateRequiredFields)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DICTIONARY

protected static final biz.onixs.fix.parser.StandardDictionary DICTIONARY

CHECK_SUM_ANCHOR_BYTES

protected static final byte[] CHECK_SUM_ANCHOR_BYTES

ZERO

protected static final ValuePtr ZERO

ONE

protected static final ValuePtr ONE

LOGON_MSG_TYPE

protected static final ValuePtr LOGON_MSG_TYPE

DATETIME

protected static final ValuePtr DATETIME

MAX_SEQ_NUM

protected static final ValuePtr MAX_SEQ_NUM

APPL_VER_ID_ANCHOR

protected static final String APPL_VER_ID_ANCHOR
See Also:
Constant Field Values

APPL_VER_ID_ANCHOR_BYTES

protected static final byte[] APPL_VER_ID_ANCHOR_BYTES

DEF_APPL_VER_ID_ANCHOR

protected static final String DEF_APPL_VER_ID_ANCHOR
See Also:
Constant Field Values

DEF_APPL_VER_ID_ANCHOR_BYTES

protected static final byte[] DEF_APPL_VER_ID_ANCHOR_BYTES

contents

protected biz.onixs.util.ByteBuffer contents

fieldIndexes

protected int[] fieldIndexes

fieldLengths

protected int[] fieldLengths

groups

protected Group[] groups

version

protected Version version

descr

protected biz.onixs.fix.parser.InstanceDescription descr

userFields

protected Map<Integer,biz.onixs.fix.parser.Message.UserDefinedField> userFields

enableUnknownFields

protected boolean enableUnknownFields

allowEmptyValues

protected boolean allowEmptyValues

validateNumInGroupCount

protected boolean validateNumInGroupCount

checksumField

protected byte[] checksumField

msgType

protected String msgType
Constructor Detail

Message

public Message(biz.onixs.util.ByteBuffer rawMsg,
               boolean enableUnknownFields,
               boolean allowEmptyValues,
               boolean validateNumInGroupCount,
               boolean verifyLength,
               boolean verifyCheckSum)

Message

public Message(byte[] rawMsg,
               int length,
               boolean enableUnknownFields,
               boolean allowEmptyValues,
               boolean validateNumInGroupCount,
               boolean verifyLength,
               boolean verifyCheckSum)

Message

public Message(Version version,
               byte[] rawMsg,
               int length,
               boolean enableUnknownFields,
               boolean allowEmptyValues,
               boolean validateNumInGroupCount,
               boolean verifyLength,
               boolean verifyCheckSum)

Message

public Message(byte[] rawMessage)
Parses the raw FIX message and creates the corresponding class instance.

Parameters:
rawMessage - the raw FIX message (in the <tag>=<value> format)

Message

public Message(Version version,
               biz.onixs.util.ByteBuffer buffer)

Message

public Message(Version version,
               String rawMessage)
Creates a message.

Parameters:
version - FIX version
rawMessage - the raw FIX message (in the <tag>=<value> format)

Message

public Message(String type,
               Version version)
Creates a message.

Parameters:
type - Message type (the MsgType (tag=35) field value)
version - FIX version

Message

public Message(String type,
               Version version,
               boolean enableUnknownFields)
Creates a message.

Parameters:
type - Message type (the MsgType (tag=35) field value)
version - FIX version
enableUnknownFields - flag to enable unknown fields

Message

public Message(String type,
               Version version,
               boolean enableUnknownFields,
               boolean allowEmptyValues)
Creates a message.

Parameters:
type - Message type (the MsgType (tag=35) field value)
version - FIX version
enableUnknownFields - flag to enable unknown fields
allowEmptyValues - flag to allow empty values

Message

public Message()

Message

public Message(Message rh)

Message

public Message(String rawMessage)
Parses the raw FIX message and creates the corresponding class instance.

Parameters:
rawMessage - the raw FIX message (in the <tag>=<value> format)

Message

public Message(String rawMessage,
               boolean enableUnknownFields,
               boolean allowEmptyValues,
               boolean validateNumInGroupCount)
Method Detail

getDictionary

protected biz.onixs.fix.parser.InstanceDescriptionImpl getDictionary(String msgType,
                                                                     Version version)

reset

public void reset()

init

public void init(Message rh)

assemble

public void assemble(biz.onixs.util.ByteBuffer bb)

get

public boolean get(int tag,
                   ValuePtr valuePtr)
Returns field value.

Parameters:
tag - tag number
valuePtr - value pointer
Returns:
whether value is set

getBytes

public byte[] getBytes(int tag)
Returns the field value as a byte array.

Parameters:
tag - tag number
Returns:
field value as a byte array, null if it is not set

getValuePtr

public ValuePtr getValuePtr(int tag)
Returns the field value.

Parameters:
tag - tag number
Returns:
value pointer, use ValuePtr.isSet() to check whether value is set

getVersion

public Version getVersion()
Financial Interface eXchange (FIX) protocol version.

Returns:
The FIX version of the message

get

public String get(int tag)
Returns the field value as string.

Specified by:
get in interface FixBlock
Parameters:
tag - tag number
Returns:
field value as string, null if it is not set

contains

public boolean contains(int tag)
Returns whether the field with the specified tag number is set.

Specified by:
contains in interface FixBlock
Parameters:
tag - field tag number
Returns:
true if the field is set, false if the field is not set or is not defined for this message

getDouble

public double getDouble(int tag)
Returns the field value as double. Whether the value is set or not can be checked using contains(int).

Parameters:
tag - Tag number
Returns:
Field value as double, Double.NaN if it is not set
Throws:
ValueIsIncorrectException - if the value can't be parsed to double

getLong

public long getLong(int tag)
Returns the field value as long. Whether the value is set or not can be checked using contains(int).

Specified by:
getLong in interface FixBlock
Parameters:
tag - tag number
Returns:
field value as long, Long.MAX_VALUE if it is not set
Throws:
ValueIsIncorrectException - if the value can't be parsed to long

set

public boolean set(int tag,
                   biz.onixs.util.ByteBuffer buffer)
Sets the field value.

Specified by:
set in interface FixBlock
Parameters:
tag - field tag number
buffer - field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

set

public boolean set(int tag,
                   ValuePtr valuePtr)
Sets field value.

Specified by:
set in interface FixBlock
Parameters:
tag - tag number
valuePtr - value pointer
Returns:
true if the value was replaced with the new one, and false if a new field was inserted
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

set

public boolean set(int tag,
                   byte[] value)
Sets field value.

Specified by:
set in interface FixBlock
Parameters:
tag - field tag number
value - field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

getInteger

public int getInteger(int tag)
Returns the field value as integer. Whether the value is set or not can be checked using contains(int).

Specified by:
getInteger in interface FixBlock
Parameters:
tag - tag number
Returns:
field value as integer, Integer.MAX_VALUE if it is not set
Throws:
ValueIsIncorrectException - if the value can't be parsed to int

set

public boolean set(int tag,
                   String value)
Sets the field value as string.

Specified by:
set in interface FixBlock
Parameters:
tag - field tag number
value - field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

set

public boolean set(int tag,
                   int value)
Sets the field value as integer.

Specified by:
set in interface FixBlock
Parameters:
tag - Tag number
value - Field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

set

public boolean set(int tag,
                   double value)
Sets the field value as double.

Parameters:
tag - Tag number
value - Field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

set

public boolean set(int tag,
                   long value)
Sets the long field value.

Specified by:
set in interface FixBlock
Parameters:
tag - tag number
value - field value
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

getSenderCompID

public String getSenderCompID()
Returns assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).

Returns:
SenderCompID

setSenderCompID

public void setSenderCompID(String newValue)
Sets assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).

Parameters:
newValue - SenderCompID

getTargetCompID

public String getTargetCompID()
Returns assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).

Returns:
TargetCompID

setTargetCompID

public void setTargetCompID(String newValue)
Sets assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).

Parameters:
newValue - TargetCompID

getType

public String getType()
Returns message type (the MsgType (tag=35) field value).

Returns:
message type

setGroup

public Group setGroup(int numberOfInstancesTag,
                      int numberOfIntances)
Creates a new repeating group or changes the number of instances in the existing repeatign group.

Specified by:
setGroup in interface FixBlock
Parameters:
numberOfInstancesTag - Tag number of the field that defines the number of instances in this repeating group (the NoXXX field)
numberOfIntances - Number of instances in the repeating group
Returns:
Repeating group
Throws:
ParserException - The tag number does not belong to the message

remove

public boolean remove(int tag)
Removes the field.

Parameters:
tag - Tag number
Returns:
true if the field was found and removed, otherwise false

getGroup

public Group getGroup(int numberOfInstancesTag)
Returns the repeating group.

Specified by:
getGroup in interface FixBlock
Parameters:
numberOfInstancesTag - Tag number of the field that defines the number of instances in this repeating group (the NoXXX field)
Returns:
The nested repeating group
Throws:
ParserException - The tag number does not belong to the message

validate

public void validate()
Performs the message validation.

Throws:
ParserException - The message is not valid

validate

public void validate(boolean validateRequiredFields)

getSeqNum

public long getSeqNum()
Returns message sequence number (the MsgSeqNum (tag=34) field value).

Returns:
message sequence number

setSeqNum

public void setSeqNum(long value)
Sets message sequence number (the MsgSeqNum (tag=34) field value).

Parameters:
value - message sequence number

toString

public String toString()
Returns the <tag>=<value> representation of the message.

Overrides:
toString in class Object
Returns:
The raw FIX representation of the message

toString

public String toString(char delimiter)
Returns the <tag>=<value> representation of the message using the given delimiter.

Parameters:
delimiter - The delimiter between the <tag>=<value> pairs
Returns:
raw message

isSessionLevel

public boolean isSessionLevel()

hasFlag

public boolean hasFlag(int tag)
Returns the flag value.

Parameters:
tag - tag number
Returns:
whether field value is equal to "Y" or "y"

setFlag

public boolean setFlag(int tag,
                       boolean value)
Sets the flag tag value - "Y" or "N".

Parameters:
tag - the tag number
value - true for "Y", false for "N"
Returns:
whether there was a previous value
Throws:
TagNotDefinedForThisMessageTypeException - if field with the specified tag is not defined for this message and unknown fields are disabled

isOriginal

public boolean isOriginal()

setValidateFieldValues

public void setValidateFieldValues(boolean validateFieldValues)

getValidateFieldValues

public boolean getValidateFieldValues()

init

protected void init()

setCommonFields

protected void setCommonFields()

updateChecksum

public void updateChecksum()


Copyright © 2005-2012 Onix Solutions. All Rights Reserved.