예제 #1
0
  public List<XSSFXmlColumnPr> getXmlColumnPrs() {

    if (xmlColumnPr == null) {
      xmlColumnPr = new Vector<XSSFXmlColumnPr>();
      for (CTTableColumn column : ctTable.getTableColumns().getTableColumnArray()) {
        if (column.getXmlColumnPr() != null) {
          XSSFXmlColumnPr columnPr = new XSSFXmlColumnPr(this, column, column.getXmlColumnPr());
          xmlColumnPr.add(columnPr);
        }
      }
    }
    return xmlColumnPr;
  }
예제 #2
0
  /**
   * Calculates the xpath of the root element for the table. This will be the common part of all the
   * mapping's xpaths
   *
   * @return the xpath of the table's root element
   */
  public String getCommonXpath() {

    if (commonXPath == null) {

      String[] commonTokens = {};

      for (CTTableColumn column : ctTable.getTableColumns().getTableColumnArray()) {
        if (column.getXmlColumnPr() != null) {
          String xpath = column.getXmlColumnPr().getXpath();
          String[] tokens = xpath.split("/");
          if (commonTokens.length == 0) {
            commonTokens = tokens;

          } else {
            int maxLenght =
                commonTokens.length > tokens.length ? tokens.length : commonTokens.length;
            for (int i = 0; i < maxLenght; i++) {
              if (!commonTokens[i].equals(tokens[i])) {
                List<String> subCommonTokens = Arrays.asList(commonTokens).subList(0, i);

                String[] container = {};

                commonTokens = subCommonTokens.toArray(container);
                break;
              }
            }
          }
        }
      }

      commonXPath = "";

      for (int i = 1; i < commonTokens.length; i++) {
        commonXPath += "/" + commonTokens[i];
      }
    }

    return commonXPath;
  }