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


Java Node.setNodeValue方法代码示例

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


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

示例1: extractFeatures

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static ArrayList<Node> extractFeatures(Node n, Document D) {
    ArrayList<Node> attrs = new ArrayList<Node>();
    String type = n.getAttributes().getNamedItem("type").getNodeValue();
    NodeList features = n.getChildNodes();
    for (int i = 0; i < n.getChildNodes().getLength(); i++) {
        if (n.getChildNodes().item(i) instanceof Element) {
            features = n.getChildNodes().item(i).getChildNodes();
        }
    }
    for (int i = 0; i < features.getLength(); i++) {
        Node feature = features.item(i);
        if (feature instanceof Element) {
            String name = feature.getAttributes().getNamedItem("name")
                    .getNodeValue();
            String value = extractFeatureValue(feature);
            Node attr = D.createAttribute(type + ":" + name);
            attr.setNodeValue(value);
            attrs.add(attr);
        }
    }
    return attrs;
}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:23,代码来源:ViewTreeBuilder.java

示例2: mergeChildNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Merge child nodes
 * 
 * @param node     current node base
 * @param childNode child node if exist
 * @param foundBean child bean
 * @param currentChild current child node
 * @param patternChild current pattern child
 * @param nodeMap node map
 * @param document document
 * @param patternBean pattern bean
 * @param children list relevant childs current node base
 */
