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


Java Node.getAttributes方法代码示例

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


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

示例1: parseTable

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected void parseTable(Node n)
{
    NamedNodeMap attrs = n.getAttributes();
    String name = attrs.getNamedItem("name").getNodeValue();
    if (name.charAt(0) != '#') throw new IllegalArgumentException("Table name must start with #");
    StringTokenizer data = new StringTokenizer(n.getFirstChild().getNodeValue());
    List<String> array = new ArrayList<>();
    while (data.hasMoreTokens())
        array.add(data.nextToken());
    String[] res = new String[array.size()];
    int i = 0;
    for (String str : array)
    {
        res[i++] = str;
    }
    setTable(name, res);
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:18,代码来源:DocumentBase.java

示例2: compareElementNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
static boolean compareElementNode(@NonNull Node node1, @NonNull Node node2, boolean strict) {
    if (!node1.getNodeName().equals(node2.getNodeName())) {
        return false;
    }

    NamedNodeMap attr1 = node1.getAttributes();
    NamedNodeMap attr2 = node2.getAttributes();

    if (!compareAttributes(attr1, attr2)) {
        return false;
    }

    if (strict) {
        return compareChildren(node1.getChildNodes(), node2.getChildNodes());
    }

    return compareContent(node1.getChildNodes(), node2.getChildNodes());
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:NodeUtils.java

示例3: getAttributeValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
static int getAttributeValue(Node node,
                             NamedNodeMap attrs,
                             String name,
                             int min,
                             int max,
                             boolean required)
    throws IIOInvalidTreeException {
    if (attrs == null) {
        attrs = node.getAttributes();
    }
    String valueString = attrs.getNamedItem(name).getNodeValue();
    int value = -1;
    if (valueString == null) {
        if (required) {
            throw new IIOInvalidTreeException
                (name + " attribute not found", node);
        }
    } else {
          value = Integer.parseInt(valueString);
          if ((value < min) || (value > max)) {
              throw new IIOInvalidTreeException
                  (name + " attribute out of range", node);
          }
    }
    return value;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:MarkerSegment.java

示例4: parseXml

import org.w3c.dom.Node; //导入方法依赖的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

示例5: parsePluralsValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
private ResourceValue parsePluralsValue(PluralsResourceValue value) {
    NodeList children = mValue.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);

        if (child.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap attributes = child.getAttributes();
            String quantity = getAttributeValue(attributes, ATTR_QUANTITY);
            if (quantity != null) {
                String text = getTextNode(child.getChildNodes());
                text = ValueXmlHelper.unescapeResourceString(text, false, true);
                value.addPlural(quantity, text);
            }
        }
    }

    return value;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:ResourceItem.java

示例6: testGetValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void testGetValue () throws Exception {
    Color c = new Color (16, 16, 16);
    System.out.println("original "+c);
    XMLPropertyEditor propEd = new ColorEditor();
    propEd.setValue(c);
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Node element = propEd.storeToXML(doc);

    NamedNodeMap nodeMap = element.getAttributes();
    for (int i = 0; i < nodeMap.getLength(); i++) {
        System.out.println("attr "+i+", "+nodeMap.item(i));
    }
    
    propEd.readFromXML(element);
    Color restoredColor = (Color)propEd.getValue();
    System.out.println("restoredColor "+restoredColor);
    assertEquals("Restored value has to be the same", c, restoredColor);
    assertTrue("It is Color", restoredColor instanceof Color);
    assertFalse("It is not SuperColor", restoredColor instanceof ColorEditor.SuperColor);
    System.out.println("GENERATE: " + propEd.getJavaInitializationString ());
    assertEquals ("Generate Java source with UI color.", "new java.awt.Color(16, 16, 16)", propEd.getJavaInitializationString ());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ColorEditorTest.java

示例7: parseShortcuts

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Parses a shortcut.
 * @param d the node
 */
private void parseShortcuts(Node d)
{
	NamedNodeMap attrs = d.getAttributes();
	final Node classIdNode = attrs.getNamedItem("classId");
	final List<Shortcut> list = new ArrayList<>();
	for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
	{
		if ("page".equals(c.getNodeName()))
		{
			attrs = c.getAttributes();
			final int pageId = parseInteger(attrs, "pageId");
			for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
			{
				if ("slot".equals(b.getNodeName()))
				{
					list.add(createShortcut(pageId, b));
				}
			}
		}
	}
	
	if (classIdNode != null)
	{
		_initialShortcutData.put(ClassId.getClassId(Integer.parseInt(classIdNode.getNodeValue())), list);
	}
	else
	{
		_initialGlobalShortcutList.addAll(list);
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:35,代码来源:InitialShortcutData.java

示例8: extractPolyItem

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Convert polygon element into a path.
 */
private static void extractPolyItem(SvgTree avg, SvgLeafNode child, Node currentGroupNode) {
    logger.log(Level.FINE, "Rect found" + currentGroupNode.getTextContent());
    if (currentGroupNode.getNodeType() == Node.ELEMENT_NODE) {

        NamedNodeMap a = currentGroupNode.getAttributes();
        int len = a.getLength();

        for (int itemIndex = 0; itemIndex < len; itemIndex++) {
            Node n = a.item(itemIndex);
            String name = n.getNodeName();
            String value = n.getNodeValue();
            if (name.equals(SVG_STYLE)) {
                addStyleToPath(child, value);
            } else if (presentationMap.containsKey(name)) {
                child.fillPresentationAttributes(name, value);
            } else if (name.equals(SVG_POINTS)) {
                PathBuilder builder = new PathBuilder();
                String[] split = value.split("[\\s,]+");
                float baseX = Float.parseFloat(split[0]);
                float baseY = Float.parseFloat(split[1]);
                builder.absoluteMoveTo(baseX, baseY);
                for (int j = 2; j < split.length; j += 2) {
                    float x = Float.parseFloat(split[j]);
                    float y = Float.parseFloat(split[j + 1]);
                    builder.relativeLineTo(x - baseX, y - baseY);
                    baseX = x;
                    baseY = y;
                }
                builder.relativeClose();
                child.setPathData(builder.toString());
            }
        }
    }
}
 
开发者ID:RaysonYeungHK,项目名称:Svg2AndroidXml,代码行数:38,代码来源:Svg2Vector.java

示例9: getAttributeValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static String getAttributeValue(Node node, String attributeName) {
    if (node == null) {
        return null;
    }

    NamedNodeMap attribs = node.getAttributes();
    if (attribs != null && attribs.getNamedItem(attributeName) != null) { // NOI18N
        return attribs.getNamedItem(attributeName).getNodeValue(); // NOI18N
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:HibernateRefactoringUtil.java

示例10: copyNodeAndAttributes

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static final org.w3c.dom.Element copyNodeAndAttributes(Node node) {
	org.w3c.dom.Element result = document.createElement(node.getNodeName());
	NamedNodeMap attributes = node.getAttributes();
	for (int i = 0; i < attributes.getLength(); ++i) {
		Node a = attributes.item(i);
		String name = a.getNodeName();
		String value = a.getNodeValue();
		result.setAttribute(name, value);
	}
	return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:12,代码来源:XMLReader.java

示例11: parseAttributes

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected Properties parseAttributes(Node node) {
    Properties attributes = new Properties();
    NamedNodeMap nnm = node.getAttributes();
    for (int i = 0; i < nnm.getLength(); i++) {
        Node attribute = nnm.item(i);
        String value = parsePropertyTokens(attribute.getNodeValue());
        attributes.put(attribute.getNodeName(), value);
    }

    return attributes;
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:12,代码来源:MyBatisGeneratorConfigurationParser.java

示例12: getAttribute

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static String getAttribute(Node node, String name) {
  NamedNodeMap attributes = node.getAttributes();
  if (attributes == null) {
    return null;
  }

  Node attributeNode = node.getAttributes().getNamedItem(name);
  if (attributeNode == null) {
    return null;
  }
  return attributeNode.getTextContent();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:XmlUtils.java

示例13: parseDocument

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	final Node table = doc.getFirstChild();
	final NamedNodeMap tableAttr = table.getAttributes();
	
	MAX_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxLevel").getNodeValue()) + 1);
	MAX_PET_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxPetLevel").getNodeValue()) + 1);
	
	if (MAX_LEVEL > Config.PLAYER_MAXIMUM_LEVEL)
	{
		MAX_LEVEL = Config.PLAYER_MAXIMUM_LEVEL;
	}
	if (MAX_PET_LEVEL > MAX_LEVEL)
	{
		MAX_PET_LEVEL = MAX_LEVEL; // Pet level should not exceed owner level.
	}
	
	int maxLevel = 0;
	for (Node n = table.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("experience".equals(n.getNodeName()))
		{
			final NamedNodeMap attrs = n.getAttributes();
			maxLevel = parseInteger(attrs, "level");
			if (maxLevel > Config.PLAYER_MAXIMUM_LEVEL)
			{
				break;
			}
			_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:34,代码来源:ExperienceData.java

示例14: setPropsForCompileFile

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Description: Editing the xml file for compiling files.
 * @param init path to the xml file
 * @param sourceFile path to the source to be compiled
 */
public static void setPropsForCompileFile(String init, String sourceFile) {
    try {
        File file = new File(sourceFile);
        
        String filepath = init;
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(filepath);
        
        // get project 
        //Node project = doc.getFirstChild();
        Node prop1 = doc.getElementsByTagName("property").item(0);
        Node prop2 = doc.getElementsByTagName("property").item(1);
        Node prop3 = doc.getElementsByTagName("property").item(2);
        
        NamedNodeMap srcAttr = prop1.getAttributes();
        Node srcName = srcAttr.getNamedItem("location");
        srcName.setTextContent( file.getParent());
        
        NamedNodeMap buildAttr = prop2.getAttributes();
        Node buildName = buildAttr.getNamedItem("location");
        buildName.setTextContent( file.getParent());
        
        NamedNodeMap fileAttr = prop3.getAttributes();
        Node fileName = fileAttr.getNamedItem("value");
        fileName.setTextContent( file.getName());
        
        updateBuildFile( filepath, doc);
        
    } catch (Exception ex) {}
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:37,代码来源:BuildSys.java

示例15: Htable

import org.w3c.dom.Node; //导入方法依赖的package包/类
Htable(Node node) throws IIOInvalidTreeException {
    if (node.getNodeName().equals("dhtable")) {
        NamedNodeMap attrs = node.getAttributes();
        int count = attrs.getLength();
        if (count != 2) {
            throw new IIOInvalidTreeException
                ("dhtable node must have 2 attributes", node);
        }
        tableClass = getAttributeValue(node, attrs, "class", 0, 1, true);
        tableID = getAttributeValue(node, attrs, "htableId", 0, 3, true);
        if (node instanceof IIOMetadataNode) {
            IIOMetadataNode ourNode = (IIOMetadataNode) node;
            JPEGHuffmanTable table =
                (JPEGHuffmanTable) ourNode.getUserObject();
            if (table == null) {
                throw new IIOInvalidTreeException
                    ("dhtable node must have user object", node);
            }
            numCodes = table.getLengths();
            values = table.getValues();
        } else {
            throw new IIOInvalidTreeException
                ("dhtable node must have user object", node);
        }
    } else {
        throw new IIOInvalidTreeException
            ("Invalid node, expected dqtable", node);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:DHTMarkerSegment.java


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