net.sf.xmlmatcher.strategy
Class FloatingNumbersMatchingStrategy
java.lang.Object
net.sf.xmlmatcher.strategy.TextValueMatchingStrategy
net.sf.xmlmatcher.strategy.FloatingNumbersMatchingStrategy
- All Implemented Interfaces:
- MatchingStrategy
- Direct Known Subclasses:
- AngleMatchingStrategy
public class FloatingNumbersMatchingStrategy
- extends TextValueMatchingStrategy
Compares double values specified by two elements.
Comparison uses tolerance specified as template attribute or from global allowence table.
Method Summary |
protected static double |
getAttributeValueAsDouble(org.w3c.dom.Element template,
java.lang.String attributeName)
|
protected static double |
getAttributeValueAsDouble(org.w3c.dom.Element template,
java.lang.String attributeName,
double defaultValue)
|
protected static double |
getTolerance(org.w3c.dom.Element template)
|
protected void |
matchTextContent(org.w3c.dom.Element template,
org.w3c.dom.Element actual,
java.lang.String templateValue,
java.lang.String actualValue,
Matcher matcher)
|
boolean |
select(org.w3c.dom.Element template,
boolean hasChildren)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TOLERANCE_ATTR
public static final java.lang.String TOLERANCE_ATTR
- See Also:
- Constant Field Values
FloatingNumbersMatchingStrategy
public FloatingNumbersMatchingStrategy()
select
public boolean select(org.w3c.dom.Element template,
boolean hasChildren)
throws InvalidTemplateException
- Parameters:
template
- template Element to comparehasChildren
- true if given template element has children elements
- Returns:
- true if this strategy can handle comparison of given template to some actual element
- Throws:
InvalidTemplateException
matchTextContent
protected void matchTextContent(org.w3c.dom.Element template,
org.w3c.dom.Element actual,
java.lang.String templateValue,
java.lang.String actualValue,
Matcher matcher)
throws XMLMismatchException,
InvalidTemplateException
- Specified by:
matchTextContent
in class TextValueMatchingStrategy
templateValue
- non-nullable StringactualValue
- non-nullable String
- Throws:
XMLMismatchException
InvalidTemplateException
getTolerance
protected static double getTolerance(org.w3c.dom.Element template)
throws InvalidTemplateException
- Returns:
- tolerance for given template or NaN
- Throws:
InvalidTemplateException
getAttributeValueAsDouble
protected static double getAttributeValueAsDouble(org.w3c.dom.Element template,
java.lang.String attributeName)
throws InvalidTemplateException
- Returns:
- double value of given attribute or Double.NaN
- Throws:
InvalidTemplateException
getAttributeValueAsDouble
protected static double getAttributeValueAsDouble(org.w3c.dom.Element template,
java.lang.String attributeName,
double defaultValue)
throws InvalidTemplateException
- Returns:
- double value of given attribute or default value
- Throws:
InvalidTemplateException
Copyright © 2007. All Rights Reserved.