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


Java NamedNodeMap类代码示例

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


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

示例1: collectElementProperties

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private UiElementProperties collectElementProperties( Element elementNode, String mapId ) {

        UiElementProperties elementProperties = new UiElementProperties();

        NamedNodeMap nodeAttributes = (elementNode).getAttributes();
        for (int i = 0; i < nodeAttributes.getLength(); i++) {
            Node node = nodeAttributes.item(i);
            if (StringUtils.isNullOrEmpty(node.getNodeValue())) {
                throw new ElementsMapException("Error loading '" + mapId + "' element from map. '"
                                               + node.getNodeName() + "' contains an empty value");
            }
            if (StringUtils.isNullOrEmpty(node.getNodeName())) {
                throw new ElementsMapException("Error loading '" + mapId + "' element from map. '"
                                               + node.getNodeValue() + "' contains an empty key");
            }
            elementProperties.addProperty(node.getNodeName(), node.getNodeValue());
        }

        return elementProperties;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:21,代码来源:ElementsMap.java

示例2: parse

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
public Resource[] parse(Node rootNode, ParserContext parserContext) {
	NamedNodeMap nodeMap=rootNode.getAttributes();
	String locations=getAttributeValue("locations",nodeMap);
	if(StringUtils.isNotEmpty(locations)){
		String[] locationsArray=locations.split(LOCATION_SEPARATOR);
		List<Resource> resources=new ArrayList<Resource>();
		for(int i=0;i<locationsArray.length;i++){
			String location=locationsArray[i];
			if(StringUtils.isNotEmpty(location)){
				resources.add(resourcePatternResolver.getResource(location));					
			}
		}
		return resources.toArray(new Resource[resources.size()]);
	}else{
		return null;			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:18,代码来源:ResourcesElementParser.java

示例3: parseXml

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
@Override
public void parseXml(Node node) {
	super.parseXml(node);
	NamedNodeMap map=node.getAttributes();
	Node lockmodeNode=map.getNamedItem("lockmode");
	if(lockmodeNode!=null){
		LockModeType type=null;
		for(LockModeType mode:LockModeType.values()){
			if(mode.toString().equals(lockmodeNode.getNodeValue())){
				type=mode;
			}
		}
		this.lockmode=type;
	}
	Node multiplicityNode=map.getNamedItem("multiplicity");
	if(multiplicityNode!=null){
		this.multiplicity=multiplicityNode.getNodeValue();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:20,代码来源:JoinNode.java

示例4: displayMetadata

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
static void displayMetadata(Node node, int level) {
    for (int i = 0; i < level; i++) System.out.print("  ");
    System.out.print("<" + node.getNodeName());
    NamedNodeMap map = node.getAttributes();
    if (map != null) { // print attribute values
        int length = map.getLength();
        for (int i = 0; i < length; i++) {
            Node attr = map.item(i);
            System.out.print(" " + attr.getNodeName() +
                             "=\"" + attr.getNodeValue() + "\"");
        }
    }

    Node child = node.getFirstChild();
    if (child != null) {
        System.out.println(">"); // close current tag
        while (child != null) { // emit child tags recursively
            displayMetadata(child, level + 1);
            child = child.getNextSibling();
        }
        for (int i = 0; i < level; i++) System.out.print("  ");
        System.out.println("</" + node.getNodeName() + ">");
    } else {
        System.out.println("/>");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:MagentaEXIFTest.java

示例5: parse

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
@Override
public void parse(Consumer<MnoInfo> consumer) throws Exception {
    File fXmlFile = config.toFile();

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(fXmlFile);
    doc.getDocumentElement().normalize();
    XPathExpression xpathMno = XPathFactory.newInstance().newXPath().compile("//*[local-name()='mno']");
    XPathExpression xpathMasksMno = XPathFactory.newInstance().newXPath().compile("//*[local-name()='mask']");
    NodeList mnoNodes = (NodeList) xpathMno.evaluate(doc, XPathConstants.NODESET);
    for (int i=0; i<mnoNodes.getLength(); i++) {
        Node node = mnoNodes.item(i);
        NamedNodeMap attributes = node.getAttributes();
        String country = getValue(attributes.getNamedItem("country"));
        String title = getValue(attributes.getNamedItem("title"));
        String area = getValue(attributes.getNamedItem("area"));
        Set<Mask> masks = new HashSet<>();
        NodeList maskNodes = (NodeList) xpathMasksMno.evaluate(doc, XPathConstants.NODESET);
        for (int j=0; j<maskNodes.getLength(); j++) {
            masks.add(Mask.parse(getValue(maskNodes.item(j))));
        }
        consumer.accept(new MnoInfo(title, area, country, masks));
    }
}
 
开发者ID:chukanov,项目名称:mnp,代码行数:26,代码来源:CustomMasksParser.java

示例6: examineNode

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
/**
 * A single node is read, the namespace attributes are extracted and stored.
 * 
 * @param node
 *            to examine
 * @param attributesOnly,
 *            if true no recursion happens
 */
private void examineNode(Node node, boolean attributesOnly) {
	while(node != null && node.getNodeType() == Node.COMMENT_NODE) {
		node = node.getNextSibling();
	}
	if(node != null) {
		NamedNodeMap attributes = node.getAttributes();
		if(attributes != null) {
			for (int i = 0; i < attributes.getLength(); i++) {
				Node attribute = attributes.item(i);
				storeAttribute((Attr) attribute);
			}
		}

		if (!attributesOnly) {
			NodeList chields = node.getChildNodes();
			for (int i = 0; i < chields.getLength(); i++) {
				Node chield = chields.item(i);
				if (chield.getNodeType() == Node.ELEMENT_NODE)
					examineNode(chield, false);
			}
		}
	}
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:32,代码来源:UniversalNamespaceCache.java

示例7: parseDropListItem

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private void parseDropListItem(Node drop_list_item, DropListScope dropListScope, List<IDropItem> drops)
{
	final NamedNodeMap attrs = drop_list_item.getAttributes();
	switch (drop_list_item.getNodeName().toLowerCase())
	{
		case "item":
		{
			final IDropItem dropItem = dropListScope.newDropItem(parseInteger(attrs, "id"), parseLong(attrs, "min"), parseLong(attrs, "max"), parseDouble(attrs, "chance"));
			if (dropItem != null)
			{
				drops.add(dropItem);
			}
			break;
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:17,代码来源:NpcData.java

示例8: compareElementAttrs

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private static boolean compareElementAttrs(Element e1, Element e2) {
    NamedNodeMap at1 = e1.getAttributes();
    NamedNodeMap at2 = e2.getAttributes();
    if (at1.getLength() != at2.getLength()) {
        System.out.println("Different number of attributes");
    }
    for (int i = 0; i < at1.getLength(); i++) {
        Attr attr1 = (Attr)at1.item(i);
        Attr attr2 = (Attr)at2.getNamedItemNS(attr1.getNamespaceURI(), attr1.getLocalName());
        if (attr2 == null) {
            System.out.println("Attribute " + attr1.getNodeName() + " not found");
            return false;
        }
        if (!compareStrings(attr1.getNodeValue(), attr2.getNodeValue())) {
            System.out.println("Different attributes " + attr1.getNodeName() + " and " + attr2.getNodeName());
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DOMCompare.java

示例9: parseXml

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
@Override
public void parseXml(Node node) {
	super.parseXml(node);
	NamedNodeMap nodeMap=node.getAttributes();
	Node expr=nodeMap.getNamedItem("expr");
	if(expr!=null){
		this.type=DecisionType.expression;
		this.expression=expr.getNodeValue();
	}else{
		NodeList list=node.getChildNodes();
		for(int i=0;i<list.getLength();i++){
			Node cnode=list.item(i);
			if(cnode.getNodeName().equals("handler")){
				this.type=DecisionType.handlerClass;
				NamedNodeMap map=cnode.getAttributes();
				this.handlerClass=map.getNamedItem("class").getNodeValue();
				break;
			}
		}			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:22,代码来源:DecisionNode.java

示例10: parseHuntingBonus

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private void parseHuntingBonus(Node node)
{
	forEach(node, IXmlReader::isNode, memberNode ->
	{
		if ("hunting".equalsIgnoreCase(memberNode.getNodeName()))
		{
			final NamedNodeMap attrs = memberNode.getAttributes();
			final int requiredAmount = parseInteger(attrs, "points");
			final int level = parseInteger(attrs, "level");
			final ClanRewardBonus bonus = new ClanRewardBonus(ClanRewardType.HUNTING_MONSTERS, level, requiredAmount);
			forEach(memberNode, IXmlReader::isNode, itemsNode ->
			{
				if ("item".equalsIgnoreCase(itemsNode.getNodeName()))
				{
					final NamedNodeMap itemsAttr = itemsNode.getAttributes();
					final int id = parseInteger(itemsAttr, "id");
					final int count = parseInteger(itemsAttr, "count");
					bonus.setItemReward(new ItemHolder(id, count));
				}
			});
			_clanRewards.computeIfAbsent(bonus.getType(), key -> new ArrayList<>()).add(bonus);
		}
	});
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:25,代码来源:ClanRewardData.java

示例11: checkAttributesEqual

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
protected boolean checkAttributesEqual(final Element p1, final Element p2) {
    if (p1 == null || p2 == null) return false;
    NamedNodeMap nm1 = p1.getAttributes();
    NamedNodeMap nm2 = p2.getAttributes();
    if( nm1.getLength() != nm2.getLength() ) return false;
    
    for ( int i = 0; i < nm1.getLength(); i++ ) {
        Node attr2 = (Node) nm2.getNamedItem(nm1.item(i).getNodeName());
        if ( attr2 == null ) return false;
        if(nm2.item(i) != attr2) return false;
        List<Token> t1List = ((NodeImpl)nm1.item(i)).getTokens();            
        List<Token> t2List = ( (NodeImpl) attr2 ).getTokens();
        boolean status = compareTokenEquals( t1List, t2List );
        if ( !status ) return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DiffFinder.java

示例12: consolidateAttributePrefix

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private void consolidateAttributePrefix(List<Node> parentAndAncestors, Element newNode) {
    NamedNodeMap nnm = newNode.getAttributes();
    for (int i=0; i<nnm.getLength(); i++) {
        if (! (nnm.item(i) instanceof Attribute))  continue;
        Attribute attr = (Attribute) nnm.item(i);
        String prefix = attr.getPrefix();
        if (prefix != null && ! attr.isXmlnsAttribute()) {
            String namespace = newNode.lookupNamespaceURI(prefix);
            if (namespace == null) continue;
            prefix = NodeImpl.lookupPrefix(namespace, parentAndAncestors);
              if (prefix != null) {
                attr.setPrefix(prefix);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:XDMModel.java

示例13: mergeStandardTextNode

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
private void mergeStandardTextNode(Node node)
    throws IIOInvalidTreeException {
    // Convert to comments.  For the moment ignore the encoding issue.
    // Ignore keywords, language, and encoding (for the moment).
    // If compression tag is present, use only entries with "none".
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        NamedNodeMap attrs = child.getAttributes();
        Node comp = attrs.getNamedItem("compression");
        boolean copyIt = true;
        if (comp != null) {
            String compString = comp.getNodeValue();
            if (!compString.equals("none")) {
                copyIt = false;
            }
        }
        if (copyIt) {
            String value = attrs.getNamedItem("value").getNodeValue();
            COMMarkerSegment com = new COMMarkerSegment(value);
            insertCOMMarkerSegment(com);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:JPEGMetadata.java

示例14: toNodeSet

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
/**
 * Converts an Iterator to a Set of Nodes, according to the XPath
 * Data Model.
 *
 * @param i the Iterator
 * @return the Set of Nodes
 */
static Set<Node> toNodeSet(Iterator<Node> i) {
    Set<Node> nodeSet = new HashSet<Node>();
    while (i.hasNext()) {
        Node n = i.next();
        nodeSet.add(n);
        // insert attributes nodes to comply with XPath
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap nnm = n.getAttributes();
            for (int j = 0, length = nnm.getLength(); j < length; j++) {
                nodeSet.add(nnm.item(j));
            }
        }
    }
    return nodeSet;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:Utils.java

示例15: fromNode

import org.w3c.dom.NamedNodeMap; //导入依赖的package包/类
@Override
public Account fromNode(Node node) {
    NamedNodeMap attributes = node.getAttributes();
    float initialAmount = 0;
    if (attributes.getNamedItem("initial") != null) {
        initialAmount = Float.parseFloat(attributes.getNamedItem("initial").getNodeValue());
    }
    Account account = new Account(
            Integer.parseInt(attributes.getNamedItem("key").getNodeValue()),
            attributes.getNamedItem("name").getNodeValue(),
            Integer.parseInt(attributes.getNamedItem("curr").getNodeValue()),
            initialAmount
    );

    Node flags = attributes.getNamedItem("flags");
    if (flags != null) {
        account.setFlags(Integer.parseInt(flags.getNodeValue()));
    }
    return account;
}
 
开发者ID:monsieurh,项目名称:homebank_android,代码行数:21,代码来源:AccountFactory.java


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