Esempio n. 1
0
 /* Global dictionary, read only once:
  * com.reuters.tibmsg.TibException: Specified data dictionary has already been loaded/unpacked
  */
 static {
   Context.initialize();
   dictionary = FieldDictionary.create();
   FieldDictionary.readRDMFieldDictionary(dictionary, "RDMFieldDictionary");
   FieldDictionary.readEnumTypeDef(dictionary, "enumtype.def");
   biddef = dictionary.getFidDef("BID");
   askdef = dictionary.getFidDef("ASK");
 }
  /**
   * This method should be called one before parsing and data.
   *
   * @param fieldDictionaryFilename
   * @param enumDictionaryFilename
   * @throws DictionaryException if an error has occurred
   */
  public static void initializeDictionary(
      String fieldDictionaryFilename, String enumDictionaryFilename) throws DictionaryException {
    FieldDictionary dictionary = FieldDictionary.create();
    try {
      FieldDictionary.readRDMFieldDictionary(dictionary, fieldDictionaryFilename);
      System.out.println("field dictionary read from RDMFieldDictionary file");

      FieldDictionary.readEnumTypeDef(dictionary, enumDictionaryFilename);
      System.out.println("enum dictionary read from enumtype.def file");

      initializeDictionary(dictionary);
    } catch (DictionaryException e) {
      throw new DictionaryException(
          "ERROR: Check if files "
              + fieldDictionaryFilename
              + " and "
              + enumDictionaryFilename
              + " exist and are readable.",
          e);
    }
  }