private static void mergeChildNodes(Node node, Node childNode, BaseBean foundBean,
        Node currentChild, Node patternChild, Map nodeMap, Document document,
        BaseBean patternBean, List children) {
    Node foundChild = childNode;
    if (foundChild == null) {
        foundChild = takeEqualNode(children, patternChild);
    }
    if (foundChild != null) {
        if (foundChild != currentChild) {
            node.removeChild(foundChild);
            node.insertBefore(foundChild, currentChild);
        }
        if (foundBean != null) {
            mergeBeans(nodeMap, foundBean, patternBean);
        } else if (isRelevantNode(foundChild) && foundChild.hasChildNodes()) {
            mergeNode(nodeMap, foundChild, patternChild);
        } else {
            foundChild.setNodeValue(patternChild.getNodeValue());
        }
    } else {
        Node child = document.importNode(patternChild, true);
        node.insertBefore(child, currentChild);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:Schema2BeansUtil.java

示例3: setText

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Set or replace the text value
 */
public static void setText(Node node, String val) {
    Node chld=DomUtil.getChild(node, Node.TEXT_NODE);
    if( chld == null ) {
        Node textN=node.getOwnerDocument().createTextNode(val);
        node.appendChild(textN);
        return;
    }
    // change the value
    chld.setNodeValue(val);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:DomUtil.java

示例4: renameManifestPackage

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Replaces package value with passed packageOriginal string
 *
 * @param file File for AndroidManifest.xml
 * @param packageOriginal Package name to replace
 * @throws AndrolibException
 */
public static void renameManifestPackage(File file, String packageOriginal) throws AndrolibException {
    try {
        Document doc = loadDocument(file);

        // Get the manifest line
        Node manifest = doc.getFirstChild();

        // update package attribute
        NamedNodeMap attr = manifest.getAttributes();
        Node nodeAttr = attr.getNamedItem("package");
        nodeAttr.setNodeValue(packageOriginal);
        saveDocument(file, doc);

    } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:24,代码来源:ResXmlPatcher.java

示例5: makeCdataReplacements

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void makeCdataReplacements(Element element) throws Exception {
	try {
        Node cdata = XMLUtils.findChildNode(element, Node.CDATA_SECTION_NODE);
        if (cdata != null) {
            String s = cdata.getNodeValue();
            if (!s.equals("")) {
                StringEx sx = new StringEx(s);
                Enumeration<String> keys = nameReplacements.keys();
                String key, value;
                while (keys.hasMoreElements()) {
                	key = keys.nextElement();
                	value = nameReplacements.get(key);
                	sx.replaceAll(key, value);
                }
                s = sx.toString();
                cdata.setNodeValue(s);
            }
        }
	}
	catch (Exception e) {
		throw new Exception("Unable to make replacements",e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:24,代码来源:Migration5_0_0.java

示例6: fixingPublicAttrsInProviderAttributes

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Any @string reference in a <provider> value in AndroidManifest.xml will break on
 * build, thus preventing the application from installing. This is from a bug/error
 * in AOSP where public resources cannot be part of an authorities attribute within
 * a <provider> tag.
 *
 * This finds any reference and replaces it with the literal value found in the
 * res/values/strings.xml file.
 *
 * @param file File for AndroidManifest.xml
 * @throws AndrolibException
 */
public static void fixingPublicAttrsInProviderAttributes(File file) throws AndrolibException {
    if (file.exists()) {
        try {
            Document doc = loadDocument(file);
            XPath xPath = XPathFactory.newInstance().newXPath();
            XPathExpression expression = xPath.compile("/manifest/application/provider");

            Object result = expression.evaluate(doc, XPathConstants.NODESET);
            NodeList nodes = (NodeList) result;

            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                NamedNodeMap attrs = node.getAttributes();

                if (attrs != null) {
                    Node provider = attrs.getNamedItem("android:authorities");

                    if (provider != null) {
                        String reference = provider.getNodeValue();
                        String replacement = pullValueFromStrings(file.getParentFile(), reference);

                        if (replacement != null) {
                            provider.setNodeValue(replacement);
                            saveDocument(file, doc);
                        }
                    }
                }
            }

        }  catch (SAXException | ParserConfigurationException | IOException |
                XPathExpressionException | TransformerException ignored) {
        }
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:47,代码来源:ResXmlPatcher.java

示例7: updateAttributeValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void updateAttributeValue(Node node, String attName,
        int decimalPlacesSetting) {
    if (node.hasAttributes()
            && !"NumberOfOccurrence".equals(node.getNodeName())
            && !"ParameterValue".equals(node.getNodeName())) {
        Node attribute = node.getAttributes().getNamedItem(attName);
        if (attribute != null) {
            String priceValue = attribute.getNodeValue();
            if (priceValue != null && priceValue.length() > 0) {
                attribute.setNodeValue(getConvertedPrice(priceValue,
                        decimalPlacesSetting));
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:MigrationBillingResultDecimalPlace.java

示例8: setByPath

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void setByPath(Node doc, String path, String value) {
    Node node = getNodeByPath(doc, path, true);
    if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
        node.setNodeValue(value);
    } else if (node.hasChildNodes() && node.getFirstChild().getNodeType() == Node.TEXT_NODE) {
        node.getFirstChild().setTextContent(value);
    } else if (node.getNodeType() == Node.ELEMENT_NODE) {
        node.setTextContent(value);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:11,代码来源:XmlUtils.java

示例9: setValueForNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Retrieves the text value from a node's child text node.
 */
static void setValueForNode(Node node, String value)
{
	if( node != null )
	{
		switch( node.getNodeType() )
		{
			case Node.ELEMENT_NODE: {
				Node child = node.getFirstChild();
				if( child == null )
				{
					Document doc = node.getOwnerDocument();
					node.appendChild(doc.createTextNode(value));
				}
				else
				{
					child.setNodeValue(value);
				}
				break;
			}

			case Node.ATTRIBUTE_NODE: {

				Attr attribute = (Attr) node;
				attribute.getOwnerElement().setAttribute(attribute.getName(), value);
				break;
			}

			default:
				break;
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:DOMHelper.java

示例10: setText

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Set or replace the text value 
 */ 
public static void setText(Node node, String val) {
    Node chld=DomUtil.getChild(node, Node.TEXT_NODE);
    if( chld == null ) {
        Node textN=node.getOwnerDocument().createTextNode(val);
        node.appendChild(textN);
        return;
    }
    // change the value
    chld.setNodeValue(val);           
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DomUtil.java

示例11: setValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void setValue(String value) {
    Node valueNode = getValueNodeStrict();
    if (valueNode != null) {
        valueNode.setNodeValue(value);
    } else {
        try {
            addTextNode(value);
        } catch (SOAPException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ElementImpl.java

示例12: setText

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Set or replace the text value
 */
public static void setText(Node node, String val) {
	Node chld = DomUtil.getChild(node, Node.TEXT_NODE);
	if (chld == null) {
		Node textN = node.getOwnerDocument().createTextNode(val);
		node.appendChild(textN);
		return;
	}
	// change the value
	chld.setNodeValue(val);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:14,代码来源:DomUtil.java

示例13: setValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public void setValue(String value) {
    Node valueNode = getValueNodeStrict();
    if (valueNode != null) {
        valueNode.setNodeValue(value);
    } else {
        try {
            addTextNode(value);
        } catch (SOAPException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ElementImpl.java

示例14: acceptNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public short acceptNode(Node n) {
    String localname = n.getLocalName();
    if (localname.equals("_test-04")) {
        Node child = n.getFirstChild();
        String text = child.getNodeValue();
        if (text.equals("T%e!s#t$")) {
            child.setNodeValue("T%E!S#T$");
        }
    }
    return FILTER_ACCEPT;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DOML3InputSourceFactoryImpl.java

示例15: setAttribute

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void setAttribute(Node node, String attName, String val) {
    NamedNodeMap attributes=node.getAttributes();
    Node attNode=node.getOwnerDocument().createAttribute(attName);
    attNode.setNodeValue( val );
    attributes.setNamedItem(attNode);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:DomUtil.java


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