def zonedFromNumber()

in daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/DecimalUtils.scala [572:616]


  def zonedFromNumber(
    num: String,
    optZonedStyle: Option[TextZonedSignStyle],
    opl: OverpunchLocation.Value
  ): String = {
    val positive = (num.charAt(0) != '-')
    val inStr = positive match {
      case true => num
      case false => num.substring(1)
    }
    val opindex = opl match {
      case OverpunchLocation.Start => 0
      case OverpunchLocation.End => inStr.length - 1
      case _ => -1
    }

    val encodedValue = {
      if (opl == OverpunchLocation.None) {
        if (!positive) Assert.impossible()
        inStr
      } else {
        val digit = optZonedStyle match {
          case None => convertToZonedEBCDIC(inStr(opindex), positive)
          case Some(TextZonedSignStyle.AsciiStandard) =>
            convertToAsciiStandard(inStr(opindex), positive)
          case Some(TextZonedSignStyle.AsciiTranslatedEBCDIC) =>
            convertToAsciiTranslatedEBCDIC(inStr(opindex), positive)
          case Some(TextZonedSignStyle.AsciiCARealiaModified) =>
            convertToAsciiCARealiaModified(inStr(opindex), positive)
          case Some(TextZonedSignStyle.AsciiTandemModified) =>
            convertToAsciiTandemModified(inStr(opindex), positive)
        }

        val convertedNum = opl match {
          case OverpunchLocation.Start => digit +: inStr.substring(1)
          case OverpunchLocation.End => inStr.substring(0, opindex) + digit
          case _ => Assert.impossible()
        }

        convertedNum
      }
    }

    encodedValue
  }