本文整理汇总了Java中org.dom4j.Element.getUniquePath方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getUniquePath方法的具体用法?Java Element.getUniquePath怎么用?Java Element.getUniquePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.getUniquePath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLuceneQuery
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Gets the Lucene Query representation for the given XML Query starting at the Query element.
*
* @param queryElement A dom4j representation of the Query element
* @param queryParser QueryParser used to parse Lucene syntax based queries and tokenize the text
* @return The Lucene Query object representation of this XML Query
* @exception Exception If error
*/
public static Query getLuceneQuery(Element queryElement, QueryParser queryParser) throws Exception {
// Check if requested to exclude from results, which is an error if not within a boolean clause
String excludeOrRequire = queryElement.attributeValue("excludeOrRequire");
if (excludeOrRequire != null)
throw new Exception("Error parsing document: attribute excludeOrRequire may only be used when the query is enclosed in an encompassing <booleanQuery>. Error found at: " + queryElement.getUniquePath());
if (queryElement.getName().equals("booleanQuery"))
return makeBooleanQuery(queryElement, queryParser);
else if (queryElement.getName().equals("textQuery"))
return makeLuceneQuery(queryElement, queryParser);
else if (queryElement.getName().equals("luceneQuery"))
return makeLuceneQuery(queryElement, queryParser);
else
throw new Exception("Error parsing document: invalid element name '<" + queryElement.getName() + ">' at " + queryElement.getUniquePath());
}
示例2: read
import org.dom4j.Element; //导入方法依赖的package包/类
private static void read(Element e) {
String result = "";
if( !"".equals(targetPath) ){
return ;
}
if (e.nodeCount() > 0) {
Iterator<Element> it = e.elementIterator();
while (it.hasNext()) {
Element ele = it.next();
if( "CSVDataSet".equals(ele.getName()) ){
/*if("".equals(targetPath)){ //查到的第一个 CSVDataSet 保存到参数中,
targetPath = ele.getUniquePath();
}*/
targetPath = ele.getUniquePath();
}
read(ele);
}
}
}
示例3: GenericType
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Constructor - accounting for location and schemaReader.
*
* @param element NOT YET DOCUMENTED
* @param location NOT YET DOCUMENTED
* @param namespace NOT YET DOCUMENTED
* @param schemaReader NOT YET DOCUMENTED
*/
public GenericType(Element element, String location, Namespace namespace, SchemaReader schemaReader) {
this.xsdPrefix = schemaReader.getNamespaces().getSchemaNamespace().getPrefix();
this.location = location;
this.name = element.attributeValue("name");
this.element = element;
this.namespace = namespace;
this.schemaReader = schemaReader;
this.path = element.getUniquePath();
this.type = element.getName();
if (schemaDocAware)
extractDocumentation();
else
filterChildren(xsdPrefix + ":annotation");
}
示例4: makeBooleanQuery
import org.dom4j.Element; //导入方法依赖的package包/类
private static Query makeBooleanQuery(Element booleanQueryElement, QueryParser queryParser) throws Exception {
String operator = booleanQueryElement.valueOf("@type");
boolean isRequired = false;
boolean isProhibited = false;
if (operator == null)
throw new Exception("Error parsing document: element <booleanQuery> must contain an attribite named 'type' that contains the value 'AND' or 'OR'. Error found at " + booleanQueryElement.getUniquePath());
else if (operator.equalsIgnoreCase("OR"))
isRequired = false;
else if (operator.equalsIgnoreCase("AND"))
isRequired = true;
else
throw new Exception("Error parsing document: element <booleanQuery> must contain an attribite named 'type' that contains the value 'AND' or 'OR' but value '" + operator + "' was found. Error found at " + booleanQueryElement.getUniquePath());
BooleanQuery booleanQuery = new BooleanQuery();
// iterate through child elements of booleanClause
Query query = null;
for (Iterator i = booleanQueryElement.elementIterator(); i.hasNext(); ) {
Element element = (Element) i.next();
// Exclude from results or require (overrides previous boolean designation)?
String excludeOrRequire = element.attributeValue("excludeOrRequire");
if (excludeOrRequire != null) {
excludeOrRequire = excludeOrRequire.trim();
if (excludeOrRequire.equalsIgnoreCase("exclude")) {
isRequired = false;
isProhibited = true;
}
else if (excludeOrRequire.equalsIgnoreCase("require")) {
isRequired = true;
isProhibited = false;
}
else if (excludeOrRequire.equalsIgnoreCase("neither")) {
isRequired = false;
isProhibited = false;
}
else {
throw new Exception("Error parsing document: the value of attribute excludeOrRequire must be one of 'exclude', 'require' or 'neither' but '"
+ excludeOrRequire + "' was found at " + booleanQueryElement.getUniquePath());
}
}
if (element.getName().equals("booleanQuery")) {
query = makeBooleanQuery(element, queryParser);
if (query != null) {
if (isRequired && !isProhibited)
booleanQuery.add(query, BooleanClause.Occur.MUST);
else if (!isRequired && isProhibited)
booleanQuery.add(query, BooleanClause.Occur.MUST_NOT);
else
booleanQuery.add(query, BooleanClause.Occur.SHOULD);
}
}
else {
query = makeLuceneQuery(element, queryParser);
if (query != null) {
if (isRequired && !isProhibited)
booleanQuery.add(query, BooleanClause.Occur.MUST);
else if (!isRequired && isProhibited)
booleanQuery.add(query, BooleanClause.Occur.MUST_NOT);
else
booleanQuery.add(query, BooleanClause.Occur.SHOULD);
}
}
}
return applyBoost(booleanQueryElement, booleanQuery);
}
示例5: getUniquePath
import org.dom4j.Element; //导入方法依赖的package包/类
public String getUniquePath(Element element) {
return element.getUniquePath( element );
}