Esempio n. 3
0
 /* BID            : REAL      8 : 21.42 <18>		// TSS_HINT_DECIMAL_2
  * ASK            : REAL      8 : 21.43 <18>
  * BIDSIZE        : REAL      8 : 7.0 <0>		// TSS_HINT_DENOM_NONE
  * ASKSIZE        : REAL      8 : 7.0 <0>
  * PRC_QL_CD      : STRING    1 : "0" <261>		// TSS_HINT_MFEED_ENUMERATED
  * BID_MMID1      : STRING    4 : "NAS "
  * ASK_MMID1      : STRING    4 : "NAS "
  * GV1_TEXT       : STRING    6 : "A     "
  * QUOTIM         : STRING    8 : "14:33:44" <260>	// TSS_HINT_MFEED_TIME_SECONDS
  * PRC_QL3        : STRING    1 : "0" <261>
  * QUOTIM_MS      : REAL      8 : 5.2424789E7 <0>
  *
  * <!-- rwfMajorVer="14" rwfMinorVer="0" -->
  * <updateMsg domainType="RSSL_DMT_MARKET_PRICE" streamId="5" containerType="RSSL_DT_FIELD_LIST" flags="0x10 (RSSL_UPMF_HAS_SEQ_NUM)" updateType="1" seqNum="3632" dataSize="70">
  *     <dataBody>
  *         <fieldList flags="0x8 (RSSL_FLF_HAS_STANDARD_DATA)">
  *             <fieldEntry fieldId="22" dataType="RSSL_DT_REAL" data="21.42"/>
  *             <fieldEntry fieldId="25" dataType="RSSL_DT_REAL" data="21.43"/>
  *             <fieldEntry fieldId="30" dataType="RSSL_DT_REAL" data="7"/>
  *             <fieldEntry fieldId="31" dataType="RSSL_DT_REAL" data="7"/>
  *             <fieldEntry fieldId="118" dataType="RSSL_DT_ENUM" data="0"/>
  *             <fieldEntry fieldId="293" dataType="RSSL_DT_RMTES_STRING" data="NAS"/>
  *             <fieldEntry fieldId="296" dataType="RSSL_DT_RMTES_STRING" data="NAS"/>
  *             <fieldEntry fieldId="1000" dataType="RSSL_DT_RMTES_STRING" data="A"/>
  *             <fieldEntry fieldId="1025" dataType="RSSL_DT_TIME" data=" 14:33:44:000"/>
  *             <fieldEntry fieldId="3264" dataType="RSSL_DT_ENUM" data="0"/>
  *             <fieldEntry fieldId="3855" dataType="RSSL_DT_UINT" data="52424789"/>
  *         </fieldList>
  *     </dataBody>
  * </updateMsg>
  */
 @SuppressWarnings("unchecked")
 @BeforeExperiment
 void setUp() {
   pool =
       OMMPool.create(
           "RWF", 14, /* RWF major version */ 0, /* RWF minor version */ OMMPool.SINGLE_THREADED);
   OMMEncoder encoder = pool.acquireEncoder();
   encoder.initialize(OMMTypes.MSG, 500);
   msg = pool.acquireMsg();
   msg.setMsgType(OMMMsg.MsgType.UPDATE_RESP);
   msg.setMsgModelType(RDMMsgTypes.MARKET_PRICE);
   msg.setSeqNum(3632);
   msg.setRespTypeNum(RDMInstrument.Update.QUOTE);
   encoder.encodeMsgInit(msg, OMMTypes.NO_DATA, OMMTypes.FIELD_LIST);
   encoder.encodeFieldListInit(
       OMMFieldList.HAS_STANDARD_DATA,
       (short) 1, /* dictionaryId */
       (short) 78, /* fieldListNumber */
       (short) 0); /* dataDefId */
   final ImmutableMap<String, FidDef> dict = ImmutableMap.copyOf(dictionary.toNameMap());
   encoder.encodeFieldEntryInit(dict.get("BID").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal((long) (21.42 * 100), OMMNumeric.EXPONENT_NEG2);
   encoder.encodeFieldEntryInit(dict.get("ASK").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal((long) (21.43 * 100), OMMNumeric.EXPONENT_NEG2);
   encoder.encodeFieldEntryInit(dict.get("BIDSIZE").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal(7L, OMMNumeric.EXPONENT_0);
   encoder.encodeFieldEntryInit(dict.get("ASKSIZE").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal(7L, OMMNumeric.EXPONENT_0);
   encoder.encodeFieldEntryInit(dict.get("PRC_QL_CD").getFieldId(), OMMTypes.ENUM);
   encoder.encodeEnum(0);
   encoder.encodeFieldEntryInit(dict.get("BID_MMID1").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("NAS", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("ASK_MMID1").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("NAS", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("GV1_TEXT").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("A", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("QUOTIM").getFieldId(), OMMTypes.TIME);
   encoder.encodeTime(14, 33, 44, 0);
   encoder.encodeFieldEntryInit(dict.get("PRC_QL3").getFieldId(), OMMTypes.ENUM);
   encoder.encodeEnum(0);
   encoder.encodeFieldEntryInit(dict.get("QUOTIM_MS").getFieldId(), OMMTypes.UINT);
   encoder.encodeUInt(52424789L);
   encoder.encodeAggregateComplete();
   msg = (OMMMsg) encoder.getEncodedObject();
 }
 // This method can be used to initialize a downloaded dictionary
 public static synchronized void initializeDictionary(FieldDictionary dict) {
   int dictId = dict.getDictId();
   if (dictId == 0) dictId = 1; // dictId == 0 is the same as dictId 1
   DICTIONARIES.put(new Integer(dictId), dict);
 }
 private static final void parseEntry(OMMEntry entry, PrintStream ps, int tabLevel) {
   try {
     switch (entry.getType()) {
       case OMMTypes.FIELD_ENTRY:
         {
           OMMFieldEntry fe = (OMMFieldEntry) entry;
           if (CURRENT_DICTIONARY != null) {
             FidDef fiddef = CURRENT_DICTIONARY.getFidDef(fe.getFieldId());
             if (fiddef != null) {
               dumpFieldEntryHeader(fe, fiddef, ps, tabLevel);
               OMMData data = null;
               if (fe.getDataType() == OMMTypes.UNKNOWN) data = fe.getData(fiddef.getOMMType());
               else
                 // defined data already has type
                 data = fe.getData();
               if (data.getType() == OMMTypes.ENUM) {
                 ps.print(
                     CURRENT_DICTIONARY.expandedValueFor(
                         fiddef.getFieldId(), ((OMMEnum) data).getValue()));
                 ps.print(" (");
                 ps.print(data);
                 ps.println(")");
               } else parseData(data, ps, tabLevel);
             } else {
               ps.println(
                   "Received field id: " + fe.getFieldId() + " - Not defined in dictionary");
             }
           } else {
             dumpFieldEntryHeader(fe, null, ps, tabLevel);
             if (fe.getDataType() == OMMTypes.UNKNOWN) {
               OMMDataBuffer data = (OMMDataBuffer) fe.getData();
               ps.println(HexDump.toHexString(data.getBytes(), false));
             } else
             // defined data already has type
             {
               OMMData data = fe.getData();
               parseData(data, ps, tabLevel);
             }
           }
           ps.flush();
         }
         break;
       case OMMTypes.ELEMENT_ENTRY:
         dumpElementEntryHeader((OMMElementEntry) entry, ps, tabLevel);
         parseData(entry.getData(), ps, tabLevel);
         break;
       case OMMTypes.MAP_ENTRY:
         dumpMapEntryHeader((OMMMapEntry) entry, ps, tabLevel);
         if ((((OMMMapEntry) entry).getAction() != OMMMapEntry.Action.DELETE)
             && entry.getDataType() != OMMTypes.NO_DATA) parseData(entry.getData(), ps, tabLevel);
         break;
       case OMMTypes.VECTOR_ENTRY:
         dumpVectorEntryHeader((OMMVectorEntry) entry, ps, tabLevel);
         if ((((OMMVectorEntry) entry).getAction() != OMMVectorEntry.Action.DELETE)
             && (((OMMVectorEntry) entry).getAction() != OMMVectorEntry.Action.CLEAR))
           parseData(entry.getData(), ps, tabLevel);
         break;
       case OMMTypes.FILTER_ENTRY:
         dumpFilterEntryHeader((OMMFilterEntry) entry, ps, tabLevel);
         if (((OMMFilterEntry) entry).getAction() != OMMFilterEntry.Action.CLEAR)
           parseData(entry.getData(), ps, tabLevel);
         break;
       default:
         dumpEntryHeader(entry, ps, tabLevel);
         parseData(entry.getData(), ps, tabLevel);
         break;
     }
   } catch (OMMException e) {
     ps.println("ERROR Invalid data: " + e.getMessage());
   }
 }