You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by GitBox <gi...@apache.org> on 2019/06/19 22:48:16 UTC
[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull
request #240: Add dfdlx:choiceBranchKeyRanges
mbeckerle commented on a change in pull request #240: Add dfdlx:choiceBranchKeyRanges
URL: https://github.com/apache/incubator-daffodil/pull/240#discussion_r295548536
##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/cookers/Cookers.scala
##########
@@ -84,3 +89,28 @@ object ChoiceBranchKeyCooker extends ListOfStringLiteralNonEmptyNoCharClassEntit
object RepValueCooker extends ListOfStringLiteralNonEmptyNoCharClassEntitiesNoByteEntities()
object UpperCaseTokenCooker extends UpperCaseToken
+
+object IntRangeCooker extends Converter[String, Seq[Range[BigInt]]] {
+ protected def convert(input: String, context: ThrowsSDE, forUnparse: Boolean): Seq[Range[BigInt]] = {
+ def run(xs: Seq[String]): Seq[(RangeBound[BigInt], RangeBound[BigInt])] = {
+ xs match {
+ case Seq() => Seq()
+ case a +: b +: rest => {
+ val a2 = BigInt(a)
+ val b2 = BigInt(b)
+ if (a2.compare(b2) > 0) {
+ context.SDE("min value must not be greater than max value")
Review comment:
I think you should display the specific min and max values in this message. If someone typos and deletes a number from middle of a whitespace separated list of ranges, then this could be a little hard to isolate if there's lots of pairs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services