當前位置: 首頁>>代碼示例>>Java>>正文


Java NamedNodeMap.getNamedItem方法代碼示例

本文整理匯總了Java中org.w3c.dom.NamedNodeMap.getNamedItem方法的典型用法代碼示例。如果您正苦於以下問題:Java NamedNodeMap.getNamedItem方法的具體用法?Java NamedNodeMap.getNamedItem怎麽用?Java NamedNodeMap.getNamedItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.dom.NamedNodeMap的用法示例。


在下文中一共展示了NamedNodeMap.getNamedItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:JPEGMetadata.java

示例2: createSplitOperation

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
private List<SubOperation> createSplitOperation(NamedNodeMap node) {
    List<SubOperation> subOperations = new ArrayList<>();
    String splitPattern = Pattern.quote("||");

    String[] splitAmount = node.getNamedItem("samt").getNodeValue().split(splitPattern);
    String[] splitCategoryKey = node.getNamedItem("scat").getNodeValue().split(splitPattern);

    String[] splitMemo = new String[splitAmount.length];
    if (node.getNamedItem("smem") != null) {
        splitMemo = node.getNamedItem("smem").getNodeValue().split(splitPattern);
    }

    for (int i = 0; i < splitAmount.length; i++) {
        subOperations.add(new SubOperation(
                i < splitCategoryKey.length ? Integer.parseInt(splitCategoryKey[i]) : 0,
                Float.parseFloat(splitAmount[i]),
                i < splitMemo.length ? splitMemo[i] : ""
        ));
    }
    return subOperations;
}
 
開發者ID:monsieurh,項目名稱:homebank_android,代碼行數:22,代碼來源:OperationFactory.java

