override def runtimeDependencies = Vector()

in daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/ChoiceAndOtherVariousUnparsers.scala [84:139]


  override def runtimeDependencies = Vector()

  override def childProcessors = choiceBranchMap.childProcessors

  def unparse(state: UState): Unit = {
    if (state.withinHiddenNest) {
      val branchForUnparseIfHidden = choiceBranchMap.defaultUnparser
      branchForUnparseIfHidden.get.unparse1(state)
    } else {
      state.pushTRD(mgrd)
      val event: InfosetAccessor = state.inspectOrError
      val key: ChoiceBranchEvent = event match {
        //
        // The ChoiceBranchStartEvent(...) is not a case class constructor. It is a
        // hash-table lookup for a cached value. This avoids constructing these
        // objects over and over again.
        //
        case e if e.isStart && e.isElement => ChoiceBranchStartEvent(e.erd.namedQName)
        case e if e.isEnd && e.isElement => ChoiceBranchEndEvent(e.erd.namedQName)
        case e if e.isStart && e.isArray => ChoiceBranchStartEvent(e.erd.namedQName)
        case e if e.isEnd && e.isArray => ChoiceBranchEndEvent(e.erd.namedQName)
      }

      val maybeChildUnparser = choiceBranchMap.get(key)
      if (maybeChildUnparser.isEmpty) {
        UnparseError(
          One(mgrd.schemaFileLocation),
          One(state.currentLocation),
          "Found next element %s, but expected one of %s.",
          key.qname.toExtendedSyntax,
          choiceBranchMap.keys
            .map {
              _.qname.toExtendedSyntax
            }
            .mkString(", ")
        )
      }
      val childUnparser = maybeChildUnparser.get
      state.popTRD(mgrd)
      state.pushTRD(childUnparser.context.asInstanceOf[TermRuntimeData])
      if (choiceLengthInBits.isDefined) {
        val suspendableOp =
          new ChoiceUnusedUnparserSuspendableOperation(mgrd, choiceLengthInBits.get)
        val choiceUnusedUnparser =
          new ChoiceUnusedUnparser(mgrd, choiceLengthInBits.get, suspendableOp)

        suspendableOp.captureDOSStartForChoiceUnused(state)
        childUnparser.unparse1(state)
        suspendableOp.captureDOSEndForChoiceUnused(state)
        choiceUnusedUnparser.unparse(state)
      } else {
        childUnparser.unparse1(state)
      }
      state.popTRD(childUnparser.context.asInstanceOf[TermRuntimeData])
    }
  }