efinnegan commented on a change in pull request #83: Adding value of 'bcd' to 
binaryCalendarRep
URL: https://github.com/apache/incubator-daffodil/pull/83#discussion_r203422531
 
 

 ##########
 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 was having trouble combining this code because I have BCDDelimitedLength 
extending the class StringDelimited, so it can't also extend 
BinaryPackedDecimalCalendarPrimBase. But then when I put it into a trait it 
couldn't extend the Terminal to use the SDE function. But I see that I can just 
call that separately as e.SDE(...) so I will change it to use a trait and call 
SDE that way. 

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