Example #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");
 }
 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());
   }
 }