mbeckerle commented on code in PR #1248:
URL: https://github.com/apache/daffodil/pull/1248#discussion_r1620823622
##########
daffodil-runtime1-layers/src/main/scala/org/apache/daffodil/layers/runtime1/ByteSwapLayer.scala:
##########
@@ -29,18 +30,47 @@ final class TwoByteSwapLayer extends
ByteSwap("twobyteswap", 2)
final class FourByteSwapLayer extends ByteSwap("fourbyteswap", 4)
-abstract class ByteSwap(name: String, count: Int)
+/**
+ * This class represents a byte swap layer that can be used to swap the byte
order of data.
+ *
+ * DFDL Variable `requireLengthInWholeWords` can be used to request that the
layer enforce
+ * the length being a multiple of the word size.
+ *
+ * @constructor Creates a new ByteSwap instance with the specified name and
word size.
+ * @param name The name of the byte swap layer.
+ * @param wordsize The word size in bytes.
+ */
+abstract class ByteSwap(name: String, wordsize: Int)
extends Layer(name, "urn:org.apache.daffodil.layers.byteSwap") {
+ private var wholeWords: Boolean = false
+
+ /**
+ * Initialize from DFDL variables that are parameters.
+ * @param requireLengthInWholeWords a string that is the value of the DFDL
variable of the same name in this layer's
+ * namespace. Must be "yes" or "no" or it
is a SDE.
+ */
+ def setLayerVariableParameters(requireLengthInWholeWords: String): Unit = {
+ requireLengthInWholeWords match {
+ case "yes" => this.wholeWords = true
+ case "no" => this.wholeWords = false // this is the default
Review Comment:
I made it a string with yes/no for this extensibility reason. I think that's
sufficient.
--
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]