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


Java Element.selectNodes方法代码示例

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


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

示例1: addAtlasProxyClazz

import org.dom4j.Element; //导入方法依赖的package包/类
public static void addAtlasProxyClazz(Document document, Set<String> nonProxyChannels,  Result result) {

        Element root = document.getRootElement();// Get the root node

        List<? extends Node> serviceNodes = root.selectNodes("//@android:process");

        String packageName = root.attribute("package").getStringValue();

        Set<String> processNames = new HashSet<>();
        processNames.add(packageName);

        for (Node node : serviceNodes) {
            if (null != node && StringUtils.isNotEmpty(node.getStringValue())) {
                String value = node.getStringValue();
                processNames.add(value);
            }
        }

        processNames.removeAll(nonProxyChannels);

        List<String> elementNames = Lists.newArrayList("activity", "service", "provider");

        Element applicationElement = root.element("application");

        for (String processName : processNames) {

            boolean isMainPkg = packageName.equals(processName);
            //boolean isMainPkg = true;
            String processClazzName = processName.replace(":", "").replace(".", "_");

            for (String elementName : elementNames) {

                String fullClazzName = "ATLASPROXY_" +  (isMainPkg ? "" : (packageName.replace(".", "_") + "_" )) +  processClazzName + "_" + StringUtils.capitalize(elementName);

                if ("activity".equals(elementName)) {
                    result.proxyActivities.add(fullClazzName);
                } else if ("service".equals(elementName)) {
                    result.proxyServices.add(fullClazzName);
                } else {
                    result.proxyProviders.add(fullClazzName);
                }

                Element newElement = applicationElement.addElement(elementName);
                newElement.addAttribute("android:name", ATLAS_PROXY_PACKAGE + "." + fullClazzName);

                if (!packageName.equals(processName)) {
                    newElement.addAttribute("android:process", processName);
                }

                boolean isProvider = "provider".equals(elementName);
                if (isProvider) {
                    newElement.addAttribute("android:authorities",
                                            ATLAS_PROXY_PACKAGE + "." + fullClazzName);
                }

            }

        }

    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:61,代码来源:AtlasProxy.java

示例2: removeStringValue

import org.dom4j.Element; //导入方法依赖的package包/类
public static void removeStringValue(File file, String key) throws IOException, DocumentException {

        if (!file.exists()) {
            return;
        }

        Document document = XmlHelper.readXml(file);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        List<? extends Node> nodes = root.selectNodes("//string");
        for (Node node : nodes) {
            Element element = (Element)node;
            String name = element.attributeValue("name");
            if (key.equals(name)) {
                element.getParent().remove(element);
                break;
            }
        }
        // sLogger.warn("[resxmlediter] add " + key + " to " + file.getAbsolutePath());
        XmlHelper.saveDocument(document, file);
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:21,代码来源:XmlHelper.java

示例3: setOriginAttribute

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setOriginAttribute(final String id, final String x, final String y)
{	
	String s = "junction[@type='Other_Junction' and contains(@intNode,'"+ id +"')]";
	//System.out.println("add O: " + id);
	Element r = document.getRootElement();
	List<Element> list = r.selectNodes(s);
	String junctemp = "";
	if(!list.isEmpty())
	{
		junctemp = list.get(0).attribute("id").getValue();
	}
	
	origin.addAttribute("id", id);
	origin.addAttribute("x", x);
	origin.addAttribute("y", y);
	origin.addAttribute("junction", junctemp);
}
 
开发者ID:ansleliu,项目名称:GraphicsViewJambi,代码行数:19,代码来源:ExportNetworkToXML.java

示例4: parse

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public StateLike parse(Element elem) {
    require(elem.attributeValue("name") != null,
        "attribute 'name' in node is required");
    stateName = elem.attributeValue("name");
    stateAlias = elem.attributeValue("alias");
    // 得到所有该节点下的 paths 下的 path
    List<Element> childPaths = elem.selectNodes(PATH_TAG);
    for (Element node : childPaths) {
        require(node.attributeValue("to") != null, "attribute to in path node is required");

        String pathTo = node.attributeValue("to");
        String expr = null;
        if (node.attributeValue("expr") != null) {
            expr = node.attributeValue("expr");
        }
        // 新实例一个path,并加入到paths中
        Path pt = new Path(pathTo, expr);
        // 添加到path 列表中
        paths.add(pt);
    }
    return this;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:25,代码来源:RunnableState.java

示例5: parse

import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public StateLike parse(Element elem) {
    super.parse(elem);
    List<Element> pre_invokesPaths = elem.selectNodes(PRE_INVOKES_TAG);
    for (Element node : pre_invokesPaths) {// 拿 孩子节点
        for (Iterator i = node.elementIterator(); i.hasNext(); ) {
            Element child = (Element)i.next();
            try {
                preInvokes.add(InvokableFactory.newInstance(child.getName(), child));
            } catch (RuntimeException re) {
                logger.error(String.format("实例Invokable类型时候出错,类型为:%s , 异常为: %s", child.getName(), re.toString()));
                throw re;
            } catch (Throwable e) {
                logger.error(String.format("实例Invokable类型时候出错,类型为: %s , 异常为:", child.getName(), e.toString()));
                throw new UndeclaredThrowableException(e,
                    "error happened when newInstance Invokable class:" + child.getName());
            }
        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:22,代码来源:Event.java

示例6: parse

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public StateLike parse(Element elem) {
    List<Element> infoElemList = elem.selectNodes(INFO_TAG);
    for (Element infoElem : infoElemList) {
        BizInfoElement bizInfoElement = new BizInfoElement();
        for (Iterator<Attribute> it = infoElem.attributeIterator(); it.hasNext(); ) {
            Attribute attribute = it.next();
            bizInfoElement.attribute.put(attribute.getName(), attribute.getValue());
        }
        String key = bizInfoElement.attribute.get(KEY_TAG);
        require(StringUtils.hasText(key), "attribute '" + KEY_TAG + "' in node bizInfo/info is required");
        if (bizInfoList.get(key) == null) {
            bizInfoList.put(key, new ArrayList<BizInfoElement>());
        }
        bizInfoList.get(key).add(bizInfoElement);
    }
    return this;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:20,代码来源:BizInfo.java

示例7: addODToODMatrix

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void addODToODMatrix(List<Element> originList)
{
	final int originListSize = originList.size();
	System.out.println("Origin's count: " + originListSize); 
	for(int i = 0; i<originListSize; i++)
	{
		Vertex orgV = null;		//连接的起点
				
		Element element = originList.get(i);
		String orgid = element.attribute("id").getValue();
		String orgx = element.attribute("x").getValue();
		String orgy = element.attribute("y").getValue();
		
		orgV = new Vertex(orgid,"Internal",Double.parseDouble(orgx),Double.parseDouble(orgy));
		
		List<Element> destinationList = element.selectNodes(LocalXmlAttributeMatch.DESTINATION);
		int destinationCount = destinationList.size();	
		for(int j = 0; j<destinationCount; j++)
		{
			Vertex desV = null;  	//连接的终点
			String demand = null;
			
			Element destinaton = destinationList.get(j);
			String desid = destinaton.attribute("id").getValue();
			String desx = destinaton.attribute("x").getValue();
			String desy = destinaton.attribute("y").getValue();
			demand = destinaton.attribute("demand").getValue();
			
			desV = new Vertex(desid,"Internal",Double.parseDouble(desx),Double.parseDouble(desy));
			OD od = new OD(orgV,desV,Double.parseDouble(demand));
			odMatrix.addOD(od);
		}
	}
}
 
开发者ID:ansleliu,项目名称:GraphicsViewJambi,代码行数:36,代码来源:ImportLocalNetImplement.java

示例8: fillFullClazzName

import org.dom4j.Element; //导入方法依赖的package包/类
private static void fillFullClazzName(Element root, String packageName, String type) {
    List<? extends Node> applicatNodes = root.selectNodes("//" + type);
    for (Node node : applicatNodes) {
        Element element = (Element)node;
        Attribute attribute = element.attribute("name");
        if (attribute != null) {
            if (attribute.getValue().startsWith(".")) {
                attribute.setValue(packageName + attribute.getValue());
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:13,代码来源:ManifestFileUtils.java

示例9: removeProvider

import org.dom4j.Element; //导入方法依赖的package包/类
private static void removeProvider(Document document) throws IOException, DocumentException {

        Element root = document.getRootElement();// Get the root node
        List<? extends Node> nodes = root.selectNodes("//provider");
        for (Node node : nodes) {
            Element element = (Element)node;
            String name = element.attributeValue("name");
            logger.info("[Remove Provider]" + name);
            element.getParent().remove(element);
        }
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:12,代码来源:ManifestFileUtils.java

示例10: networkStorage

import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Network networkStorage()
{
	final Element root = document.getRootElement();
	final List<Element> junctionList = root.selectNodes(LocalXmlAttributeMatch.JUNCTION); 
	final List<Element> extLinkList = root.selectNodes(LocalXmlAttributeMatch.EXTLINK);
	
	addJunctionToNetwork(junctionList);
	addExtLinkToNetwork(extLinkList);
	
	return network;
}
 
开发者ID:ansleliu,项目名称:GraphicsViewJambi,代码行数:13,代码来源:ImportNetworkFromLocal.java

示例11: parse

import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public StateLike parse(Element elem) {
    super.parse(elem);
    if (elem.attributeValue(REPEATLIST_TAG) != null) {
        repeatList = elem.attributeValue(REPEATLIST_TAG);
    }
    if (elem.attributeValue(IGNOREWEEKEND_TAG) != null) {
        ignoreWeekend = Boolean.valueOf(elem.attributeValue(IGNOREWEEKEND_TAG));
    }

    List<Element> invokesPaths = elem.selectNodes(INVOKES_TAG);
    // 拿孩子节点
    for (Element node : invokesPaths) {
        for (Iterator i = node.elementIterator(); i.hasNext(); ) {
            Element child = (Element)i.next();
            try {
                invokes.add(InvokableFactory.newInstance(child.getName(), child));
            } catch (RuntimeException re) {
                logger.error(String.format("实例Invokable类型时候出错,类型为: %s , 异常为: %s", child.getName(), re.toString()));
                throw re;
            } catch (Throwable e) {
                logger.error(String.format("实例Invokable类型时候出错,类型为: %s , 异常为: %s", child.getName(), e.toString()));
                throw new UndeclaredThrowableException(e,
                    "error happened when newInstance Invokable class:" + child.getName());
            }

        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:31,代码来源:State.java

示例12: createODNodeList

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 * 获取OD List
 */
@SuppressWarnings("unchecked")
public void createODNodeList()
{
	final Element root = document.getRootElement();
	final List<Element> tazList = root.selectNodes("taz");
	
	final int tazListSize = tazList.size();
	for(int i = 0; i<tazListSize; i++)
	{
		//Get a Taz from the Taz List
		Element element = tazList.get(i);
		
		List<Element> tazSourceList = element.selectNodes("tazSource");
		if(!tazSourceList.isEmpty())
		{
			String origin = tazSourceList.get(0).attribute("id").getValue();
			originList.add(origin);
		}
		
		List<Element> tazSinkList = element.selectNodes("tazSink");
		if(!tazSinkList.isEmpty())
		{
			String destination = tazSinkList.get(0).attribute("id").getValue();
			destinationList.add(destination);
		}
	}
}
 
开发者ID:ansleliu,项目名称:GraphicsViewJambi,代码行数:31,代码来源:ImportSumoODMatrix.java

示例13: networkStorage

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 * 存储路网到Network
 * @return
 */
@SuppressWarnings("unchecked")
public Network networkStorage()
{
	final Element root = document.getRootElement();
	final List<Element> junctionList = root.selectNodes(LocalXmlAttributeMatch.JUNCTION); 
	final List<Element> extLinkList = root.selectNodes(LocalXmlAttributeMatch.EXTLINK);
	final List<Element> originList = root.selectNodes(LocalXmlAttributeMatch.ORIGIN);
	addJunctionToNetwork(junctionList);
	addExtLinkToNetwork(extLinkList);
	addODToODMatrix(originList);
	return network;
}
 
开发者ID:ansleliu,项目名称:GraphicsViewJambi,代码行数:17,代码来源:ImportLocalNetImplement.java

示例14: getSetDefinitionsForm

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 *  Reads the ListSets config XML to extract the set definition for a given set into a SetDefinitionsForm
 *  bean.
 *
 * @param  listSetsXml    The ListSets config XML to read
 * @param  setSpec        The setSpec to read
 * @return                The setDefinitionsForm, or null if none configred for that setSpec
 * @exception  Exception  If error parsing the XML
 */
public static SetDefinitionsForm getSetDefinitionsForm(String listSetsXml, String setSpec)
	 throws Exception {

	Document document = Dom4jUtils.getXmlDocument(listSetsXml);
	Element setElement = (Element) document.selectSingleNode("/ListSets/set[setSpec='" + setSpec + "']");
	if (setElement == null)
		return null;

	SetDefinitionsForm setDefinitionsForm = new SetDefinitionsForm();
	setDefinitionsForm.setSetName(setElement.valueOf("setName"));
	setDefinitionsForm.setSetSpec(setElement.valueOf("setSpec"));
	setDefinitionsForm.setSetDescription(setElement.valueOf("setDescription/description"));
	setDefinitionsForm.setSetURL(setElement.valueOf("setDescription/identifier"));
	setDefinitionsForm.setIncludedFormat(setElement.valueOf("virtualSearchField/virtualSearchTermDefinition/Query//booleanQuery/textQuery[@field='xmlFormat']"));
	setDefinitionsForm.setIncludedQuery(setElement.valueOf("virtualSearchField/virtualSearchTermDefinition/Query/booleanQuery/luceneQuery[not(@excludeOrRequire='exclude')]"));
	setDefinitionsForm.setExcludedQuery(setElement.valueOf("virtualSearchField/virtualSearchTermDefinition/Query/booleanQuery/luceneQuery[@excludeOrRequire='exclude']"));

	// Handle include clauses

	// Get included dirs
	List includedDirs = setElement.selectNodes("virtualSearchField/virtualSearchTermDefinition/Query//booleanQuery/textQuery[@field='docdir' and not(@excludeOrRequire='exclude')]");
	ArrayList dirsList = new ArrayList(includedDirs.size());
	for (int i = 0; i < includedDirs.size(); i++)
		dirsList.add( ((Node) includedDirs.get(i)).getText() );
	setDefinitionsForm.setIncludedDirs((String[])dirsList.toArray(new String[]{}));

	// Get included terms/phrases
	List terms = setElement.selectNodes("virtualSearchField/virtualSearchTermDefinition/Query//booleanQuery/textQuery[@field='default' and not(@excludeOrRequire='exclude')]");
	String text = "";
	prtln("terms size: " + terms.size());
	for (int i = 0; i < terms.size(); i++) {
		text += ((Node) terms.get(i)).getText();
		if (i < terms.size() - 1)
			text += ", ";
	}
	setDefinitionsForm.setIncludedTerms(text);

	// Handle exclude clauses

	// Get excluded dirs
	List exdludedDirs = setElement.selectNodes("virtualSearchField/virtualSearchTermDefinition/Query/booleanQuery/textQuery[@field='docdir' and @excludeOrRequire='exclude']");
	dirsList = new ArrayList(exdludedDirs.size());
	for (int i = 0; i < exdludedDirs.size(); i++)
		dirsList.add( ((Node) exdludedDirs.get(i)).getText() );
	setDefinitionsForm.setExcludedDirs((String[])dirsList.toArray(new String[]{}));
	
	/* dirStrings = setDefinitionsForm.getExcludedDirs();
	for (int i = 0; i < exdludedDirs.size(); i++)
		dirStrings[i] = ((Node) exdludedDirs.get(i)).getText();
	setDefinitionsForm.setExcludedDirs(dirStrings); */

	// Get excluded terms/phrases
	terms = setElement.selectNodes("virtualSearchField/virtualSearchTermDefinition/Query/booleanQuery/textQuery[@field='default' and @excludeOrRequire='exclude']");
	text = "";
	for (int i = 0; i < terms.size(); i++) {
		text += ((Node) terms.get(i)).getText();
		if (i < terms.size() - 1)
			text += ", ";
	}
	setDefinitionsForm.setExcludedTerms(text);

	//prtln("setDefinitionsForm.getSetName(): " + setDefinitionsForm.getSetName());
	return setDefinitionsForm;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:74,代码来源:OAISetsXMLConfigManager.java

示例15: searchDocs

import org.dom4j.Element; //导入方法依赖的package包/类
/**
 *  analogus to SimpleLuceneIndex.searchDoc, performs a search and returns an
 *  array of {@link RemoteResultDoc} objects that represent the results of the
 *  search. <p>
 *
 *  Note: the urlCheck WebService returns information about duplicate records
 *  (that don't match the query, but which refer to the same resource) returned
 *  as an <b>alsoCatalogedBy</b> element of <b>MatchingRecord</b> . These
 *  duplicates are treated as search results by searchDocs - they are expanded
 *  into RemoteResultDoc objects and added to the results returned.
 *
 *@param  s  Description of the Parameter
 *@return    Description of the Return Value
 */
public RemoteResultDoc[] searchDocs(String s) {
	RemoteResultDoc[] emptyResults = new RemoteResultDoc[]{};
	if (s == null) {
		prtln("RemoteResultDoc: got null for the search parameter");
		return emptyResults;
	}
	Document webServiceResultDoc = null;
	try {
		prtln("about to call webserviceClient.urlCheck with " + s);
		webServiceResultDoc = wsc.urlCheck(s);
	} catch (WebServiceClientException e) {
		prtln(e.getMessage());
		return emptyResults;
	}
	if (webServiceResultDoc == null) {
		prtln("urlCheck returned null");
		return emptyResults;
	}
	// parse results document
	List matchingRecords = webServiceResultDoc.selectNodes("//results/matchingRecord");
	if (matchingRecords.size() == 0) {
		prtln("urlCheck returned no matches");
		return emptyResults;
	}
	else {
		ArrayList matches = new ArrayList();
		for (Iterator i = matchingRecords.iterator(); i.hasNext(); ) {
			Element matchingRecord = (Element) i.next();
			// prtln ("about to parse matchingRecord:\n" + Dom4jUtils.prettyPrint(matchingRecord));

			RemoteResultDoc m = new RemoteResultDoc(matchingRecord, this);
			matches.add(m);

			// now deal with the alsoCatalogedBys
			List alsoCatalogedBys = matchingRecord.selectNodes("//additionalMetadata[@realm='adn']/alsoCatalogedBy");
			if (alsoCatalogedBys == null) {
				// prtln ("no alsoCatalogedBys found");
			}
			else {
				// prtln (alsoCatalogedBys.size() + " alsoCatalogedBys found");
				for (Iterator n = alsoCatalogedBys.iterator(); n.hasNext(); ) {
					Element ae = (Element) n.next();
					String collection = ae.attributeValue("collectionLabel");
					String id = ae.getText();
					RemoteResultDoc am = new RemoteResultDoc(id, m.getUrl(), collection, this);
					matches.add(am);
				}
			}
		}
		prtln("searchDocs found " + matches.size() + " items");
		return (RemoteResultDoc[]) matches.toArray(emptyResults);
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:68,代码来源:RemoteSearcher.java


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