示例3: getAttributeValue

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
@Nullable
private static String getAttributeValue(NamedNodeMap attributes, String attributeName) {
    Attr attribute = (Attr) attributes.getNamedItem(attributeName);
    if (attribute != null) {
        return attribute.getValue();
    }

    return null;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:10,代碼來源:ResourceItem.java

示例4: getAttributeValue

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
public static int getAttributeValue( Node node, String attributeName, int defaultValue ) {
    NamedNodeMap nnm = node.getAttributes();
    Node attribute = nnm.getNamedItem( attributeName );
    if (attribute == null) {
        return defaultValue;
    } else try {
        return Integer.parseInt( attribute.getNodeValue() );
    } catch (NumberFormatException e) {
        return defaultValue;
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:12,代碼來源:NodeUtils.java

示例5: getProcessKey

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
private String getProcessKey(InputStream workflowDefinition) throws Exception
{
    try 
    {
        InputSource inputSource = new InputSource(workflowDefinition);
        DOMParser parser = new DOMParser();
        parser.parse(inputSource);
        Document document = parser.getDocument();
        NodeList elemnts = document.getElementsByTagName("process");
        if (elemnts.getLength() < 1)
        {
            throw new IllegalArgumentException("The input stream does not contain a process definition!");
        }
        NamedNodeMap attributes = elemnts.item(0).getAttributes();
        Node idAttrib = attributes.getNamedItem("id");
        if (idAttrib == null)
        {
            throw new IllegalAccessError("The process definition does not have an id!");
        }
        
        if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled())
        {
            // Workflow-definition is deployed tenant-aware, key should be altered
            return factory.getDomainProcessKey(idAttrib.getNodeValue());
        }
        else
        {
            return idAttrib.getNodeValue();
        }
    }
    finally
    {
        workflowDefinition.close();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:36,代碼來源:ActivitiWorkflowEngine.java

示例6: setPropsForJavaDoc

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
 * Description: Editing the xml file for building javadoc files.
 * @param init path to the xml file
 * @param srcDir path to the source directory
 * @param docsDir path to the docs directory
 */
public static void setPropsForJavaDoc(String init, String srcDir, String docsDir) {
    
    try {
        //String filepath = "/Users/ATTJ/Desktop/xmlPlay/build.xml";
        String filepath = init;
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(filepath);
        
        // get property, location src
        Node prop1 = doc.getElementsByTagName("property").item(0);
        // get property, location docs
        Node prop2 = doc.getElementsByTagName("property").item(1);
        
        NamedNodeMap buildAttr = prop1.getAttributes();
        Node buildName = buildAttr.getNamedItem("location");
        buildName.setTextContent(srcDir);
        
        NamedNodeMap distAttr = prop2.getAttributes();
        Node distName = distAttr.getNamedItem("location");
        distName.setTextContent(docsDir);
        
        updateBuildFile( filepath, doc);
        
    } catch (Exception e) {}
}
 
開發者ID:bufferhe4d,項目名稱:call-IDE,代碼行數:33,代碼來源:BuildSys.java

示例7: getAttributeValue

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
* get the attribute with the given name from the given node as an int value
* @param node - the node to look in
* @param attributeName - the attribute's name to look for
* @param defaultValue
* @return - the value - defaultValue as default 
*/
 public static int getAttributeValue( Node node, String attributeName, int defaultValue ) {
     NamedNodeMap nnm = node.getAttributes();
     Node attribute = nnm.getNamedItem( attributeName );
     if (attribute == null) {
         return defaultValue;
     } else try {
         return Integer.parseInt( attribute.getNodeValue() );
     } catch (NumberFormatException e) {
         return defaultValue;
     }
 }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:NodeUtils.java

示例8: getNodeAttribute

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
public static String getNodeAttribute(Node node, String attribute, String defaultValue) {
	String value = defaultValue;
	if (node != null) {
		NamedNodeMap attributes = node.getAttributes();
		if (attributes != null) {
			Node attributeNode = attributes.getNamedItem(attribute);
			if (attributeNode != null) {
				value = attributeNode.getNodeValue();
			}
		}
	}
	return value;
}
 
開發者ID:nasa,項目名稱:OpenVSP3Plugin,代碼行數:14,代碼來源:XPathUtil.java

示例9: concatAttributes

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
 * Retrieve and concatenate a node's attribute name/value pairs
 * 
 * @param nextNode
 *            the next node in the XML tree to be parsed.
 * @param resultText
 *            the concatenated result text.
 * 
 * @return the concatenated result text.
 */
private String concatAttributes(Node nextNode, String resultText) {
	try {
		// process element attributes
		if (nextNode.getAttributes() != null) {
			NamedNodeMap attributes = nextNode.getAttributes();
			String attributesBlock = "";
			if (attributes.getNamedItem("name") != null) { // name attribute
															// first.
				attributesBlock = attributesBlock + "name="
						+ attributes.getNamedItem("name").getNodeValue();
				if (attributes.getLength() > 1) {
					attributesBlock = attributesBlock + ", ";
				}
			}
			// Clean up DP response namespace declaration.
			for (int i = 0; i < attributes.getLength(); i++) {
				if (!attributes.item(i).getNodeValue()
						.contains("soap-envelope")
						&& (attributes.item(i).getLocalName() != "name")) {
					attributesBlock = attributesBlock
							+ attributes.item(i).getLocalName() + "="
							+ attributes.item(i).getNodeValue();
					if (i != attributes.getLength() - 1) {
						attributesBlock = attributesBlock + ", ";
					}
				}
			}
			if (attributesBlock != "") {
				resultText = resultText + ", " + attributesBlock;
			}
		}
	} catch (NullPointerException ex) {
		return resultText;
	}
	return resultText;
}
 
開發者ID:mqsysadmin,項目名稱:dpdirect,代碼行數:47,代碼來源:ResponseParser.java

示例10: getNamespaceURI

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
 * This method is not particularly fast, but shouldn't be called very
 * often. If we start to use it more, we should keep track of the
 * NS declarations using a NamespaceContext implementation instead.
 */
public String getNamespaceURI(String prefix) {
    if (prefix == null) {
        throw new IllegalArgumentException("DOMStreamReader: getNamespaceURI(String) call with a null prefix");
    }
    else if (prefix.equals("xml")) {
        return "http://www.w3.org/XML/1998/namespace";
    }
    else if (prefix.equals("xmlns")) {
        return "http://www.w3.org/2000/xmlns/";
    }

    // check scopes
    String nsUri = scopes[depth].getNamespaceURI(prefix);
    if(nsUri!=null)    return nsUri;

    // then ancestors above start node
    Node node = findRootElement();
    String nsDeclName = prefix.length()==0 ? "xmlns" : "xmlns:"+prefix;
    while (node.getNodeType() != DOCUMENT_NODE) {
        // Is ns declaration on this element?
        NamedNodeMap namedNodeMap = node.getAttributes();
        Attr attr = (Attr) namedNodeMap.getNamedItem(nsDeclName);
        if (attr != null)
            return attr.getValue();
        node = node.getParentNode();
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:DOMStreamReader.java

示例11: fromFile

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
 * Create an instance from a file
 * @param fileNode
 */
public static FileSnapshot fromFile( Element fileNode ) {

    NamedNodeMap fileAttributes = fileNode.getAttributes();

    String pathAtt = fileAttributes.getNamedItem("path").getNodeValue();
    long fileSize = -1;
    long fileTimeModified = -1;
    String fileMD5 = null;
    String filePermissions = null;

    Node sizeNode = fileAttributes.getNamedItem("size");
    if (sizeNode != null) {
        fileSize = Long.parseLong(sizeNode.getNodeValue());
    }
    Node timeModifiedNode = fileAttributes.getNamedItem("modified");
    if (timeModifiedNode != null) {
        fileTimeModified = SnapshotUtils.stringToDate(timeModifiedNode.getNodeValue());
    }
    Node md5Node = fileAttributes.getNamedItem("md5");
    if (md5Node != null) {
        fileMD5 = md5Node.getNodeValue();
    }
    Node permissionsNode = fileAttributes.getNamedItem("permissions");
    if (permissionsNode != null) {
        filePermissions = permissionsNode.getNodeValue();
    }
    FileSnapshot fileSnapshot = new FileSnapshot(pathAtt, fileSize, fileTimeModified, fileMD5,
                                                 filePermissions);

    log.debug("Add " + fileSnapshot.toString());

    return fileSnapshot;
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:38,代碼來源:FileSnapshot.java

示例12: getNodeAttribute

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
 * get the attribute with the given name from the given node
 * @param node - the node to look in
 * @param attributeName - the attribute's name to look for
 * @param defaultValue
 * @return - the value - defaultValue as default
 */
public static String getNodeAttribute( Node node, String attributeName, String defaultValue ) {
    NamedNodeMap attributes = node.getAttributes();
    if (attributes == null) return defaultValue;

    Node attribute = attributes.getNamedItem( attributeName );
    return (attribute == null) ? defaultValue : attribute.getNodeValue();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:NodeUtils.java

示例13: readClasspathFile

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
private void readClasspathFile(ProjectImpl definition) {
    File classpathfile = new File(definition.getLocation(), FILE_CLASSPATH);
    // May not exist for non Java projects
    if (!classpathfile.exists()) {
        return;
    }
    Document doc = parse(classpathfile);
    NodeList entries = doc.getElementsByTagName("classpathentry");
    for (int i = 0; i < entries.getLength(); i++) {
        NamedNodeMap attrs = entries.item(i).getAttributes();
        String path = attrs.getNamedItem("path").getNodeValue();
        String kind = attrs.getNamedItem("kind").getNodeValue();
        File location = getLocation(definition.getLocation(), path, kind);
        if (kind.equals("lib")) {
            definition.libraries.add(location);
            Node exattr = attrs.getNamedItem("exported");
            if (exattr != null && "true".equals(exattr.getNodeValue())) {
                definition.exportedlibraries.add(location);
            }
        }
        if (kind.equals("src")) {
            if (path.startsWith("/")) {
                // Java project reference
                String ref = path.substring(1);
                definition.dependencies.add(ref);
                definition.javapathdependencies.add(ref);
            } else {
                // local source folder
                definition.javasourcefolders.add(location);
            }
        }
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:34,代碼來源:EclipseProjectReader.java

示例14: compareAttr

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
protected boolean compareAttr(org.w3c.dom.Element n1, org.w3c.dom.Element n2) {
    NamedNodeMap attrs1 = n1.getAttributes();
    NamedNodeMap attrs2 = n2.getAttributes();
    
    List<String> nameSet = getIdentifiers();
    if( nameSet.isEmpty() )
        return true;
    else if ( attrs1.getLength() == 0 && attrs2.getLength() == 0 )
        return true;
    
    int matchCount = 0;
    int unmatchCount = 0;
    for ( String name:nameSet ) {
        Node attr1 = (Node) attrs1.getNamedItem( name );
        Node attr2 = (Node) attrs2.getNamedItem( name );
        if ( attr1 == null && attr2 == null )
            continue;
        else if ( attr1 != null && attr2 != null ){
            if ( attr2.getNodeValue().intern() != attr1.getNodeValue().intern() )
                unmatchCount++;
            else
                matchCount++;
        } else
            unmatchCount++;
        //check for exact match
        if ( matchCount == 1 )
            return true;
        
        //check for rename
        if ( unmatchCount == 1 && attrs1.getLength() == attrs2.getLength() )
            return false;
    }
    
    //no attributes in attrs1 and attrs2 that match nameSet
    if ( matchCount == 0 && unmatchCount == 0 )
        return true;
    
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:DefaultElementIdentity.java

示例15: fromNode

import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
@Override
public Operation fromNode(Node operationNode) {
    NamedNodeMap attributes = operationNode.getAttributes();

    String date = attributes.getNamedItem("date").getNodeValue();
    String accountKey = attributes.getNamedItem("account").getNodeValue();
    String amount = attributes.getNamedItem("amount").getNodeValue();

    Operation operation = new Operation(
            Float.parseFloat(amount),
            Integer.parseInt(accountKey),
            HbCompat.julianToDate(Long.parseLong(date))
    );

    Node category = attributes.getNamedItem("category");
    if (category != null) {
        operation.setCategoryKey(Integer.parseInt(category.getNodeValue()));
    }

    Node wording = attributes.getNamedItem("wording");
    if (wording != null) {
        operation.setWording(wording.getNodeValue());
    }

    Node flags = attributes.getNamedItem("flags");
    if (flags != null) {
        operation.setFlags(Integer.parseInt(flags.getNodeValue()));
    }

    Node payeeKey = attributes.getNamedItem("payee");
    if (payeeKey != null) {
        operation.setPayeeKey(Integer.parseInt(payeeKey.getNodeValue()));
    }

    Node status = attributes.getNamedItem("st");
    if (status != null) {
        operation.setStatus(Integer.parseInt(status.getNodeValue()));
    } else {
        operation.setStatus(0);
    }

    if (operation.hasFlag(OperationFlags.OF_SPLIT)) {
        List<SubOperation> split = createSplitOperation(attributes);
        operation.setSubOperations(split);
    }

    return operation;
}
 
開發者ID:monsieurh,項目名稱:homebank_android,代碼行數:49,代碼來源:OperationFactory.java


注:本文中的org.w3c.dom.NamedNodeMap.getNamedItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。