예제 #1
0
  public static final void parseAnsiPageData(OMMData data, PrintStream ps, int tabLevel) {
    boolean newPage = false;
    if (CURRENT_PAGE == null) {
      CURRENT_PAGE = new Page();
      newPage = true;
    }

    Vector<PageUpdate> pageUpdates = new Vector<PageUpdate>();
    ByteArrayInputStream bais = new ByteArrayInputStream(data.getBytes());
    CURRENT_PAGE.decode(bais, pageUpdates);
    if (newPage) ps.println(CURRENT_PAGE.toString()); // print the page if it is a refresh message
    else {
      // print the update string
      Iterator<PageUpdate> iter = pageUpdates.iterator();
      while (iter.hasNext()) {
        PageUpdate u = (PageUpdate) iter.next();
        StringBuilder buf = new StringBuilder(80);
        for (short k = u.getBeginningColumn(); k < u.getEndingColumn(); k++) {
          buf.append(CURRENT_PAGE.getChar(u.getRow(), k));
        }
        if (!(buf.toString()).equalsIgnoreCase("")) {
          dumpIndent(ps, tabLevel);
          ps.println(
              "Update String: "
                  + buf.toString()
                  + " (Row: "
                  + u.getRow()
                  + ", Begin Col: "
                  + u.getBeginningColumn()
                  + ", End Col: "
                  + u.getEndingColumn()
                  + ")");
        }
      }
    }
  }
예제 #2
0
  private static final void parseAggregateHeader(OMMData data, PrintStream ps, int tabLevel) {
    dumpIndent(ps, tabLevel);
    short dataType = data.getType();
    ps.println(OMMTypes.toString(dataType));
    switch (dataType) {
      case OMMTypes.FIELD_LIST:
        {
          // set DICTIONARY to the dictId for this field list
          OMMFieldList fieldList = (OMMFieldList) data;
          int dictId = fieldList.getDictId();
          CURRENT_DICTIONARY = getDictionary(dictId);
        }
        break;
      case OMMTypes.SERIES:
        {
          OMMSeries s = (OMMSeries) data;
          if (s.has(OMMSeries.HAS_SUMMARY_DATA)) {
            dumpIndent(ps, tabLevel + 1);
            ps.println("SUMMARY");
            parseData(s.getSummaryData(), ps, tabLevel + 1);
          }
          if (s.has(OMMSeries.HAS_DATA_DEFINITIONS)) {
            dumpIndent(ps, tabLevel + 1);
            short dbtype =
                s.getDataType() == OMMTypes.FIELD_LIST
                    ? OMMTypes.FIELD_LIST_DEF_DB
                    : OMMTypes.ELEMENT_LIST_DEF_DB;
            parseDataDefinition(s.getDataDefs(), dbtype, ps, tabLevel + 1);
          }
        }
        break;
      case OMMTypes.MAP:
        {
          OMMMap s = (OMMMap) data;

          String flagsString = ExampleUtil.mapFlagsString(s);
          dumpIndent(ps, tabLevel);
          ps.print("flags: ");
          ps.println(flagsString);

          if (s.has(OMMMap.HAS_SUMMARY_DATA)) {
            dumpIndent(ps, tabLevel + 1);
            ps.println("SUMMARY");
            parseData(s.getSummaryData(), ps, tabLevel + 1);
          }
        }
        break;
      case OMMTypes.VECTOR:
        {
          OMMVector s = (OMMVector) data;

          String flagsString = ExampleUtil.vectorFlagsString(s);
          dumpIndent(ps, tabLevel);
          ps.print("flags: ");
          ps.println(flagsString);

          if (s.has(OMMVector.HAS_SUMMARY_DATA)) {
            dumpIndent(ps, tabLevel + 1);
            ps.println("SUMMARY");
            parseData(s.getSummaryData(), ps, tabLevel + 1);
          }
        }
        break;
      case OMMTypes.FILTER_LIST:
        {
          OMMFilterList s = (OMMFilterList) data;

          String flagsString = ExampleUtil.filterListFlagsString(s);
          dumpIndent(ps, tabLevel);
          ps.print("flags: ");
          ps.println(flagsString);
        }
        break;
    }
  }
예제 #3
0
 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());
   }
 }
예제 #4
0
  /** parse data and print it in a table-nested format to the provided PrintStream */
  public static final void parseData(OMMData data, PrintStream ps, int tabLevel) {
    if (data.isBlank()) dumpBlank(ps);
    else if (OMMTypes.isAggregate(data.getType())) parseAggregate(data, ps, tabLevel + 1);
    else if ((data.getType() == OMMTypes.RMTES_STRING)
        && ((OMMDataBuffer) data).hasPartialUpdates()) {
      Iterator iter = ((OMMDataBuffer) data).partialUpdateIterator();
      while (true) {
        OMMDataBuffer partial = (OMMDataBuffer) iter.next();
        ps.print("hpos: ");
        ps.print(partial.horizontalPosition());
        ps.print(", ");
        ps.print(partial.toString());
        if (iter.hasNext()) ps.print("  |  ");
        else break;
      }
      ps.println();
    } else if (data.getType() == OMMTypes.ANSI_PAGE) {
      // process ANSI with com.reuters.rfa.ansipage
      parseAnsiPageData(data, ps, tabLevel);
    } else if (data.getType() == OMMTypes.BUFFER || data.getType() == OMMTypes.OPAQUE_BUFFER) {
      if (data.getEncodedLength() <= 20) {
        dumpIndent(ps, tabLevel + 1);
        // for small strings, print hex and try to print ASCII
        ps.print(HexDump.toHexString(((OMMDataBuffer) data).getBytes(), false));
        ps.print(" | ");
        ps.println(data);
      } else {
        if (INTERNAL_DEBUG) {
          ps.println("Hex Format and Data Bytes: ");
          ps.println(HexDump.hexDump(((OMMDataBuffer) data).getBytes(), 50));

          ps.println("Hex Format: ");
        }

        int lineSize = 32;
        String s = HexDump.toHexString(((OMMDataBuffer) data).getBytes(), false);

        int j = 0;
        while (j < s.length()) {
          if (j != 0) ps.println();

          dumpIndent(ps, 1);

          int end = j + lineSize;
          if (end >= s.length()) end = s.length();

          for (int i = j; i < end; i++) {
            ps.print(s.charAt(i));
          }
          j = j + lineSize;
        }

        ps.println("\nData Bytes: ");
        dumpIndent(ps, 1);
        ps.println(data);
      }
    } else if (data.getType() == OMMTypes.MSG) {
      parseMsg((OMMMsg) data, ps, tabLevel + 1);
    } else {
      try {
        ps.println(data);
      } catch (Exception e) {
        byte[] rawdata = data.getBytes();
        ps.println(HexDump.hexDump(rawdata));
      }
    }
  }