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


Java DifferenceConstants.ATTR_NAME_NOT_FOUND_ID属性代码示例

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


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

示例1: isCausedByIgnoredAttribute

/**
 * Ignores all differences caused by an ignored attribute (see {@link DiffConfiguration#getIgnoredAttributes()}
 * @param difference
 * @return
 */
protected boolean isCausedByIgnoredAttribute(Difference difference) {
	if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID){
		//ignore attributes belonging to a certain namespace
		String attrName = difference.getControlNodeDetail().getValue();
		Node node;
		if (attrName == null || attrName.equals(ATTR_NULL)){
			attrName = difference.getTestNodeDetail().getValue();
			node = helper.getDocumentNode(difference, XmlDiffDocumentType.TEST, false);
		}else{
			node = helper.getDocumentNode(difference, XmlDiffDocumentType.CONTROL, false);
		}
		String namespace = helper.getNamespaceOfAttribute(attrName, node.getAttributes());
		if (namespace != null && ignoredNamespacesInAttributes.contains(namespace)){
			//add attribute name to ignored attributes so that a difference in attribute numbers can be caught later on
               getAttributeSetForNode(node, ignoredAttributesMap)
                       .add(attrName);
			return true;
		}
			
	}
	return isCausedByAttribute(difference, false);
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:27,代码来源:AbstractXmlDifferenceListener.java

示例2: isCausedByAddingDefaultAttribute

/**
 * Ignores all differences when the test model has added optional attributes
 * missing from the reference.
 * 
 * @param difference
 * @return
 */
protected boolean isCausedByAddingDefaultAttribute(Difference difference) {
    if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID) {
        // ignore attributes belonging to a certain namespace
        String attrName = difference.getControlNodeDetail().getValue();
        String testAttrName = difference.getTestNodeDetail().getValue();
        Node node;
        if (attrName == null || attrName.equals(ATTR_NULL)) {
            node = helper.getDocumentNode(difference,
                    XmlDiffDocumentType.TEST, false);
        } else {
            node = helper.getDocumentNode(difference,
                    XmlDiffDocumentType.CONTROL, false);
        }
        Set<String> defaultedAttributesForNode = getAttributeSetForNode(
                node, defaultAttributesMap);
        for (String string : defaultedAttributesForNode) {
            if (testAttrName.equals(string)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:30,代码来源:AbstractXmlDifferenceListener.java

示例3: isCausedByIgnorableAttributeValue

/**
 * Server renderer removes all attributes with no values, client renderer doesn't always do this -> 
 * ignore missing attributes if they don't have a value.
 * Also ignores missing transform attributes, when editor generates a "transform='translate(0)'"
 * @param difference
 * @return
 */
protected boolean isCausedByIgnorableAttributeValue(Difference difference) {
	if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID) {
		//name is the same for both
		NodeDetail detail = difference.getControlNodeDetail();
		XmlDiffDocumentType type;
		if (detail.getValue() == null || detail.getValue().equals(ATTR_NULL)) {
			type = XmlDiffDocumentType.TEST;
			detail = difference.getTestNodeDetail();
		} else {
			type = XmlDiffDocumentType.CONTROL;
			detail = difference.getControlNodeDetail();
		}
		
		String attrName = detail.getValue();
		if (attrName != null) {
			attrName = helper.addNamespacePrefixToAttribute(attrName, detail.getNode());
			Node attrNode = detail.getNode().getAttributes().getNamedItem(attrName);
			String attrValue = (attrNode == null)? null : attrNode.getNodeValue();
			if (canAttributeBeIgnored(attrName, attrValue)) {
				Node node = helper.getDocumentNode(difference, type, false);
                   getAttributeSetForNode(node, ignoredAttributesMap).add(
                           attrName);
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:35,代码来源:AbstractXmlDifferenceListener.java

示例4: differenceFound

@Override
public int differenceFound(Difference difference) {
  switch (difference.getId()) {
    case DifferenceConstants.NAMESPACE_URI_ID:
      return namespaceDifferenceFound(difference);
    case DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID:
    case DifferenceConstants.ATTR_NAME_NOT_FOUND_ID:
      return attributeDifferenceFound(difference);
    default:
      return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
  }
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:12,代码来源:CustomDifferenceListener.java

示例5: isCausedByAttribute

protected boolean isCausedByAttribute(Difference difference, boolean isOptional) {
		if (difference.getId() != DifferenceConstants.ATTR_NAME_NOT_FOUND_ID
				&& difference.getId() != DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID
				&& difference.getId() != DifferenceConstants.HAS_CHILD_NODES_ID
				&& difference.getId() != DifferenceConstants.ATTR_VALUE_ID) {
			return false;
		}

		// get the nodes that are different
		// don't use 'difference.getControlNodeDetail().getNode()' because it
		// returns a node that is not even equal to ones returned by the xPath
		// parser
		Set<String> attributeSet;
		Node node;
		for (XmlDiffDocumentType type : XmlDiffDocumentType.values()) {// test whether one of
															// the document
															// nodes contains an
															// ignored attribute
			// optional attributes must have same value, if they are set
			if (!isOptional && difference.getId() == DifferenceConstants.ATTR_VALUE_ID) {
				// xpath originally points to the actual attribute node ->
				// remove attribute reference from xpath
				node = helper.getDocumentNode(difference, type, true);
				if (node != null){
//					String attributeName = difference.getControlNodeDetail().getNode().getNodeName();
					String attributeName = XPathUtil.getAttributeNameFromXPath(difference.getControlNodeDetail().getXpathLocation());
                    if (getAttributeSetForNode(node, ignoredAttributesMap)
                            .contains(attributeName)) {
						return true;
					}
				}
			}
			node = helper.getDocumentNode(difference, type, false);
			if (node == null) {
				continue;
			}

			if (isOptional) {
                attributeSet = getAttributeSetForNode(node,
                        optionalAttributesMap);
			} else {
                attributeSet = getAttributeSetForNode(node,
                        ignoredAttributesMap);
			}

			switch (difference.getId()) {
			case DifferenceConstants.ATTR_NAME_NOT_FOUND_ID:
				String attrName = difference.getControlNodeDetail().getValue();
				if (attrName == null || attrName.equals(ATTR_NULL)){
					attrName = difference.getTestNodeDetail().getValue();
					attrName = helper.addNamespacePrefixToAttribute(attrName, difference.getTestNodeDetail().getNode());
				}else{
					attrName = helper.addNamespacePrefixToAttribute(attrName, difference.getControlNodeDetail().getNode());
				}
				if (attributeSet.contains(attrName)) {
					return true;
				}
				break;
			case DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID:
			case DifferenceConstants.HAS_CHILD_NODES_ID:
				if (attributeSet.size() > 0) {
					return true;
				}
				if (containsAttributesOfIgnoredNamespaces(node)) {
					return true;
				}
				if (containsIgnorableAttributeValues(node)) {
					return true;
				}
				break;
			}
		}
		return false;
	}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:74,代码来源:AbstractXmlDifferenceListener.java


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