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


Java Node类代码示例

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


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

示例1: addAtlasProxyClazz

import org.dom4j.Node; //导入依赖的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: remove

import org.dom4j.Node; //导入依赖的package包/类
/**
 *  removes a node from the dom4j Document.
 *
 * @param  xpath  Description of the Parameter
 */
public void remove(String xpath) {
	Node node = doc.selectSingleNode(xpath);
	if (node == null) {
		// prtln("remove could not find node to delete (" + xpath + ")");
		return;
	}

	Element parent = node.getParent();
	if (parent == null) {
		// prtln("remove could not find parent of node to delete (" + xpath + ")");
		return;
	}
	if (!parent.remove(node)) {
		prtlnErr("failed to remove node at " + xpath);
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:22,代码来源:DocMap.java

示例3: query_timestamp

import org.dom4j.Node; //导入依赖的package包/类
/**
    * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
    * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
    * @return 时间戳字符串
    * @throws IOException
    * @throws DocumentException
    * @throws MalformedURLException
    */
public static String query_timestamp() throws MalformedURLException,
                                                       DocumentException, IOException {

       //构造访问query_timestamp接口的URL串
       String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + AlipayConfig.partner + "&_input_charset" +AlipayConfig.input_charset;
       StringBuffer result = new StringBuffer();

       SAXReader reader = new SAXReader();
       Document doc = reader.read(new URL(strUrl).openStream());

       List<Node> nodeList = doc.selectNodes("//alipay/*");

       for (Node node : nodeList) {
           // 截取部分不需要解析的信息
           if (node.getName().equals("is_success") && node.getText().equals("T")) {
               // 判断是否有成功标示
               List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
               for (Node node1 : nodeList1) {
                   result.append(node1.getText());
               }
           }
       }

       return result.toString();
   }
 
开发者ID:dianbaer,项目名称:epay,代码行数:34,代码来源:AlipaySubmit.java

示例4: query_timestamp

import org.dom4j.Node; //导入依赖的package包/类
/**
 * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
 * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
 *
 * @return 时间戳字符串
 * @throws IOException
 * @throws DocumentException
 * @throws MalformedURLException
 */
public static String query_timestamp() throws MalformedURLException, DocumentException, IOException {

	//构造访问query_timestamp接口的URL串
	String strUrl = PayManager.HTTPS_MAPI_ALIPAY_COM_GATEWAY_DO + "?" + "service=query_timestamp&partner=" + AlipayConfig.partner + "&_input_charset" + AlipayConfig.input_charset;
	StringBuffer result = new StringBuffer();

	SAXReader reader = new SAXReader();
	Document doc = reader.read(new URL(strUrl).openStream());

	List<Node> nodeList = doc.selectNodes("//alipay/*");

	for (Node node : nodeList) {
		// 截取部分不需要解析的信息
		if (node.getName().equals("is_success") && node.getText().equals("T")) {
			// 判断是否有成功标示
			List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
			for (Node node1 : nodeList1) {
				result.append(node1.getText());
			}
		}
	}

	return result.toString();
}
 
开发者ID:funtl,项目名称:framework,代码行数:34,代码来源:AlipaySubmit.java

示例5: MqResToDto

import org.dom4j.Node; //导入依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /* 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回 */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        logger.error("", e);
    }
    return map;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:30,代码来源:XmlUtil.java

示例6: removeStringValue

import org.dom4j.Node; //导入依赖的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

示例7: readConfig

import org.dom4j.Node; //导入依赖的package包/类
private static String readConfig(List<String> configPaths) throws DocumentException {
    SAXReader reader = new SAXReader();
    for (String path : configPaths) {
        File file = new File(path);
        if (file.exists()) {
            Document doc = reader.read(file);
            Element root = doc.getRootElement();
            Iterator<Node> it = root.elementIterator();
            while (it.hasNext()) {
                Node node = it.next();
                if (node != null && "localRepository".equals(node.getName())) {
                    return node.getText();
                }
            }
        }
    }
    return null;
}
 
开发者ID:pingcai,项目名称:maven-package-gui-installer,代码行数:19,代码来源:Application.java

示例8: getRepeatingComplexSingletonChildName

import org.dom4j.Node; //导入依赖的package包/类
/**
 *  Gets the qualified element name of the repeatingComplexSingleton child of
 *  the node specified by the provided path, or an empty string if such a child
 *  does not exist.
 *
 * @param  xpath  NOT YET DOCUMENTED
 * @return        The repeatingComplexSingletonChildName value
 */
public String getRepeatingComplexSingletonChildName(String xpath) {
	String normalizedXPath = XPathUtils.normalizeXPath(xpath);
	Node instanceDocNode = getInstanceDocNode(normalizedXPath);
	if (instanceDocNode != null && instanceDocNode.getNodeType() == org.dom4j.Node.ELEMENT_NODE) {
		List children = ((Element) instanceDocNode).elements();
		if (children.size() == 1) {
			Element childElement = (Element) children.get(0);
			String childPath = childElement.getPath();
			SchemaNode schemaNode = getSchemaNode(childPath);
			if (schemaNode != null && schemaNode.getTypeDef().isComplexType() && isRepeatingElement(childPath))
				return childElement.getQualifiedName();
		}
	}
	return "";
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:SchemaHelper.java

示例9: MqResToDto

import org.dom4j.Node; //导入依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
	// System.out.println("####recv"+recv);
	List res = new ArrayList();
	Map map = new HashMap();
	try {
		Document doc = DocumentHelper.parseText(recv);
		List list = doc.selectNodes("//item");
		Iterator<DefaultElement> it = list.iterator();
		while (it.hasNext()) {
			Map elementdto = XmlUtil.Dom2Map(it.next());
			res.add(elementdto);
		}
		map.put("resultList", res);// 放入结果集
		/*
		 * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
		 */
		Node de = doc.selectSingleNode("//REC_MNT");
		if (DataUtil.isNotEmpty(de)) {
			map.put("countInteger", de.getText());
		}
	} catch (Exception e) {
		log.error(XmlUtil.class, e);
	}
	return map;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:32,代码来源:XmlUtil.java

示例10: put

import org.dom4j.Node; //导入依赖的package包/类
/**
 *  Updates the Document by setting the Text of the Node at the specified
 *  xpath. If there is no node at the specified path, a new one is created.<p>
 *
 *  ISSUE: what if there is no value (one way this happens is when there is a
 *  field in the form but no value is supplied by user. In this case we
 *  shouldn't bother creating a new node because there is no value to insert.
 *  But what if there was formerly a value and the user has deleted it? if the
 *  node is an Element, then should that element be deleted? (The user should
 *  be warned first!) if the node is an attribute, then should that attribute
 *  be deleted? (the user won't be warned, since this does not have the
 *  "ripple" effect that deleting an element can have. (maybe the user should
 *  be warned only if the element has children with values).
 *
 * @param  key  unencoded xpath
 * @param  val  value to assign to node at xpath
 */
public void put(Object key, Object val) {
	String xpath = XPathUtils.decodeXPath((String) key);

	Node node = doc.selectSingleNode(xpath);
	if (node == null) {
		// prtln("DocMap.put(): creating new node for " + xpath);
		try {
			node = createNewNode(xpath);
		} catch (Exception e) {
			prtlnErr("DocMap.put(): couldn't create new node at \"" + xpath + "\": " + e);
			return;
		}
	}
	// 2/28/07 no longer trim values!
	/* 		String trimmed_val = "";
	if (val != null)
		trimmed_val = ((String) val).trim();
	node.setText(trimmed_val);*/
	node.setText(val != null ? (String) val : "");
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:38,代码来源:DocMap.java

示例11: smartPut

import org.dom4j.Node; //导入依赖的package包/类
/**
 *  Tests xpath against provided schema (via SchemaHelper) before putting
 *  value, creating a new Node if one is not found at xpath.
 *
 * @param  xpath          NOT YET DOCUMENTED
 * @param  value          NOT YET DOCUMENTED
 * @exception  Exception  NOT YET DOCUMENTED
 */
public void smartPut(String xpath, String value) throws Exception {
	if (schemaHelper != null && schemaHelper.getSchemaNode(xpath) == null) {
		throw new Exception("stuffValue got an illegal xpath: " + xpath);
	}

	if (value == null)
		throw new Exception("stuffValue got a null value (which is illegal) for " + xpath);

	Node node = selectSingleNode(xpath);
	if (node == null)
		node = createNewNode(xpath);
	if (node == null)
		throw new Exception("smartPut failed to find or create node: " + xpath);
	else {
		// 2/18/07 no longer trim values!
		// node.setText(value.trim());
		node.setText(value);
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:28,代码来源:DocMap.java

示例12: getInstanceValue

import org.dom4j.Node; //导入依赖的package包/类
public String getInstanceValue(Element element, String appName) throws MissingNodeException {
	Object value = element.selectObject(xpath);
	if (value == null)
		throw new MissingNodeException("Could not get value from element (path=" +
			xpath + ")");
	if (value instanceof List) {
		List list = (List) value;
		value = list.get(0);
	}

	if (value instanceof Node) {
		Node node = (Node) value;
		return node.getText();
	} else if (value instanceof String) {
		return (String) value;
	} else if (value instanceof Number) {
		String s = value.toString();
		if (s.endsWith(".0"))
			s = s.substring(0, s.length() - 2);
		return s;
	} else
		throw new IllegalStateException("Unexpected object returned from xpath query: " + value);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:ConvertToARFF.java

示例13: handleRelationField

import org.dom4j.Node; //导入依赖的package包/类
private void handleRelationField(String xPathToField, Document xmlDocument)
{
	List nodes = xmlDocument.selectNodes( xPathToField );
	if(nodes != null){
		for(int i = 0; i< nodes.size(); i++){
			Node currentNode = (Node)nodes.get(i);
			String relation = currentNode.getText();
			
			// Insert the URL if an ID is present...
			if(!relation.toLowerCase().matches(".*http\\:\\/\\/.*|.*ftp\\:\\/\\/.*")){
				String relatedID = relation.substring(relation.indexOf(" ")+1,relation.length());
				
				ResultDocList results = 
					index.searchDocs("id:" + SimpleLuceneIndex.encodeToTerm(relatedID));
				if(results == null || results.size() == 0){
					currentNode.detach();
				}else{
					String url = ((ItemDocReader)((ResultDoc)results.get(0)).getDocReader()).getUrl();
					currentNode.setText(relation.substring(0,relation.indexOf(" ") + 1) + url );				
				}				
			}
		}			
	}			
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:25,代码来源:ADNToOAIDCFormatConverter.java

示例14: removeCustomLaunches

import org.dom4j.Node; //导入依赖的package包/类
/**
 * Delete the custom header
 *
 * @param document
 * @param manifestOptions
 */
private static void removeCustomLaunches(Document document, ManifestOptions manifestOptions) {
    if (null == manifestOptions) {
        return;
    }
    Element root = document.getRootElement();// Get the root node
    // Update launch information
    if (manifestOptions.getRetainLaunches() != null && manifestOptions.getRetainLaunches().size() > 0) {
        List<? extends Node> nodes = root.selectNodes(
            "//activity/intent-filter/category|//activity-alias/intent-filter/category");
        for (Node node : nodes) {
            Element e = (Element)node;
            if ("android.intent.category.LAUNCHER".equalsIgnoreCase(e.attributeValue("name"))) {
                Element activityElement = e.getParent().getParent();
                String activiyName = activityElement.attributeValue("name");
                if (!manifestOptions.getRetainLaunches().contains(activiyName)) {
                    if (activityElement.getName().equalsIgnoreCase("activity-alias")) {
                        activityElement.getParent().remove(activityElement);
                    } else {
                        e.getParent().remove(e);
                    }
                }
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:32,代码来源:ManifestFileUtils.java

示例15: getAnyTypeValueOf

import org.dom4j.Node; //导入依赖的package包/类
/**
 *  Gets the anyTypeValueOf attribute of the SchemEditForm object
 *
 * @param  key  a jsp-encoded xpath
 * @return      The anyTypeValueOf value
 */
public Object getAnyTypeValueOf(String key) {
	// prtln("\nGET AnyTypeValueOf(): key = " + key);

	String xpath = XPathUtils.decodeXPath(key);
	// prtln ("\t decodedKey: " + xpath);
	if (this.inputManager != null) {

		String paramName = "anyTypeValueOf(" + key + ")";
		AnyTypeInputField field = (AnyTypeInputField) inputManager.getInputField(paramName);
		if (field != null && field.hasParseError())
			return field.getValue();
	}

	xpath = this.schemaHelper.encodeAnyTypeXpath(xpath);

	Node node = docMap.selectSingleNode(xpath);
	if (node != null) {
		return Dom4jUtils.prettyPrint(node);
	}
	return "";
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:28,代码来源:SchemEditForm.java


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