Packages

  • package root

    org.apache.daffodil.sapi - Provides the classes necessary to compile DFDL schemas, parse and unparse files using the compiled objects, and retrieve results and parsing diagnostics

    Apache Daffodil (incubating) Scala API

    Packages

    org.apache.daffodil.sapi - Provides the classes necessary to compile DFDL schemas, parse and unparse files using the compiled objects, and retrieve results and parsing diagnostics

    org.apache.daffodil.sapi.logger - Provides the classes necessary to receive logging messages from Daffodil.

    org.apache.daffodil.sapi.debugger - Provides the classes necessary to perform parse tracing or create a custom debugger

    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package apache
    Definition Classes
    org
  • package daffodil
    Definition Classes
    apache
  • package sapi

    Provides the classes necessary to compile DFDL schemas, parse and unparse files using the compiled objects, and retrieve results and parsing diagnostics

    Provides the classes necessary to compile DFDL schemas, parse and unparse files using the compiled objects, and retrieve results and parsing diagnostics

    Overview

    The Daffodil object is a factory object to create a Compiler. The Compiler provides a method to compils a provided DFDL schema into a ProcessorFactory, which creates a DataProcessor:

    val c = Daffodil.compiler()
    val pf = c.compileFile(file)
    val dp = pf.onPath("/")

    The DataProcessor provides the necessary functions to parse and unparse data, returning a ParseResult or UnparseResult, respectively. These contain information about the parse/unparse, such as whether or not the processing succeeded any diagnostic information.

    Parse

    The DataProcessor.parse method accepts input data to parse in the form of a InputSourceDataInputStream and an InfosetOutputter to determine the output representation of the infoset (e.g. Scala XML Nodes, JDOM2 Documents, etc.):

    val scalaOutputter = new ScalaXMLInfosetOutputter()
    val is = new InputSourceDataInputStream(data)
    val pr = dp.parse(is, scalaOutputter)
    val node = scalaOutputter.getResult

    The DataProcessor.parse method is thread-safe and may be called multiple times without the need to create other data processors. However, InfosetOutputter's are not thread safe, requiring a unique instance per thread. An InfosetOutputter should call InfosetOutputter.reset before reuse (or a new one should be allocated). For example:

    val scalaOutputter = new ScalaXMLInfosetOutputter()
    files.foreach { f => {
      outputter.reset
      val is = new InputSourceDataInputStream(new FileInputStream(f))
      val pr = dp.parse(is, scalaOutputter)
      val node = scalaOutputter.getResult
    }

    One can repeat calls to parse() using the same InputSourceDataInputStream to continue parsing where the previous parse ended. For example:

    val is = new InputSourceDataInputStream(dataStream)
    val scalaOutputter = new ScalaXMLInfosetOutputter()
    val keepParsing = true
    while (keepParsing) {
      scalaOutputter.reset()
      val pr = dp.parse(is, jdomOutputter)
      ...
      keepParsing = !pr.location().isAtEnd() && !pr.isError()
    }
    Unparse

    The same DataProcessor used for parse can be used to unparse an infoset via the DataProcessor.unparse method. An InfosetInputter provides the infoset to unparse, with the unparsed data written to the provided java.nio.channels.WritableByteChannel. For example:

    val inputter = new ScalaXMLInfosetInputter(node)
    val ur = dp.unparse(inputter, wbc)
    Failures and Diagnostics

    It is possible that failures could occur during the creation of the ProcessorFactory, DataProcessor, or ParseResult. However, rather than throwing an exception on error (e.g. invalid DFDL schema, parse error, etc), these classes extend WithDiagnostics, which is used to determine if an error occurred, and any diagnostic information (see Diagnostic) related to the step. Thus, before continuing, one must check WithDiagnostics.isError. For example:

    val pf = c.compile(file)
    if (pf.isError()) {
      val diags = pf.getDiagnostics()
      diags.foreach { d =>
        System.out.println(d.toString())
      }
      return -1;
    }
    Saving and Reloading Parsers

    In some cases, it may be beneficial to save a parser and reload it. For example, when starting up, it may be quicker to reload an already compiled parser than to compile it from scratch. To save a DataProcessor:

    val dp = pf.onPath("/")
    dp.save(saveFile);

    And to restore a saved DataProcessor:

    val dp = Daffodil.reload(saveFile);
    val pr = dp.parse(data, inputter);
    Definition Classes
    daffodil
  • package infoset

    Defines various classes used control the representation of the infoset for parse and unparse.

    Defines various classes used control the representation of the infoset for parse and unparse. Classes that extend InfosetOutputter are provided to the DataProcessor.parse method to deteremine how to output an infoset. These classes are not guaranteed to be thread-safe. Classes that extend InfosetInputter are provided to the DataProcessor.unparse method to determine how to read in an infoset. A new InfosetOutputter is required for each call to unparse().

    Definition Classes
    sapi
  • InfosetInputter
  • InfosetInputterProxy
  • InfosetOutputter
  • InfosetOutputterProxy
  • JDOMInfosetInputter
  • JDOMInfosetOutputter
  • JsonInfosetInputter
  • JsonInfosetOutputter
  • NullInfosetOutputter
  • ScalaXMLInfosetInputter
  • ScalaXMLInfosetOutputter
  • W3CDOMInfosetInputter
  • W3CDOMInfosetOutputter
  • XMLTextInfosetInputter
  • XMLTextInfosetOutputter
c

org.apache.daffodil.sapi.infoset

InfosetInputter

abstract class InfosetInputter extends infoset.InfosetInputter

Abstract class used to determine how the infoset representation should be input from a call to DataProcessor.unparse. This uses a Cursor API, such that each call to advance/inspect must update a cursor value, minimizing allocations. Callers of advance/inspect are expected to copy out any information from advanceAccessor and inspectAccessor if they need to retain the information after a call to advance/inspect.

Linear Supertypes
infoset.InfosetInputter, CursorImplMixin[InfosetAccessor], InfosetInputterCursor, Cursor[InfosetAccessor], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. InfosetInputter
  2. InfosetInputter
  3. CursorImplMixin
  4. InfosetInputterCursor
  5. Cursor
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InfosetInputter()

Abstract Value Members

  1. abstract def fini: Unit
    Definition Classes
    Cursor
  2. abstract def getEventType(): InfosetInputterEventType

    Return the current infoset inputter event type

    Return the current infoset inputter event type

    Definition Classes
    InfosetInputter → InfosetInputter
  3. abstract def getLocalName(): String

    Get the local name of the current event.

    Get the local name of the current event. This will only be called when the current event type is StartElement.

    Definition Classes
    InfosetInputter → InfosetInputter
  4. abstract def getNamespaceURI(): String

    Get the namespace of the current event.

    Get the namespace of the current event. This will only be called when the current event type is StartElement. If the InfosetInputter does not support namespaces, this shoud return null. This may return null to represent no namespaces.

    Definition Classes
    InfosetInputter → InfosetInputter
  5. abstract def getSimpleText(primType: Kind): String

    Get the content of a simple type.

    Get the content of a simple type. This will only be called when the current event type is StartElement and the element is a simple type. If the event contains complex data, it is an error and should throw NonTextFoundInSimpleContentException. If the element does not have any simple content, this should return either null or the empty string.

    Definition Classes
    InfosetInputter → InfosetInputter
  6. abstract def hasNext(): Boolean

    Return true if there are remaining events.

    Return true if there are remaining events. False otherwise.

    Definition Classes
    InfosetInputter → InfosetInputter
  7. abstract def isNilled(): MaybeBoolean

    Determine if the current event is nilled.

    Determine if the current event is nilled. This will only be called when the current event type is StartElement. Return MaybeBoolean.Nope if no nil property is set, which implies the element is not nilled. Return MaybeBoolean(false) if the nil property is set, but it is set to false. Return MaybeBoolean(true) if the nil property is set to true.

    Definition Classes
    InfosetInputter → InfosetInputter
  8. abstract def next(): Unit

    Move the internal state to the next event.

    Move the internal state to the next event.

    Definition Classes
    InfosetInputter → InfosetInputter
  9. abstract val supportsNamespaces: Boolean
    Definition Classes
    InfosetInputter

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final val accessor: InfosetAccessor
    Attributes
    protected
    Definition Classes
    CursorImplMixin
  5. final def advance: Boolean
    Definition Classes
    CursorImplMixin
  6. lazy val advanceAccessor: InfosetAccessor
    Definition Classes
    InfosetInputterCursor → Cursor
  7. final def advanceMaybe: Maybe[InfosetAccessor]
    Definition Classes
    Cursor
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. final def fill(): Boolean
    Attributes
    protected
    Definition Classes
    InfosetInputter → CursorImplMixin
  13. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def initialize(rootElementInfo: ElementRuntimeData, tunableArg: DaffodilTunables): Unit
    Definition Classes
    InfosetInputter → InfosetInputterCursor
  17. final def inspect: Boolean
    Definition Classes
    CursorImplMixin
  18. lazy val inspectAccessor: InfosetAccessor
    Definition Classes
    InfosetInputterCursor → Cursor
  19. final def inspectMaybe: Maybe[InfosetAccessor]
    Definition Classes
    Cursor
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  25. def toString(): String
    Definition Classes
    InfosetInputter → AnyRef → Any
  26. var tunable: DaffodilTunables
    Definition Classes
    InfosetInputter
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from infoset.InfosetInputter

Inherited from CursorImplMixin[InfosetAccessor]

Inherited from InfosetInputterCursor

Inherited from Cursor[InfosetAccessor]

Inherited from AnyRef

Inherited from Any

Ungrouped