当前位置: 首页>>代码示例>>Java>>正文


Java Element.valueOf方法代码示例

本文整理汇总了Java中org.dom4j.Element.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Element.valueOf方法的具体用法?Java Element.valueOf怎么用?Java Element.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dom4j.Element的用法示例。


在下文中一共展示了Element.valueOf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyBoost

import org.dom4j.Element; //导入方法依赖的package包/类
private static Query applyBoost(Element queryElement, Query query) throws Exception {
	if (query == null || queryElement == null)
		return query;

	String boost = queryElement.valueOf("@boost");
	if (boost != null && boost.length() > 0) {
		float b = 1;
		try {
			b = Float.parseFloat(boost);
		} catch (NumberFormatException nfe) {
			String path = queryElement.attribute("boost").getUniquePath();
			throw new Exception("Error parsing document: boost value was not valid (" +
				nfe.getMessage() + "). Value must be a number, for example 1.5, 2.4. Error found at " + path);
		}
		query.setBoost(b);
	}
	return query;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:19,代码来源:XMLQueryParser.java

示例2: deriveByRestriction

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 *  Relies on the SimpleType def to derive a XSDatatype
 *
 *@param  def            Description of the Parameter
 *@return                Description of the Return Value
 *@exception  Exception  Description of the Exception
 */
private XSDatatype deriveByRestriction(SimpleType def)
	throws Exception {

	// prtln ("deriveByRestriction with " + def.getElement().asXML());
	Element restriction = def.getFirstChild();
	String baseName = getBaseRestrictionName(restriction);
	// prtln (" ... baseName: " + baseName);
	if (baseName == null) {
		prtln("didn't get getBaseRestrictionName!\n\t" + def.toString());
		return null;
	}
	XSDatatype baseType = DatatypeFactory.getTypeByName(baseName);
	if (baseType == null)
		throw new Exception ("deriveByRestriction error: base XSDatatype not found for " + baseName);
	TypeIncubator incubator = new TypeIncubator(baseType);
	// now add facets to incubator
	for (Iterator i = restriction.elementIterator(); i.hasNext(); ) {
		Element child = (Element) i.next();
		String facetName = child.getName();
		String facetValue = child.valueOf("@value");
		try {
			incubator.addFacet(facetName, facetValue, true, null);
		} catch (Exception e) {
			prtln("couldnt add facet: " + facetName + ", " + facetValue + "\n" + e);
		}
	}
	// XSDatatype derived = incubator.derive("", def.getName());
	XSDatatype derived = incubator.derive (def.getNamespace().getURI(), def.getName());
	return derived;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:38,代码来源:XSDatatypeManager.java

示例3: getBaseRestrictionName

import org.dom4j.Element; //导入方法依赖的package包/类
/**
*  Given a restriction element, return the value of the <i>base</i> attribute. 
	Currently requires
 *  that a "xsd:" prefix is present in the base attribute, and remove the prefix before returning remainder
 *  of base attribute. 
 
 @see #deriveByRestriction(SimpleType)
 *
 *@param  e  Description of the Parameter
 *@return    The baseName value
 */
private String getBaseRestrictionName(Element e) {
	String bn = e.valueOf("@base");
	String prefix = e.getNamespacePrefix()+":";
	if (!bn.startsWith(prefix)) {
		// prtln ("getBaseRestrictionName report");
		// prtln ("\tnamespaceURI: " + e.getNamespaceURI());
		
		// return null;
		return bn;
	}
	else {
		return bn.substring(prefix.length());
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:26,代码来源:XSDatatypeManager.java

示例4: getMatcher

import org.dom4j.Element; //导入方法依赖的package包/类
private Matcher getMatcher(Element element) throws FilterException {
	// These will be either BugCode, Method, or Or elements.
	String name = element.getName();
	if (name.equals("BugCode")) {
		return new BugCodeMatcher(element.valueOf("@name"));
	} else if (name.equals("Method")) {
		Attribute nameAttr = element.attribute("name");
		Attribute paramsAttr = element.attribute("params");
		Attribute returnsAttr = element.attribute("returns");

		if (nameAttr == null)
			throw new FilterException("Missing name attribute in Method element");

		if ((paramsAttr != null || returnsAttr != null) && (paramsAttr == null || returnsAttr == null))
			throw new FilterException("Method element must have both params and returns attributes if either is used");

		if (paramsAttr == null)
			return new MethodMatcher(nameAttr.getValue());
		else
			return new MethodMatcher(nameAttr.getValue(), paramsAttr.getValue(), returnsAttr.getValue());
	} else if (name.equals("Or")) {
		OrMatcher orMatcher = new OrMatcher();
		Iterator i = element.elementIterator();
		while (i.hasNext()) {
			orMatcher.addChild(getMatcher((Element) i.next()));
		}
		return orMatcher;
	} else
		throw new FilterException("Unknown element: " + name);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:Filter.java

示例5: getInstanceValue

import org.dom4j.Element; //导入方法依赖的package包/类
public String getInstanceValue(Element element, String appName) throws MissingNodeException {
	String annotationText = element.valueOf("./UserAnnotation[text()]");
	//System.out.println("annotationText=" + annotationText);

	int state = getBugClassification(annotationText);

	if (state == NOT_BUG)
		return "not_bug";
	else if (state == BUG)
		return "bug";
	else if (state == HARMLESS_BUG)
		return "harmless_bug";
	else
		throw new MissingNodeException("Unclassified warning");
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:ConvertToARFF.java

示例6: getBugInstanceList

import org.dom4j.Element; //导入方法依赖的package包/类
private List getBugInstanceList(Document document) {
	List bugInstanceList = document.selectNodes("/BugCollection/BugInstance");
	if (dropUnclassifiedWarnings) {
		for (Iterator i = bugInstanceList.iterator(); i.hasNext(); ) {
			Element element = (Element) i.next();
			String annotationText = element.valueOf("./UserAnnotation[text()]");
			int classification = getBugClassification(annotationText);
			if (classification == UNCLASSIFIED)
				i.remove();
		}
	}
	return bugInstanceList;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:ConvertToARFF.java

示例7: addVirtualSearchField

import org.dom4j.Element; //导入方法依赖的package包/类
private void addVirtualSearchField(Element virtualSearchField) throws Exception {

		String field = virtualSearchField.valueOf("@field");

		if (field == null || field.trim().length() == 0)

			throw new Exception("Error parsing document: element <virtualSearchField> must have a single, non-empty 'field' attribute. Error found at " + virtualSearchField.getPath());



		List virtualSearchTermDefinitions = virtualSearchField.selectNodes("virtualSearchTermDefinition");

		for (int i = 0; i < virtualSearchTermDefinitions.size(); i++)

			addVirtualSearchTermDefinition((Element) virtualSearchTermDefinitions.get(i), field);

	}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:18,代码来源:VirtualSearchFieldMapper.java

示例8: doGetMultiRelatedResources

import org.dom4j.Element; //导入方法依赖的package包/类
private List doGetMultiRelatedResources(boolean displayable) {

		ArrayList items = new ArrayList();
		items.add(this);

		ResultDocList results = null;
		if (displayable)
			results = getDisplayableAssociatedItemResultDocs();
		else
			results = getAssociatedItemResultDocs();
		if (results != null) {
			for (int i = 0; i < results.size(); i++)
				items.add(results.get(i).getDocReader());
		}

		//prtln("getMultiRelatedResources(): items size: " + items.size() );

		ArrayList theRelatedResources = new ArrayList();

		for (int i = 0; i < items.size(); i++) {
			ItemDocReader xmlDocReader = (ItemDocReader) items.get(i);
			String specifiedById = xmlDocReader.getId();
			List relationElms = xmlDocReader.getXmlDoc().selectNodes("//*[local-name()='itemRecord']/*[local-name()='relations']//*[local-name()='relation']/*");
			if (relationElms != null) {
				for (int j = 0; j < relationElms.size(); j++) {
					try {
						Element relationElm = (Element) relationElms.get(j);
						String id = null;
						String title = null;
						String url = null;
						String kind = relationElm.valueOf("@kind");
						// Handle idEntry
						if (relationElm.getName().equals("idEntry")) {
							id = relationElm.valueOf("@entry");
							if(id == null || id.trim().length() == 0)
								continue;
							
							ResultDoc relatedDoc = null;
							if (displayable)
								relatedDoc = recordDataService.getDisplayableItemResultDoc(id);
							else
								relatedDoc = recordDataService.getItemResultDoc(id);
							if (relatedDoc != null) {
								ItemDocReader itemDocReader = (ItemDocReader) relatedDoc.getDocReader();
								title = itemDocReader.getTitle();
								url = itemDocReader.getUrl();
							}
							else
								continue;
						}
						// Handle urlEntry
						else {
							title = relationElm.valueOf("@title");
							url = relationElm.valueOf("@url");
						}
						RelatedResource relatedResource = new RelatedResource(id, title, url, kind, specifiedById);
						//prtln(relatedResource.toString());
						if (!theRelatedResources.contains(relatedResource))
							theRelatedResources.add(relatedResource);
					} catch (Throwable t) {
						prtlnErr("error getting related resource: " + t);
					}
				}
			}
		}
		return theRelatedResources;
	}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:68,代码来源:ItemDocReader.java

示例9: 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);
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:71,代码来源:XMLQueryParser.java

示例10: parse

import org.dom4j.Element; //导入方法依赖的package包/类
private void parse(String fileName) throws IOException, FilterException {

		Document filterDoc = null;

		try {
			SAXReader reader = new SAXReader();
			filterDoc = reader.read(new BufferedInputStream(new FileInputStream(fileName)));
		} catch (DocumentException e) {
			throw new FilterException("Couldn't parse filter file " + fileName, e);
		}

		// Iterate over Match elements
		Iterator i = filterDoc.selectNodes("/FindBugsFilter/Match").iterator();
		while (i.hasNext()) {
			Element matchNode = (Element) i.next();

			AndMatcher matchMatcher = new AndMatcher();

			// Each match node must have either "class" or "classregex" attributes
			Matcher classMatcher = null;
			String classAttr = matchNode.valueOf("@class");
			if (!classAttr.equals("")) {
				classMatcher = new ClassMatcher(classAttr);
			} else {
				String classRegex = matchNode.valueOf("@classregex");
				if (!classRegex.equals(""))
					classMatcher = new ClassRegexMatcher(classRegex);
			}

			if (classMatcher == null)
				throw new FilterException("Match node must specify either class or classregex attribute");

			matchMatcher.addChild(classMatcher);

			if (DEBUG) System.out.println("Match node");

			// Iterate over child elements of Match node.
			Iterator j = matchNode.elementIterator();
			while (j.hasNext()) {
				Element child = (Element) j.next();
				Matcher matcher = getMatcher(child);
				matchMatcher.addChild(matcher);
			}

			// Add the Match matcher to the overall Filter
			this.addChild(matchMatcher);
		}

	}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:50,代码来源:Filter.java

示例11: addVirtualSearchTermDefinition

import org.dom4j.Element; //导入方法依赖的package包/类
private void addVirtualSearchTermDefinition(Element virtualSearchTermDefinition, String field) throws Exception {

		String term = virtualSearchTermDefinition.valueOf("@term");

		if (term == null || term.trim().length() == 0)

			throw new Exception("Error parsing document: element <virtualSearchTermDefinition> must have a single, non-empty 'term' attribute. Error found at " + virtualSearchTermDefinition.getPath());



		List virtualDefinitionElement = virtualSearchTermDefinition.selectNodes("Query/*");

		if (virtualDefinitionElement == null || virtualDefinitionElement.size() == 0)

			throw new Exception("Error parsing document: <virtualSearchTermDefinition> child element '<Query>' is empty or missing. Error found at " + virtualSearchTermDefinition.getPath());

		if (virtualDefinitionElement.size() > 1)

			throw new Exception("Error parsing document: element <virtualSearchTermDefinition> must contain a single child element within the '<Query>' element but contains more than one. Error found at " + virtualSearchTermDefinition.getPath());



		Query query = XMLQueryParser.getLuceneQuery((Element) virtualDefinitionElement.get(0), localQueryParser);



		setQuery(field, term, query);

	}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:30,代码来源:VirtualSearchFieldMapper.java


注:本文中的org.dom4j.Element.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。