in daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/XMLUtils.scala [1180:1232]
def textIsSame(
dataA: String,
dataB: String,
maybeType: Option[String],
maybeFloatEpsilon: Option[Float],
maybeDoubleEpsilon: Option[Double]
): Boolean = {
maybeFloatEpsilon.foreach { eps => Assert.usage(eps > 0.0) }
maybeDoubleEpsilon.foreach { eps => Assert.usage(eps > 0.0) }
maybeType match {
case Some("xs:hexBinary") => dataA.equalsIgnoreCase(dataB)
case Some("xs:date") => {
val a = DFDLDateConversion.fromXMLString(dataA)
val b = DFDLDateConversion.fromXMLString(dataB)
a == b
}
case Some("xs:time") => {
val a = DFDLTimeConversion.fromXMLString(dataA)
val b = DFDLTimeConversion.fromXMLString(dataB)
a == b
}
case Some("xs:dateTime") => {
val a = DFDLDateTimeConversion.fromXMLString(dataA)
val b = DFDLDateTimeConversion.fromXMLString(dataB)
a == b
}
case Some("xs:double") => {
val a = strToDouble(dataA)
val b = strToDouble(dataB)
if (a.isNaN && b.isNaN) true // two NaNs are not normally considered equal
else {
maybeDoubleEpsilon match {
case None => a == b
case Some(epsilon) => abs(a - b) < epsilon
}
}
}
case Some("xs:float") => {
val a = strToFloat(dataA)
val b = strToFloat(dataB)
if (a.isNaN && b.isNaN) true // two NaNs are not normally considered equal
else {
maybeFloatEpsilon match {
case None => a == b
case Some(epsilon) => abs(a - b) < epsilon
}
}
}
case _ => dataA == dataB
}
}