org.dom4j.swing.XMLTableDefinition类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.dom4j.swing.XMLTableDefinition类的一些代码示例,展示了XMLTableDefinition类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLTableDefinition类的具体详情如下:
包路径:org.dom4j.swing.XMLTableDefinition
类名称:XMLTableDefinition

XMLTableDefinition介绍

[英]XMLTableDefinition represents a table definition based on XPath expression evaluated on an XML document.
[中]

代码示例

代码示例来源:origin: org.dom4j/dom4j

/**
 * Loads an XML table definition from an XML definition document
 * 
 * @param definition
 *            DOCUMENT ME!
 * 
 * @return DOCUMENT ME!
 */
public static XMLTableDefinition load(Element definition) {
  XMLTableDefinition answer = new XMLTableDefinition();
  answer.setRowExpression(definition.attributeValue("select"));
  for (Iterator<Element> iter = definition.elementIterator("column"); iter
      .hasNext();) {
    Element element = iter.next();
    String expression = element.attributeValue("select");
    String name = element.getText();
    String typeName = element.attributeValue("type", "string");
    String columnXPath = element.attributeValue("columnNameXPath");
    int type = XMLTableColumnDefinition.parseType(typeName);
    if (columnXPath != null) {
      answer.addColumnWithXPathName(columnXPath, expression, type);
    } else {
      answer.addColumn(name, expression, type);
    }
  }
  return answer;
}

代码示例来源:origin: org.dom4j/dom4j

public void addColumn(XMLTableColumnDefinition column) {
  clearCaches();
  columns.add(column);
}

代码示例来源:origin: org.dom4j/dom4j

public void addColumnWithXPathName(String columnNameXPathExpression,
    String expression, int type) {
  XPath columnNameXPath = createColumnXPath(columnNameXPathExpression);
  XPath xpath = createColumnXPath(expression);
  addColumn(new XMLTableColumnDefinition(columnNameXPath, xpath, type));
}

代码示例来源:origin: org.dom4j/dom4j

public void setRowExpression(String xpath) {
  setRowXPath(createXPath(xpath));
}

代码示例来源:origin: org.dom4j/dom4j

/**
 * DOCUMENT ME!
 * 
 * @param columnIndex
 *            DOCUMENT ME!
 * 
 * @return the XPath expresssion used to create the column name, if there is
 *         one or null if there is no XPath expression to name the column.
 */
public XPath getColumnNameXPath(int columnIndex) {
  return getColumn(columnIndex).getColumnNameXPath();
}

代码示例来源:origin: dom4j/dom4j

public void testServletTable() throws Exception {
  Document document = getDocument("/xml/web.xml");
  XMLTableDefinition tableDefinition = new XMLTableDefinition();
  tableDefinition.setRowExpression("/web-app/servlet");
  tableDefinition.addStringColumn("Name", "servlet-name");
  tableDefinition.addStringColumn("Class", "servlet-class");
  String mapping = "../servlet-mapping[servlet-name=$Name]/url-pattern";
  tableDefinition.addStringColumn("Mapping", mapping);
  XMLTableModel tableModel = new XMLTableModel(tableDefinition, document);
  // now lets test the values come out
  assertEquals("correct row count", tableModel.getRowCount(), 2);
  assertEquals("correct column count", tableModel.getColumnCount(), 3);
  assertColumnNameEquals(tableModel, 0, "Name");
  assertColumnNameEquals(tableModel, 1, "Class");
  assertColumnNameEquals(tableModel, 2, "Mapping");
  assertCellEquals(tableModel, 0, 0, "snoop");
  assertCellEquals(tableModel, 1, 0, "file");
  assertCellEquals(tableModel, 0, 1, "SnoopServlet");
  assertCellEquals(tableModel, 1, 1, "ViewFile");
  assertCellEquals(tableModel, 0, 2, "/foo/snoop");
  assertCellEquals(tableModel, 1, 2, "");
}

代码示例来源:origin: org.dom4j/dom4j

protected XPath createColumnXPath(String expression) {
  XPath xpath = createXPath(expression);
  // associate my variable context
  xpath.setVariableContext(this);
  return xpath;
}

代码示例来源:origin: org.dom4j/dom4j

public Class<?> getColumnClass(int columnIndex) {
  return definition.getColumnClass(columnIndex);
}

代码示例来源:origin: org.dom4j/dom4j

public int getColumnCount() {
  return definition.getColumnCount();
}

代码示例来源:origin: org.dom4j/dom4j

public void addStringColumn(String name, String expression) {
  addColumn(name, expression, XMLTableColumnDefinition.STRING_TYPE);
}

代码示例来源:origin: dom4j/dom4j

public void setRowExpression(String xpath) {
  setRowXPath(createXPath(xpath));
}

代码示例来源:origin: org.dom4j/dom4j

/**
 * DOCUMENT ME!
 * 
 * @param columnIndex
 *            DOCUMENT ME!
 * 
 * @return the static column name. This is used if there is no
 *         columnNameXPath
 */
public String getColumnName(int columnIndex) {
  return getColumn(columnIndex).getName();
}

代码示例来源:origin: dom4j/dom4j

protected XPath createColumnXPath(String expression) {
  XPath xpath = createXPath(expression);
  // associate my variable context
  xpath.setVariableContext(this);
  return xpath;
}

代码示例来源:origin: dom4j/dom4j

public Class<?> getColumnClass(int columnIndex) {
  return definition.getColumnClass(columnIndex);
}

代码示例来源:origin: dom4j/dom4j

public int getColumnCount() {
  return definition.getColumnCount();
}

代码示例来源:origin: org.dom4j/dom4j

public void addColumn(String name, String expression) {
  addColumn(name, expression, XMLTableColumnDefinition.OBJECT_TYPE);
}

代码示例来源:origin: dom4j/dom4j

/**
 * Loads an XML table definition from an XML definition document
 * 
 * @param definition
 *            DOCUMENT ME!
 * 
 * @return DOCUMENT ME!
 */
public static XMLTableDefinition load(Element definition) {
  XMLTableDefinition answer = new XMLTableDefinition();
  answer.setRowExpression(definition.attributeValue("select"));
  for (Iterator<Element> iter = definition.elementIterator("column"); iter
      .hasNext();) {
    Element element = iter.next();
    String expression = element.attributeValue("select");
    String name = element.getText();
    String typeName = element.attributeValue("type", "string");
    String columnXPath = element.attributeValue("columnNameXPath");
    int type = XMLTableColumnDefinition.parseType(typeName);
    if (columnXPath != null) {
      answer.addColumnWithXPathName(columnXPath, expression, type);
    } else {
      answer.addColumn(name, expression, type);
    }
  }
  return answer;
}

代码示例来源:origin: org.dom4j/dom4j

public void addColumn(String name, String expression, int type) {
  XPath xpath = createColumnXPath(expression);
  addColumn(new XMLTableColumnDefinition(name, xpath, type));
}

代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j

public void setRowExpression(String xpath) {
  setRowXPath(createXPath(xpath));
}

代码示例来源:origin: org.dom4j/dom4j

/**
 * DOCUMENT ME!
 * 
 * @param columnIndex
 *            DOCUMENT ME!
 * 
 * @return the XPath expression used to evaluate the value of cells in this
 *         column
 */
public XPath getColumnXPath(int columnIndex) {
  return getColumn(columnIndex).getXPath();
}

相关文章