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


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala:
##########
@@ -407,7 +416,32 @@ final class SimpleTypeRuntimeData(
     // Note: dont check occurs counts // if(!checkMinMaxOccurs(e, 
pstate.arrayIterationPos)) { return java.lang.Boolean.FALSE }
     OK
   }
+  private def checkLength(
+    diNode: DISimple,
+    lenValue: java.math.BigDecimal,
+    e: ThrowsSDE,
+    primType: PrimType,
+  ): java.lang.Boolean = {
+    val lenAsLong = lenValue.longValueExact()
+    primType match {
+      case PrimType.String => {
+        val data = diNode.dataValue.getString
+        val dataLen = data.length.toLong
+        val isDataLengthEqual = dataLen.compareTo(lenAsLong) == 0
+        if (isDataLengthEqual) java.lang.Boolean.TRUE
+        else java.lang.Boolean.FALSE
+      }
+      case PrimType.HexBinary => {
+        val data = diNode.dataValue.getByteArray
 
+        val dataLen = data.length.toLong
+        val isDataLengthEqual = dataLen.compareTo(lenAsLong) == 0

Review Comment:
   For hexBinary, it's definitely number of bytes, not number of characters. 
   
   For strings,...it's supposed to be characters, but a little DFDL tricky 
thing is that if dfdl:lengthKind is 'implicit' then the length is in 
characters, but the charset must be SBCS (single-byte character set) when 
dfdl:lengthUnits='bytes' so that the maxLength facet, which is used to obtain 
the length, will be correct for either bytes or characters. Otherwise DFDL's 
interpretation of the maxLength value could be inconsistent with XSDs 
interpretation. 
   



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