stevedlawrence commented on a change in pull request #83: Adding value of 'bcd'
to binaryCalendarRep
URL: https://github.com/apache/incubator-daffodil/pull/83#discussion_r203367585
##########
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:
I don't think i understand this comment. As I understand it, the calendar
pattern can only have numeric values so it would never match anything if a
decimal point were added. Is that correct? If that's the case, maybe we should
change toBigDeicmal to toBigInteger and modify that function to use
bcdToBigInteger?
----------------------------------------------------------------
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