mbeckerle commented on code in PR #1165:
URL: https://github.com/apache/daffodil/pull/1165#discussion_r1503367977


##########
daffodil-runtime1-layers/src/main/scala/org/apache/daffodil/layers/runtime1/LineFoldedTransformer.scala:
##########
@@ -75,157 +73,62 @@ import 
org.apache.daffodil.runtime1.processors.ParseOrUnparseState
  * For MIME, the maximum line length is 76.
  */
 
-sealed abstract class LineFoldedLayerCompiler(mode: LineFoldMode)
-  extends LayerCompiler(mode.transformName) {
-
-  override def compileLayer(
-    layerCompileInfo: LayerCompileInfo,
-  ): LineFoldedTransformerFactory = {
-
-    layerCompileInfo.optLayerLengthKind match {
-      case Some(LayerLengthKind.BoundaryMark) =>
-        layerCompileInfo.SDEUnless(
-          layerCompileInfo.optLayerBoundaryMarkOptConstantValue.isDefined,
-          "Property dfdlx:layerBoundaryMark was not defined.",
-        )
-      case Some(LayerLengthKind.Implicit) => // ok
-      case Some(other) =>
-        layerCompileInfo.SDE(
-          s"Property dfdlx:layerLengthKind can only be 'implicit' or 
'boundaryMark', but was '$other'.",
-        )
-      case None =>
-        layerCompileInfo.SDE(
-          s"Property dfdlx:layerLengthKind must be 'implicit' or 
'boundaryMark'.",
-        )
+sealed abstract class LineFoldedLayerBase(mode: LineFoldMode)
+  extends Layer(
+    layerName = mode.dfdlName,
+    supportedLayerLengthKinds =
+      Seq(JLayerLengthKind.BoundaryMark, JLayerLengthKind.Implicit).asJava,
+    supportedLayerLengthUnits = Seq().asJava,
+    isRequiredLayerEncoding = false,
+    optLayerVariables = Optional.empty(),
+  ) {
+
+  /**
+   * The layer limiter needs to be different for boundaryMark and implicit 
cases.
+   *  @return a LayerLimiter or Optional.empty to indicate the standard layer 
limiter implementation should be used.
+   */
+  override def layerLimiter(layerPropertyInfo: LayerPropertyInfo): 
Optional[LayerLimiter] =
+    layerPropertyInfo.layerLengthKind() match {
+      case JLayerLengthKind.Implicit =>
+        Optional.empty() // use the default implicit layer length 
implementation.
+      case JLayerLengthKind.BoundaryMark =>
+        Optional.of(new LineFoldedLayerBoundaryMarkLimiter(this))
+      case JLayerLengthKind.Explicit =>
+        Assert.invariantFailed("layerLengthKind 'explicit' not allowed.")
     }

Review Comment:
   I think this is what I'll try next. I think all properties except 
dfdlx:layer go away. Regular DFDL variables provide everything including layer 
length, boundary marks, etc. 



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to