jadams-tresys commented on a change in pull request #173: Allow implicit
conversion of string to HexBinary
URL: https://github.com/apache/incubator-daffodil/pull/173#discussion_r251820038
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/ConverterOps2.scala
##########
@@ -78,3 +78,15 @@ case object StringToTime extends Converter {
result
}
}
+
+case object StringToHexBinary extends Converter with HexBinaryKind{
+ val name = "StringToHexBinary"
+
+ override def computeValue(a: AnyRef, dstate: DState): AnyRef = {
+ val result = a match {
+ case s: String => hexStringToByteArray(s)
+ case x => throw new NumberFormatException("%s cannot be cast to
dfdl:hexBinary\ndfdl:hexBinary received an unrecognized type! Must be String or
HexBinary.".format(x.toString))
+ }
+ result
+ }
+}
Review comment:
I've made the change and it should be pushed up now.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services