mbeckerle commented on a change in pull request #214: Sequences and Separators
Refactoring and Rewrite
URL: https://github.com/apache/incubator-daffodil/pull/214#discussion_r284803213
##########
File path:
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SeparatedSequenceUnparsers.scala
##########
@@ -22,238 +22,453 @@ import org.apache.daffodil.processors.{
ElementRuntimeData, SequenceRuntimeData,
import org.apache.daffodil.schema.annotation.props.SeparatorSuppressionPolicy
import org.apache.daffodil.schema.annotation.props.gen.{ SeparatorPosition }
import org.apache.daffodil.infoset.DIElement
+import org.apache.daffodil.processors.ModelGroupRuntimeData
+import org.apache.daffodil.util.Maybe
+import scala.collection.mutable.Buffer
+import SeparatorSuppressionPolicy._
+import SeparatorPosition._
/**
* DFDL Spec. section 14.2.3 specifies only a few different behaviors
* for separator suppression. Each has an algorithm.
*/
-sealed trait SeparatorSuppressionMode extends Serializable {
-
- /**
- * Determines if we should suppress a zero length element and
- * separator.
- *
- * Checks if the length is zero if necessary to decide.
- *
- * Returns Suppress or IfTrailing when the element is, in fact, zero length,
- * and the algorithm wants those to be suppressed.
- * Returns DoNotSuppress otherwise.
- */
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement):
SeparatorSuppressionAction
-
- def shouldDoExtraSeparators = false
-
- def checkArrayPosAgainstMaxOccurs(state: UState, maxRepeats: Long): Boolean
= true
-
-}
-
-object SeparatorSuppressionMode {
- type Type = SeparatorSuppressionMode
- import SeparatorSuppressionAction._
-
- object None extends Type {
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement) =
Assert.usageError("not to be called.")
- }
- object FixedOrExpression extends Type {
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement) =
DoNotSuppress
- }
-
- class SuppressAnyEmpty(zeroLengthDetector: ZeroLengthDetector) extends Type {
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement) =
{
- val isZL = zeroLengthDetector.isZeroLength(infosetElement)
- if (isZL) Suppress
- else DoNotSuppress
- }
- }
-
- trait CheckArrayPosMixin { self: SeparatorSuppressionMode =>
- override def checkArrayPosAgainstMaxOccurs(state: UState, maxRepeats:
Long): Boolean = {
- state.arrayPos <= maxRepeats
- }
- }
-
- class ImplicitSuppressAnyEmpty(zeroLengthDetector: ZeroLengthDetector)
- extends SuppressAnyEmpty(zeroLengthDetector)
- with CheckArrayPosMixin
-
- object ImplicitNeverOrNotPotentiallyTrailing extends Type
- with CheckArrayPosMixin {
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement) =
DoNotSuppress
-
- override def shouldDoExtraSeparators = true
-
- }
-
- class ImplicitPotentiallyTrailing(zeroLengthDetector: ZeroLengthDetector)
extends Type
- with CheckArrayPosMixin {
- def shouldSuppressIfZeroLength(state: UState, infosetElement: DIElement) =
{
- val isZL = zeroLengthDetector.isZeroLength(infosetElement)
- if (isZL) IfTrailing
- else DoNotSuppress
- }
- }
-}
-
-sealed trait SeparatorSuppressionAction extends Serializable
-object SeparatorSuppressionAction {
- type Type = SeparatorSuppressionAction
- case object Suppress extends Type
- case object DoNotSuppress extends Type
- case object IfTrailing extends Type
-}
+//sealed trait SeparatorSuppressionMode extends Serializable
Review comment:
delete
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services