mbeckerle commented on a change in pull request #86: Adding value of 'bcd' to
binaryCalendarRep
URL: https://github.com/apache/incubator-daffodil/pull/86#discussion_r205828028
##########
File path:
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedBinaryUnparserTraits.scala
##########
@@ -45,7 +46,16 @@ abstract class PackedBinaryBaseUnparser(
override def unparse(state: UState): Unit = {
val nBits = getBitLength(state)
val node = state.currentInfosetNode.asSimple
- val value = node.dataValue.asInstanceOf[JNumber]
+
+ // If this is unparsing a binary calendar use node.dataValueAsString and
create a JBigDecimal
+ // so it can be cast to a JNumber below.
+ val nodeValue =
+ node.erd.optPrimType.get match {
+ case _: NodeInfo.Date.Kind | _: NodeInfo.DateTime.Kind | _:
NodeInfo.Time.Kind => new JBigDecimal(node.dataValueAsString)
Review comment:
The _: is selecting the prim type by it's type. The NodeInfo stuff is
perhaps absurdly flexible, in that you can also use selection by object as in
case NodeInfo.Date | NodeInfo.DateTime | ...
That is to say, if you remove the "_:" you also have to drop the ".Kind".
The time to use the "_:" and ".Kind" type selection is when you want a class
and all its subclasses, so like NodeInfo.Numeric.Kind to select any numeric
primtype.
----------------------------------------------------------------
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