本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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) {}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
}
}
示例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;
}
示例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;
}