本文整理匯總了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 );
}