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_r203352300
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesDateTime.scala
##########
@@ -243,3 +275,155 @@ case class ConvertBinaryDateTimeSecMilliPrim(e:
ElementBase, lengthInBits: Long)
lengthInBits.toInt,
!epochCalendar.getTimeZone.equals(TimeZone.UNKNOWN_ZONE))
}
+
+abstract class BCDRuntimeLength(e: ElementBase) extends
BinaryPackedDecimalCalendarPrimBase(e, true) {
+
+ override lazy val parser = new BinaryCalendarBCDRuntimeLengthParser(
+ e.elementRuntimeData,
+ false,
+ pattern,
+ localeEv,
+ calendarEv,
+ xsdType,
+ prettyType,
+ e.lengthEv,
+ e.lengthUnits)
+
+ override lazy val unparser =
+ new BinaryCalendarBCDRuntimeLengthUnparser(
+ e.elementRuntimeData,
+ pattern,
+ localeEv,
+ calendarEv,
+ e.lengthEv,
+ e.lengthUnits)
+}
+
+abstract class BCDKnownLength(e: ElementBase, lengthInBits: Long) extends
BinaryPackedDecimalCalendarPrimBase(e, true) {
+
+ override lazy val parser = new BinaryCalendarBCDKnownLengthParser(
+ e.elementRuntimeData,
+ false,
+ lengthInBits.toInt,
+ pattern,
+ localeEv,
+ calendarEv,
+ xsdType,
+ prettyType)
+
+ override lazy val unparser =
+ new BinaryCalendarBCDKnownLengthUnparser(
+ e.elementRuntimeData,
+ lengthInBits.toInt,
+ pattern,
+ localeEv,
+ calendarEv)
+}
+
+abstract class BCDDelimitedLength(e: ElementBase, xsdType: String, prettyType:
String)
+ extends StringDelimited(e)
+ with CalendarPrimBase {
+
+ lazy val pattern: String = {
+ val p = e.calendarPatternKind match {
+ case CalendarPatternKind.Explicit => e.calendarPattern
+ case _ => Assert.impossibleCase
+ }
Review comment:
I agree that it's impossible for calendarPatternKind to not be explicit, I'm
not sure this check gains much here. I think it's fine to just do ``val p =
e.calendarPattern``. If you really want an assert check, maybe do it separately
as an invariant, e.g. ``Assert.invariant(e.calendarPatternKind ==
CalendarPatternKind.Explicit)``. Just makes the code a little easier to follow.
----------------------------------------------------------------
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