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_r203352970
 
 

 ##########
 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
+    }
+
+    p.toSeq.foreach(char =>
+      if (!validFormatCharacters.contains(char)) {
+        SDE("Character '%s' not allowed in dfdl:calendarPattern for xs:%s with 
a binaryCalendarRep of '%s'".format(char, xsdType, e.binaryCalendarRep))
+      })
+
+    if (p.indexOf("S" * (TextCalendarConstants.maxFractionalSeconds + 1)) >= 
0) {
+      SDE("More than %d fractional seconds unsupported in dfdl:calendarPattern 
for xs:%s".format(TextCalendarConstants.maxFractionalSeconds, xsdType))
+    }
+
+    p
+  }
 
 Review comment:
   I think this is exactly the same as what is in 
BinaryPackedDecimalCalendarPrimBase. Can this class just extend that, or can 
the shared stuff be pulled out into a trait?

----------------------------------------------------------------
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

Reply via email to