mbeckerle commented on a change in pull request #83: Adding value of 'bcd' to
binaryCalendarRep
URL: https://github.com/apache/incubator-daffodil/pull/83#discussion_r203422914
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala
##########
@@ -207,3 +230,94 @@ case class ConvertBinaryCalendarSecMilliParser(
start.simpleElement.overwriteDataValue(newCal)
}
}
+
+abstract class BinaryCalendarBCDParser(
+ override val context: ElementRuntimeData,
+ hasTZ: Boolean,
+ pattern: String,
+ localeEv: CalendarLanguageEv,
+ calendarEv: CalendarEv,
+ xsdType: String,
+ prettyType: String)
+ extends CalendarParser {
+
+ def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal =
DecimalUtils.bcdToBigDecimal(num, scale)
+
+ def getBitLength(start: ParseOrUnparseState): Int
+
+ def parse(start: PState): Unit = {
+
+ val dis = start.dataInputStream
+ val nBits = getBitLength(start)
+ if (nBits == 0) return // zero length is used for outputValueCalc often.
+
+ if (!dis.isDefinedForLength(nBits)) {
+ PE(start, "Insufficient bits in data. Needed %d bit(s) but found only %d
available.", nBits, dis.remainingBits.get)
+ return
+ }
+
+ try {
+ // Use '0' for the binaryDecimalVirtualPoint because its location will
be implied by the pattern
Review comment:
Hmmm. dfdl:binaryDecimalVirtualPoint doesn't apply to date/time/dateTime at
all. So it should be ignored.
The only concept like a decimal point in date/time/datetime is the
seconds/fractional seconds boundary, and this would be expressed via "ssSSS"
i.e, the pattern explicitly give whole seconds and fractional seconds with
different characters.
----------------------------------------------------------------
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