本文整理汇总了Java中org.dom4j.ElementPath类的典型用法代码示例。如果您正苦于以下问题:Java ElementPath类的具体用法?Java ElementPath怎么用?Java ElementPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElementPath类属于org.dom4j包,在下文中一共展示了ElementPath类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onStart
import org.dom4j.ElementPath; //导入依赖的package包/类
@Override
public void onStart(ElementPath path) {
Element el = path.getCurrent();
String elName = el.getName();
Term term;
log.debug(path.getCurrent());
if (elName.equals("rules")) {
return;
} else if (elName.equals("rule")) {
Rule rule = new Rule(el.attributeValue("id"));
fRules.add(rule);
term = rule;
} else if (elName.equals("and")) {
term = new AndTerm();
} else if (elName.equals("or")) {
term = new OrTerm();
} else if (elName.equals("not")) {
term = new NotTerm();
} else if (elName.equals("expression")) {
term = new Expression(el.attributeValue("value").equals("true"));
} else {
throw new RuntimeException("XML validation should have caught this!");
// throw an error
}
if (fTermStack.size() > 0) {
Term parent = fTermStack.get(0);
if (parent instanceof CompoundTerm) {
((CompoundTerm) parent).getTerms().add(term);
} else if (parent instanceof NotTerm) {
NotTerm not = (NotTerm) parent;
if (not.getTerm() != null) {
throw new RuntimeException("XML validation should have caught this!");
}
not.setTerm(term);
}
}
fTermStack.add(0, term);
}
开发者ID:groupon,项目名称:nakala,代码行数:40,代码来源:SaxExample.java
示例2: startElement
import org.dom4j.ElementPath; //导入依赖的package包/类
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException {
super.startElement(namespaceURI, localName, qualifiedName, attributes);
final ElementPath path = getElementStack();
path.getCurrent().setData(new LocationData(locator));
}
开发者ID:evlist,项目名称:orbeon-forms,代码行数:6,代码来源:LocationSAXContentHandler.java
示例3: onEnd
import org.dom4j.ElementPath; //导入依赖的package包/类
@Override
public void onEnd(ElementPath path) {
if (fTermStack.size() > 0)
fTermStack.remove(0);
log.debug(path.getCurrent().getText());
}
开发者ID:groupon,项目名称:nakala,代码行数:7,代码来源:SaxExample.java
注:本文中的org.dom4j.ElementPath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论