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


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement
+  def isNilled: Boolean
+  def isEmpty: Boolean
+  def asSimple: InfosetSimpleElement
+  def asComplex: InfosetComplexElement
+
+  /*
+   * For API users to avoid the need to access RuntimeData
+   */
+  def metadata: ElementMetadata
+  def name = metadata.name
+  def namespace = metadata.namespace

Review Comment:
   These are just about having to change fewer lines in the tests. But I'll see 
how impactful this is. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Metadata.scala:
##########
@@ -0,0 +1,80 @@
+package org.apache.daffodil.runtime1.api
+
+import org.apache.daffodil.lib.exceptions.SchemaFileLocation
+import org.apache.daffodil.lib.xml.NS
+import org.apache.daffodil.lib.xml.NamedQName
+import org.apache.daffodil.runtime1.dpath.PrimTypeNode
+
+/*
+ * This is the supportable API for access to the RuntimeData structures
+ */
+trait Metadata {
+  def schemaFileLocation: SchemaFileLocation

Review Comment:
   We do need this, because say the Apache Drill integration can't handle if 
multiple children of an element have the same name. We need to issue a 
diagnostic and complain about the DFDL schema appropriately. 
   
   SchemaFileLocation is just a little tuple, so the easiest thing is just to 
give access to its members from this class. That way it doesn't shine through 
as an object. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/infoset/JDOMInfosetOutputter.scala:
##########
@@ -46,7 +49,8 @@ class JDOMInfosetOutputter extends InfosetOutputter with 
XMLInfosetOutputter {
     result = Maybe(root.asInstanceOf[org.jdom2.Document])
   }
 
-  def startSimple(diSimple: DISimple): Unit = {
+  override def startSimple(se: InfosetSimpleElement): Unit = {
+    val diSimple = se.asInstanceOf[DISimple]

Review Comment:
   Yes, but, there is some use of internals due to issues with namespace 
binding minimization in the XML outputters. 
   Some complex logic there that I'm not inclined to try to refactor currently. 
   
   I have changed most usage of DINode classes to InfosetFooElements. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Metadata.scala:
##########
@@ -0,0 +1,80 @@
+package org.apache.daffodil.runtime1.api
+
+import org.apache.daffodil.lib.exceptions.SchemaFileLocation
+import org.apache.daffodil.lib.xml.NS
+import org.apache.daffodil.lib.xml.NamedQName
+import org.apache.daffodil.runtime1.dpath.PrimTypeNode
+
+/*
+ * This is the supportable API for access to the RuntimeData structures
+ */
+trait Metadata {
+  def schemaFileLocation: SchemaFileLocation
+  def path: String
+  def diagnosticDebugName: String
+  override def toString = diagnosticDebugName
+}
+
+trait TermMetadata extends Metadata {
+  def isArray: Boolean
+}
+
+trait ElementMetadata extends TermMetadata {
+  def isSimpleType: Boolean
+  def isComplexType: Boolean
+
+  def name: String
+  def namespace: NS
+  def optNamespacePrefix: Option[String]
+  def isArray: Boolean
+  def isOptional: Boolean
+  def namedQName: NamedQName
+
+  def sscd: String
+  def isNillable: Boolean
+
+  def runtimeProperties: java.util.Map[String, String]
+
+}
+
+trait ComplexElementMetadata extends ElementMetadata {
+
+  def childMetadata: Seq[ElementMetadata]
+}
+
+trait SimpleElementMetadata extends ElementMetadata {
+  def primType: PrimTypeNode
+}
+
+trait ModelGroupMetadata extends TermMetadata {}
+
+trait SequenceMetadata extends ModelGroupMetadata {}
+
+trait ChoiceMetadata extends ModelGroupMetadata {}
+
+/**
+ * Base class used by clients who want to walk the runtime schema information.
+ */
+abstract class MetadataHandler() {
+
+  /**
+   * Called for simple type element metadata (for declarations or references)
+   */
+  def simpleElementMetadata(m: SimpleElementMetadata): Unit
+
+  /**
+   * Called for complex type element metadata (for declarations or references)
+   *
+   * Subsequent calls will be for the model group making up the content
+   * of the element.
+   */
+  def startComplexElementMetadata(m: ComplexElementMetadata): Unit
+  def endComplexElementMetadata(m: ComplexElementMetadata): Unit
+
+  //  def startSequenceMetadata(m: SequenceMetadata): Unit

Review Comment:
   Note: Test that these are actually walked and not just parent direct to 
element children. 
   There are use cases for these involving the API user needing some sort of 
NextElementResolver so they can cope with DFDL schemas where not all children 
have unique names. 



##########
daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala:
##########
@@ -401,6 +388,13 @@ class DataProcessor private[japi] (private var dp: 
SDataProcessor)
   extends WithDiagnostics(dp)
   with Serializable {
 
+  /**
+   * For use by the JAPI implementation-internals only.
+   *
+   * @return the underlying data processor
+   */
+  private[japi] def getUnderlyingDataProcessor = dp

Review Comment:
   Remove if unused. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement
+  def isNilled: Boolean
+  def isEmpty: Boolean
+  def asSimple: InfosetSimpleElement
+  def asComplex: InfosetComplexElement
+
+  /*
+   * For API users to avoid the need to access RuntimeData
+   */
+  def metadata: ElementMetadata
+  def name = metadata.name
+  def namespace = metadata.namespace
+}
+
+trait InfosetComplexElement extends InfosetElement {
+  override def metadata: ComplexElementMetadata
+  def getChildElement(childMetadata: ElementMetadata): InfosetElement
+  def getChildArray(childMetadata: ElementMetadata): InfosetArray
+  def getChild(childMetadata: ElementMetadata): InfosetItem
+}
+
+trait InfosetSimpleElement extends InfosetElement {
+
+  override def metadata: SimpleElementMetadata
+
+  /**
+   * Caches the string so we're not allocating strings repeatedly
+   */
+  def dataValueAsString: String
+
+  /*
+   * These are so that API users don't have to know about our
+   * very Scala-oriented DataValue type system.
+   */
+  def getAnyRef: AnyRef
+  def getBigDecimal: JBigDecimal
+  def getCalendar: DFDLCalendar
+  def getDate: DFDLDate
+  def getTime: DFDLTime
+  def getDateTime: DFDLDateTime

Review Comment:
   I think they are just encapsulations around java types for some 
serialization related reason. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement

Review Comment:
   You points on this and access to children are well taken. For metadata, 
walking that stuff is fine. For data, we don't want people crawling the infoset 
themselves. 
   
   If these are needed by tests I'll  make them package private. If not then 
I'll remove them. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement
+  def isNilled: Boolean
+  def isEmpty: Boolean
+  def asSimple: InfosetSimpleElement
+  def asComplex: InfosetComplexElement
+
+  /*
+   * For API users to avoid the need to access RuntimeData
+   */
+  def metadata: ElementMetadata
+  def name = metadata.name
+  def namespace = metadata.namespace
+}
+
+trait InfosetComplexElement extends InfosetElement {
+  override def metadata: ComplexElementMetadata
+  def getChildElement(childMetadata: ElementMetadata): InfosetElement
+  def getChildArray(childMetadata: ElementMetadata): InfosetArray
+  def getChild(childMetadata: ElementMetadata): InfosetItem
+}
+
+trait InfosetSimpleElement extends InfosetElement {
+
+  override def metadata: SimpleElementMetadata
+
+  /**
+   * Caches the string so we're not allocating strings repeatedly
+   */
+  def dataValueAsString: String
+
+  /*
+   * These are so that API users don't have to know about our
+   * very Scala-oriented DataValue type system.
+   */
+  def getAnyRef: AnyRef

Review Comment:
   Actually, in the Drill changes I've done getAnyRef is the only thing I've 
called in these. Turns out I need an object, not a primitive value, to give it 
to Drill. Calling getAnyRef is easier since the assignment to the field takes 
an object ref.
   
   I'd almost suggest we leave out all the typed getters and ONLY have 
getAnyRef. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Metadata.scala:
##########
@@ -0,0 +1,80 @@
+package org.apache.daffodil.runtime1.api
+
+import org.apache.daffodil.lib.exceptions.SchemaFileLocation
+import org.apache.daffodil.lib.xml.NS
+import org.apache.daffodil.lib.xml.NamedQName
+import org.apache.daffodil.runtime1.dpath.PrimTypeNode
+
+/*
+ * This is the supportable API for access to the RuntimeData structures
+ */
+trait Metadata {
+  def schemaFileLocation: SchemaFileLocation
+  def path: String
+  def diagnosticDebugName: String
+  override def toString = diagnosticDebugName
+}
+
+trait TermMetadata extends Metadata {
+  def isArray: Boolean
+}
+
+trait ElementMetadata extends TermMetadata {
+  def isSimpleType: Boolean
+  def isComplexType: Boolean
+
+  def name: String
+  def namespace: NS
+  def optNamespacePrefix: Option[String]
+  def isArray: Boolean
+  def isOptional: Boolean
+  def namedQName: NamedQName
+
+  def sscd: String

Review Comment:
   Unused, so I'll pull it. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement
+  def isNilled: Boolean
+  def isEmpty: Boolean
+  def asSimple: InfosetSimpleElement
+  def asComplex: InfosetComplexElement

Review Comment:
   These are for tests to make them more compact. Removing. They are seldom 
used. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Infoset.scala:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.api
+
+import java.lang.{ Boolean => JBoolean }
+import java.lang.{ Byte => JByte }
+import java.lang.{ Double => JDouble }
+import java.lang.{ Float => JFloat }
+import java.lang.{ Integer => JInt }
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+import java.lang.{ Short => JShort }
+import java.lang.{ String => JString }
+import java.math.{ BigDecimal => JBigDecimal }
+import java.math.{ BigInteger => JBigInt }
+import java.net.URI
+
+import org.apache.daffodil.lib.calendar.DFDLCalendar
+import org.apache.daffodil.lib.calendar.DFDLDate
+import org.apache.daffodil.lib.calendar.DFDLDateTime
+import org.apache.daffodil.lib.calendar.DFDLTime
+
+/**
+ * API access to array objects in the DFDL Infoset
+ */
+trait InfosetArray extends InfosetItem {
+  override def metadata: ElementMetadata // the element that is an array
+  def getOccurrence(occursIndex: Long): InfosetElement
+  def length: Long
+  final def apply(occursIndex: Long): InfosetElement = 
getOccurrence(occursIndex)
+  final def apply(occursIndex: Int) : InfosetElement = 
getOccurrence(occursIndex.toLong)
+}
+
+/**
+ * API access to elements of the DFDL Infoset
+ */
+trait InfosetElement extends InfosetItem {
+  def parent: InfosetComplexElement
+  def isNilled: Boolean
+  def isEmpty: Boolean

Review Comment:
   empty string or empty hexBinary. Will add the scaladoc. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/infoset/XMLInfosetOutputterMixin.scala:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime1.infoset
+
+import org.apache.daffodil.lib.equality._
+import org.apache.daffodil.lib.util.Maybe
+import org.apache.daffodil.lib.xml.XMLUtils
+
+trait XMLInfosetOutputterMixin {
+
+  def remapped(dataValueAsString: String) =
+    XMLUtils.remapXMLIllegalCharactersToPUA(dataValueAsString)
+
+  /**
+   * String suitable for use in the text of a Processing Instruction.
+   *
+   * The text is a pseudo-XML string.
+   */
+  protected final def fmtInfo(diTerm: DITerm): Maybe[String] = {

Review Comment:
   Dropped. It was unused. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala:
##########
@@ -1079,27 +1101,27 @@ sealed trait DIElement
   protected final var _isHidden = false
   final def isHidden: Boolean = _isHidden
 
-  override def setHidden(): Unit = {
+  def setHidden(): Unit = {
     _isHidden = true
   }
 
   final def runtimeData = erd
-  protected final var _parent: InfosetComplexElement = null
+  protected final var _parent: DIComplex = null

Review Comment:
   So one thing this change to expose the InfosetItem means.... users can just 
downcast and they have the DINode objects again. 
   
   The proxy way of isolating an API is superior in that one can't even get a 
pointer to the interior object, so you can't bypass the API. 
   
   On the other hand, the jars are all linkable, and so people who bypass the 
API can easily just get at whatever they want. Furthermore it's all open 
source..... 
   
   A way of avoiding exposing the InfosetNode traits/classes at all is to make 
the walkers work more like a cursor. 
   I.e., startComplex() and other event-handler methods don't get passed 
anything. Just the methods that access the data and metadata fields are all on 
the handler (in this case the InfosetOutputter) and can be called to access the 
underlying info for the current object the handler is positioned on. 
   
   But I don't want to do that simply because it's yet more proxy-style 
duplication of API. It's also unexpected stylistically I think. 
   
   
   



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/Metadata.scala:
##########
@@ -0,0 +1,80 @@
+package org.apache.daffodil.runtime1.api
+
+import org.apache.daffodil.lib.exceptions.SchemaFileLocation
+import org.apache.daffodil.lib.xml.NS
+import org.apache.daffodil.lib.xml.NamedQName
+import org.apache.daffodil.runtime1.dpath.PrimTypeNode
+
+/*
+ * This is the supportable API for access to the RuntimeData structures
+ */
+trait Metadata {
+  def schemaFileLocation: SchemaFileLocation
+  def path: String
+  def diagnosticDebugName: String
+  override def toString = diagnosticDebugName
+}
+
+trait TermMetadata extends Metadata {
+  def isArray: Boolean
+}
+
+trait ElementMetadata extends TermMetadata {
+  def isSimpleType: Boolean
+  def isComplexType: Boolean
+
+  def name: String
+  def namespace: NS
+  def optNamespacePrefix: Option[String]
+  def isArray: Boolean
+  def isOptional: Boolean
+  def namedQName: NamedQName
+
+  def sscd: String
+  def isNillable: Boolean
+
+  def runtimeProperties: java.util.Map[String, String]
+
+}
+
+trait ComplexElementMetadata extends ElementMetadata {
+
+  def childMetadata: Seq[ElementMetadata]

Review Comment:
   Actually, the whole metadata structure is static, so there is no risk to 
this. I do have need of it in the Apache Drill integration in one place where 
we want to know if the docRoot has exactly 1 complex repeating child element, 
and if so we treat the docRoot differently. 



##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala:
##########
@@ -1558,6 +1590,29 @@ sealed class DISimple(override val erd: 
ElementRuntimeData)
     Assert.invariantFailed("Should not try to remove a child of a simple type")
   }
 
+  // call to getAnyRef here seems redundant
+  // but tests fail that compare objects if this call isn't here
+  // Boxing/Unboxing related perhaps
+  @inline private def v = dataValue.getAnyRef
+
+  override def getAnyRef: AnyRef = v.asInstanceOf[AnyRef]
+  override def getBigDecimal: JBigDecimal = v.asInstanceOf[JBigDecimal]
+  override def getCalendar: DFDLCalendar = v.asInstanceOf[DFDLCalendar]
+  override def getDate: DFDLDate = v.asInstanceOf[DFDLDate]
+  override def getTime: DFDLTime = v.asInstanceOf[DFDLTime]
+  override def getDateTime: DFDLDateTime = v.asInstanceOf[DFDLDateTime]
+  override def getByteArray: Array[Byte] = v.asInstanceOf[Array[Byte]]
+  override def getBoolean: JBoolean = v.asInstanceOf[JBoolean]
+  override def getNumber: JNumber = v.asInstanceOf[JNumber]
+  override def getByte: JByte = v.asInstanceOf[JByte]
+  override def getShort: JShort = v.asInstanceOf[JShort]
+  override def getInt: JInt = v.asInstanceOf[JInt]
+  override def getLong: JLong = v.asInstanceOf[JLong]
+  override def getDouble: JDouble = v.asInstanceOf[JDouble]
+  override def getFloat: JFloat = v.asInstanceOf[JFloat]
+  override def getBigInt: JBigInt = v.asInstanceOf[JBigInt]
+  override def getString: JString = v.asInstanceOf[JString]
+  override def getURI: URI = v.asInstanceOf[URI]

Review Comment:
   I tried to do it that way, but invoking these from Java was having trouble. 
I'll put one back and see what happens though, and document why it has to be 
done this way (if that holds). 



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