Basic concept
The Fixopaedia is a high-level mechanism for FixMessage manipulation. It is responsible for:
- Collecting all information about supported versions of the FIX protocol.
- Providing a set of interfaces, which gives access to FixMessage structural parts.
FIX Dictionary
The FixDictionary is a storage of meta-data which describes different versions and dialects of the FIX protocol. The format of FixDictionary structure description is XML. The FixDictionary allows to load protocol descriptions dynamically. It provides the following information about the FIX Protocol elements:
- Message
- Group
- Block
- Field
- Reference to the list of child elements
Create and start
The FixDictionary object can be created in a common way.
For example:
final SAXUnmarshaler
<Fixdic> saxUnmapshaler = new SAXUnmarshaler
<Fixdic>();
final XMLEngine
<Fixdic> engine = new XMLEngineImpl
<Fixdic>(saxUnmapshaler);
final InputStream xml = Thread.currentThread().getContextClassLoader().getResourceAsStream(dictName);
if (xml == null) {
throw new RuntimeException("Unable to locate requested dictionary '" + dictName
+ "' in the application classpath");
}
Fixdic fixdic = engine.unmarshal(Fixdic.class, SAXReader.createReader(xml, saxUnmapshaler), true);
Search for the FIX protocol elements
You can get lists of messages
List
<Msgdef> messages = fixdic.getMsgdic().getMsgdef();
, blocks
List
<Blockdef> blocks = fixdic.getMsgdic().getBlockdef();
, fields
List
<Fielddef> fields = fixdic.getFielddic().getFielddef();
from Fixdic.
If you need a particular message you have to iterate through the list to find it.
You can get fields, blocks and groups from the message by calling the message.getFieldOrDescrOrAlias()method. It returns a list containing all children, so you need to iterate through it and check element types.
For example, to process all groups in message:
Msgdef message = ...
for (Object obj : message.getFieldOrDescrOrAlias()) {
if (obj instanceof Group){
Group gr = (Group) obj;
doSomethingWithGroup(gr);
}
}
The other way to work with dictionary is to get instance of FIXUtil:
FIXVersionContainer fixVersionContainer =
FIXVersionContainer.getFIXVersionContainer(FIXVersion.FIX44);
FIXUtil fixUtil = FIXUtilFactory.getInstance().getFIXUtil(fixVersionContainer);
Msgdef orderDefinition = fixUtil.getMessageDefUtils().get("D");
List
<Integer> requiredTagsForMessage = fixUtil.getRequiredTagsForMessage("D");