Class InfosetOutputter

java.lang.Object
org.apache.daffodil.api.infoset.InfosetOutputter
Direct Known Subclasses:
JDOMInfosetOutputter, ScalaXMLInfosetOutputter, W3CDOMInfosetOutputter

public abstract class InfosetOutputter extends Object
Abstract class used to determine how the infoset representation should be output from a call to DataProcessor.parse(input:org\.apache\.daffodil* DataProcessor.parse). The Daffodil core will call the various methods of this class in an order appropriate to create an infoset representation.

Classes that extend InfosetOutputter are not guaranteed to be thread-safe.

Note that these functions all throw the generic java.lang.Exception to indicate error. Part of the reason to do this instead of a custom exception (e.g. InfosetOutputterException) is to simplify implementations. If an implementation already throws an exception when there is an error, there is no need to catch it and wrap it in a Daffodil specific exception. This is especially true considering Daffodil will just unwrap the exception and convert it to a SDE. Additionally, because Scala does not have checked exceptions, it can be difficult to ensure all expected exceptions are caught by implementations. This does mean some exceptions that you might normally expect to bubble up and will not, and will instead be turned into an SDE.

  • Constructor Details

    • InfosetOutputter

      public InfosetOutputter()
  • Method Details

    • reset

      public abstract void reset()
      Reset the internal state of this InfosetOutputter. This should be called in between calls to the parse method.

      call to reuse these. When first constructed, no reset call is necessary.

    • startDocument

      public abstract void startDocument() throws Exception
      Called by Daffodil internals to signify the beginning of the infoset.

      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • endDocument

      public abstract void endDocument() throws Exception
      Called by Daffodil internals to signify the end of the infoset.

      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • startSimple

      public abstract void startSimple(InfosetSimpleElement diSimple) throws Exception
      Called by Daffodil internals to signify the beginning of a simple element.

      Parameters:
      diSimple - the simple element that is started. Various fields of DISimple can be accessed to determine things like the value, nil, name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • endSimple

      public abstract void endSimple(InfosetSimpleElement diSimple) throws Exception
      Called by Daffodil internals to signify the end of a simple element.

      Parameters:
      diSimple - the simple element that is ended. Various fields of DISimple can be accessed to determine things like the value, nil, name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • startComplex

      public abstract void startComplex(InfosetComplexElement complex) throws Exception
      Called by Daffodil internals to signify the beginning of a complex element.

      Parameters:
      complex - the complex element that is started. Various fields of DIComplex can be accessed to determine things like the nil, name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • endComplex

      public abstract void endComplex(InfosetComplexElement complex) throws Exception
      Called by Daffodil internals to signify the end of a complex element.

      Parameters:
      complex - the complex element that is ended. Various fields of DIComplex can be accessed to determine things like the nil, name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • startArray

      public abstract void startArray(InfosetArray array) throws Exception
      Called by Daffodil internals to signify the beginning of an array of elements.

      Parameters:
      array - the array that is started. Various fields of DIArray can be accessed to determine things like the name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • endArray

      public abstract void endArray(InfosetArray array) throws Exception
      Called by Daffodil internals to signify the end of an array of elements.

      Parameters:
      array - the array that is ended. Various fields of DIArray can be accessed to determine things like the name, namespace, etc.
      Throws:
      Exception - if there was an error and Daffodil should stop parsing
    • setBlobAttributes

      public final void setBlobAttributes(Path dir, String prefix, String suffix)
      Set the attributes for how to create blob files.
      Parameters:
      dir - the Path the the directory to create files. If the directory does not exist, Daffodil will attempt to create it before writing a blob.
      prefix - the prefix string to be used in generating a blob file name
      suffix - the suffix string to be used in generating a blob file name
    • getBlobPrefix

      public final String getBlobPrefix()
      Returns:
      blob prefix string
    • getBlobSuffix

      public final String getBlobSuffix()
      Returns:
      blob suffix string
    • getBlobDirectory

      public final Path getBlobDirectory()
      Returns:
      blob directory path
    • getBlobPaths

      public final List<Path> getBlobPaths()
      Get the list of blob paths that were output in the infoset.

      This is the same as what would be found by iterating over the infoset.

      Returns:
      list of blob paths that were output in the infoset.
    • setBlobPaths

      public final void setBlobPaths(List<Path> blobPaths)
      Set the list of blob paths
      Parameters:
      blobPaths - list of blob paths to be set