示例#1
0
  /**
   * This method process the cells in a <code>Document</code> and generates a portion of the <code>
   * Document</code>.
   *
   * <p>This method assumes that records are sorted by row and then column.
   *
   * @param root The <code>Node</code> of the <code>Document</code> we are building that we will
   *     append our cell <code>Node</code> objects. This <code>Node</code> should be a TAG_TABLE
   *     tag.
   * @throws IOException If any I/O error occurs.
   */
  protected void processColumns(Node root) throws IOException {

    for (Iterator<ColumnRowInfo> e = decoder.getColumnRowInfos(); e.hasNext(); ) {

      ColumnRowInfo ci = e.next();
      if (ci.isColumn()) {
        ColumnStyle cStyle =
            new ColumnStyle(
                "Default",
                SxcConstants.COLUMN_STYLE_FAMILY,
                SxcConstants.DEFAULT_STYLE,
                ci.getSize(),
                null);

        Style result[] = styleCat.getMatching(cStyle);
        String styleName;
        if (result.length == 0) {

          cStyle.setName("co" + colStyles++);
          styleName = cStyle.getName();
          Debug.log(Debug.TRACE, "No existing style found, adding " + styleName);
          styleCat.add(cStyle);
        } else {
          ColumnStyle existingStyle = (ColumnStyle) result[0];
          styleName = existingStyle.getName();
          Debug.log(Debug.TRACE, "Existing style found : " + styleName);
        }

        // Create an element node for the new row
        Element colElement = doc.createElement(TAG_TABLE_COLUMN);
        colElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, styleName);
        if (ci.getRepeated() != 1) {
          String repeatStr = String.valueOf(ci.getRepeated());
          colElement.setAttribute(ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED, repeatStr);
        }
        root.appendChild(colElement);
      }
    }
  }