stevedlawrence commented on code in PR #1532:
URL: https://github.com/apache/daffodil/pull/1532#discussion_r2270653637


##########
daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java:
##########
@@ -36,4 +49,192 @@ private Daffodil() {
   public static org.apache.daffodil.api.Compiler compiler() {
     return org.apache.daffodil.core.compiler.Compiler.apply(true);
   }
+
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as a 
scala.xml.Node
+   *
+   * @return InfosetOutputter
+   */
+  public static ScalaXMLInfosetOutputter newScalaXMLInfosetOutputter() {
+    return new 
org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetOutputter(false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as XML written 
to a java.io.OutputStream
+   * <p>
+   * Output the infoset as XML Text, written to a java.io.OutputStream
+   *
+   * @param os     the java.io.OutputStream to write the XML text to
+   * @param pretty enable or disable pretty printing. Pretty printing will only
+   *               insert indentation and newlines where it will not affect the
+   *               content of the XML.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newXMLTextInfosetOutputter(OutputStream os, 
boolean pretty) {
+    return new XMLTextInfosetOutputter(os, pretty, 
XMLTextEscapeStyle.Standard, false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as XML written 
to a java.io.OutputStream
+   * <p>
+   * Output the infoset as XML Text, written to a java.io.OutputStream
+   *
+   * @param os                 the java.io.OutputStream to write the XML text 
to
+   * @param pretty             enable or disable pretty printing. Pretty 
printing will only
+   *                           insert indentation and newlines where it will 
not affect the
+   *                           content of the XML.
+   * @param xmlTextEscapeStyle determine whether to wrap values of elements of 
type
+   *                           xs:string in CDATA tags in order to preserve
+   *                           whitespace.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newXMLTextInfosetOutputter(OutputStream os, 
boolean pretty, XMLTextEscapeStyle xmlTextEscapeStyle) {
+    return new XMLTextInfosetOutputter(os, pretty, xmlTextEscapeStyle, false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as JSON written 
to a java.io.OutputStream
+   * Output the infoset as json text, written to a java.io.OutputStream
+   *
+   * @param os     the java.io.OutputStream to write the json text to
+   * @param pretty enable or disable pretty printing. Pretty printing will only
+   *               insert indentation and newlines where it will not affect the
+   *               content of the json.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newJsonInfosetOutputter(OutputStream os, 
boolean pretty) {
+    return new JsonInfosetOutputter(os, pretty);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as an 
org.jdom2.Document
+   *
+   * @return InfosetOutputter
+   */
+  public static JDOMInfosetOutputter newJDOMInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.JDOMInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as an 
org.w3c.dom.Document
+   *
+   * @return InfosetOutputter
+   */
+  public static W3CDOMInfosetOutputter newW3CDOMInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.W3CDOMInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetOutputter} that does not build an infoset representation, 
ignoring
+   * all {@link InfosetOutputter} events
+   *
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newNullInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.NullInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as a scala.xml.Node
+   *
+   * @param node the scala.xml.Node infoset
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newScalaXMLInfosetInputter(scala.xml.Node 
node) {
+    return new 
org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetInputter(node);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as XML from a 
java.io.InputStream
+   * <p>
+   * Read in an infoset in the form of XML text from a java.io.InputStream
+   *
+   * @param is the java.io.InputStream to read the XML text from
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newXMLTextInfosetInputter(InputStream is) {
+    return new org.apache.daffodil.runtime1.infoset.XMLTextInfosetInputter(is);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as JSON from a 
java.io.InputStream
+   * <p>
+   * Read in an infoset in the form of json text from a java.io.InputStream
+   *
+   * @param is the java.io.InputStream to read the json text from
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newJsonInfosetInputter(InputStream is) {
+    return new org.apache.daffodil.runtime1.infoset.JsonInfosetInputter(is);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as an 
org.jdom2.Document
+   *
+   * @param document the org.jdom2.Document infoset
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newJDOMInfosetInputter(org.jdom2.Document 
document) {
+    return new 
org.apache.daffodil.runtime1.infoset.JDOMInfosetInputter(document);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as an 
org.w3c.dom.Document
+   *
+   * @param document the org.w3c.dom.Document infoset. Note that w3c
+   *                 Documents are not guaranteed to be thread-safe, even if 
all
+   *                 users only read/traverse it. It is up to the user to 
ensure
+   *                 that the Document passed into the W3CDOMInfosetInputter is
+   *                 not read or written by other threads while the
+   *                 W3CDOMInfosetInputter has access to it.
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newW3CDOMInfosetInputter(org.w3c.dom.Document 
document) {
+    return new 
org.apache.daffodil.runtime1.infoset.W3CDOMInfosetInputter(document);
+  }
+
+  /**
+   * Create an InputSourceDataInputStream from a java.io.InputStream
+   *
+   * @param is input stream to create from
+   * @return InputSourceDataInputStream from a java.io.InputStream
+   */
+  public static InputSourceDataInputStream 
newInputSourceDataInputStream(InputStream is) {

Review Comment:
   These three InputSourceDataInputStream factory methods were the impetus 
behind this change.
   
   The issue was that previously they lived in the `o.a.d.api.infoset.Infoset` 
class, which didn't really make sense since they don't really have anything to 
do with infosets. I'm not sure I love throwing all our factory methods in the 
`Daffodil` class, but I'm not sure where else makes sense. Does a a new 
package/class make sense for for ISDIS?
   
   Or, maybe it is actually convenient to say that any Daffodil thing you want 
to create is either created from a factory method in Daffodil or by something 
created by one of those factory methods, such that everything ultimately is 
created from the Daffodil class.
   
   Any thoughts for alternatives?



##########
daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java:
##########
@@ -36,4 +49,192 @@ private Daffodil() {
   public static org.apache.daffodil.api.Compiler compiler() {
     return org.apache.daffodil.core.compiler.Compiler.apply(true);
   }
+
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as a 
scala.xml.Node
+   *
+   * @return InfosetOutputter
+   */
+  public static ScalaXMLInfosetOutputter newScalaXMLInfosetOutputter() {
+    return new 
org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetOutputter(false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as XML written 
to a java.io.OutputStream
+   * <p>
+   * Output the infoset as XML Text, written to a java.io.OutputStream
+   *
+   * @param os     the java.io.OutputStream to write the XML text to
+   * @param pretty enable or disable pretty printing. Pretty printing will only
+   *               insert indentation and newlines where it will not affect the
+   *               content of the XML.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newXMLTextInfosetOutputter(OutputStream os, 
boolean pretty) {
+    return new XMLTextInfosetOutputter(os, pretty, 
XMLTextEscapeStyle.Standard, false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as XML written 
to a java.io.OutputStream
+   * <p>
+   * Output the infoset as XML Text, written to a java.io.OutputStream
+   *
+   * @param os                 the java.io.OutputStream to write the XML text 
to
+   * @param pretty             enable or disable pretty printing. Pretty 
printing will only
+   *                           insert indentation and newlines where it will 
not affect the
+   *                           content of the XML.
+   * @param xmlTextEscapeStyle determine whether to wrap values of elements of 
type
+   *                           xs:string in CDATA tags in order to preserve
+   *                           whitespace.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newXMLTextInfosetOutputter(OutputStream os, 
boolean pretty, XMLTextEscapeStyle xmlTextEscapeStyle) {
+    return new XMLTextInfosetOutputter(os, pretty, xmlTextEscapeStyle, false);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as JSON written 
to a java.io.OutputStream
+   * Output the infoset as json text, written to a java.io.OutputStream
+   *
+   * @param os     the java.io.OutputStream to write the json text to
+   * @param pretty enable or disable pretty printing. Pretty printing will only
+   *               insert indentation and newlines where it will not affect the
+   *               content of the json.
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newJsonInfosetOutputter(OutputStream os, 
boolean pretty) {
+    return new JsonInfosetOutputter(os, pretty);
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as an 
org.jdom2.Document
+   *
+   * @return InfosetOutputter
+   */
+  public static JDOMInfosetOutputter newJDOMInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.JDOMInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetOutputter} to build an infoset represented as an 
org.w3c.dom.Document
+   *
+   * @return InfosetOutputter
+   */
+  public static W3CDOMInfosetOutputter newW3CDOMInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.W3CDOMInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetOutputter} that does not build an infoset representation, 
ignoring
+   * all {@link InfosetOutputter} events
+   *
+   * @return InfosetOutputter
+   */
+  public static InfosetOutputter newNullInfosetOutputter() {
+    return new org.apache.daffodil.runtime1.infoset.NullInfosetOutputter();
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as a scala.xml.Node
+   *
+   * @param node the scala.xml.Node infoset
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newScalaXMLInfosetInputter(scala.xml.Node 
node) {
+    return new 
org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetInputter(node);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as XML from a 
java.io.InputStream
+   * <p>
+   * Read in an infoset in the form of XML text from a java.io.InputStream
+   *
+   * @param is the java.io.InputStream to read the XML text from
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newXMLTextInfosetInputter(InputStream is) {
+    return new org.apache.daffodil.runtime1.infoset.XMLTextInfosetInputter(is);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as JSON from a 
java.io.InputStream
+   * <p>
+   * Read in an infoset in the form of json text from a java.io.InputStream
+   *
+   * @param is the java.io.InputStream to read the json text from
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newJsonInfosetInputter(InputStream is) {
+    return new org.apache.daffodil.runtime1.infoset.JsonInfosetInputter(is);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as an 
org.jdom2.Document
+   *
+   * @param document the org.jdom2.Document infoset
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newJDOMInfosetInputter(org.jdom2.Document 
document) {
+    return new 
org.apache.daffodil.runtime1.infoset.JDOMInfosetInputter(document);
+  }
+
+  /**
+   * {@link InfosetInputter} to read an infoset represented as an 
org.w3c.dom.Document
+   *
+   * @param document the org.w3c.dom.Document infoset. Note that w3c
+   *                 Documents are not guaranteed to be thread-safe, even if 
all
+   *                 users only read/traverse it. It is up to the user to 
ensure
+   *                 that the Document passed into the W3CDOMInfosetInputter is
+   *                 not read or written by other threads while the
+   *                 W3CDOMInfosetInputter has access to it.
+   * @return InfosetInputter
+   */
+  public static InfosetInputter newW3CDOMInfosetInputter(org.w3c.dom.Document 
document) {
+    return new 
org.apache.daffodil.runtime1.infoset.W3CDOMInfosetInputter(document);
+  }
+
+  /**
+   * Create an InputSourceDataInputStream from a java.io.InputStream
+   *
+   * @param is input stream to create from
+   * @return InputSourceDataInputStream from a java.io.InputStream
+   */
+  public static InputSourceDataInputStream 
newInputSourceDataInputStream(InputStream is) {
+    return org.apache.daffodil.io.InputSourceDataInputStream.apply(is);
+  }
+
+  /**
+   * Create an InputSourceDataInputStream from a java.nio.ByteBuffer
+   *
+   * @param bb byte buffer to create from
+   * @return InputSourceDataInputStream from a java.nio.ByteBuffer
+   */
+  public static InputSourceDataInputStream 
newInputSourceDataInputStream(ByteBuffer bb) {
+    return org.apache.daffodil.io.InputSourceDataInputStream.apply(bb);
+  }
+
+  /**
+   * Create an InputSourceDataInputStream from a byte array
+   *
+   * @param arr byte array to create from
+   * @return InputSourceDataInputStream from a byte array
+   */
+  public static InputSourceDataInputStream 
newInputSourceDataInputStream(byte[] arr) {
+    return org.apache.daffodil.io.InputSourceDataInputStream.apply(arr);
+  }
+
+  /**
+   * These are the events that a derived specific InfosetInputter
+   * creates.
+   * <p>
+   * The InfosetInputter base class figures out Daffodil InfosetEvents from
+   * the call-backs providing these derived-class events types.
+   */
+  public enum InfosetInputterEventType {

Review Comment:
   It feels like this enum still wants to live in the `o.a.d.api.infoset` 
package, since this is something only used by custom InfosetInputter 
implementations, which mostly use APIs defined in `o.a.d.api.infoset`.



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