Packages

  • package root
    Definition Classes
    root
  • package io
    Definition Classes
    root
  • package dylemma
    Definition Classes
    io
  • package spac

    SPaC (short for "Streaming Parser Combinators") is a library for building stream consumers in a declarative style, specialized for tree-like data types like XML and JSON.

    SPaC (short for "Streaming Parser Combinators") is a library for building stream consumers in a declarative style, specialized for tree-like data types like XML and JSON.

    Many utilities for handling XML and JSON data involve parsing the entire "document" to some DOM model, then inspecting and transforming that model to extract information. The downside to these utilities is that when the document is very large, the DOM may not fit in memory. The workaround for this type of problem is to treat the document as a stream of "events", e.g. "StartElement" and "EndElement" for XML, or "StartObject" and "EndObject" for JSON. The downside to this workaround is that writing code to handle these streams can be complicated and error-prone, especially when the DOM is complicated.

    SPaC's goal is to drastically simplify the process of creating code to handle these streams.

    This package contains the "core" SPaC traits; Parser, Transformer, Splitter, and ContextMatcher.

    See the xml and json subpackages (provided by the xml-spac and json-spac libraries respectively) for specific utilities related to handling XML and JSON event streams.

    Definition Classes
    dylemma
  • package xml

    This package provides extensions to the core "spac" library which allow for the handling of XML data.

    This package provides extensions to the core "spac" library which allow for the handling of XML data.

    Rather than creating explicit classes that extend Parser, Transformer, and Splitter, this package provides type aliases and implicit extensions. For example, XmlParser[A] is just a type alias for Parser[XmlEvent, A], and XmlParser is just a call to Parser[XmlEvent].

    Three main Parser methods are added to Parser[XmlEvent] via the XmlParserApplyOps implicit class:

    • XmlParser.forText - for capturing raw text
    • XmlParser.attr - for capturing mandatory attributes from elements
    • XmlParser.attrOpt - for capturing optional attributes from elements

    One main Splitter constructor method is added to Splitter via the XmlSplitterApplyOps implicit class:

    • Splitter.xml - for creating splitters based on an inspection of an "element stack"

    Three main Splitter member methods are added to Splitter[XmlEvent, C] via the XmlSplitterOps implicit class:

    • .attr - alias for .joinBy(XmlParser.attr(...))
    • .attrOpt - alias for .joinBy(XmlParser.attrOpt(...))
    • .text - alias for .joinBy(XmlParser.forText)

    A DSL for creating xml-specific ContextMatchers is provided to make it more convenient to call Splitter.xml. For example:

    Splitter.xml("things" \ "thing").attr("foo").parseToList

    Can be used to capture a list of the "foo" attributes in the <thing> elements in

    <things>
       <thing foo="hello" />
       <thing foo="Goodbye">
          <extra>junk</extra>
       </thing>
    </thing>
    Definition Classes
    spac
  • AsQName
  • Fs2DataQName
  • Fs2DataSource
  • JavaxQName
  • JavaxSource
  • XmlEvent
  • XmlParserApplyOps
  • XmlSpacException
  • XmlSplitterApplyOps
  • XmlSplitterOps
o

io.dylemma.spac.xml

JavaxSource

object JavaxSource

Provides helpers for creating Source[XmlEvent] using javax.xml.stream for the underlying event provider.

Source
JavaxSource.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JavaxSource
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

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. def apply(eventReader: XMLEventReader): Source[XmlEvent]
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. lazy val defaultFactory: XMLInputFactory

    Default XMLInputFactory used when creating an underlying XMLEventReader with the methods in this object.

    Default XMLInputFactory used when creating an underlying XMLEventReader with the methods in this object.

    This factory disables the IS_REPLACING_ENTITY_REFERENCES and IS_SUPPORTING_EXTERNAL_ENTITIES features, in efforts to mitigate xml injection attacks.

    When using the methods in this object, if you want to override this default factory, define an implicit XMLInputFactory somewhere and make it available in the scope where you call the method, e.g.

    implicit val mySpecificXmlFactory: XMLInputFactory = ???
    val xmlEvents = JavaxSource[IO](new File("./stuff.xml"))
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. def fromFile(file: File, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Returns a Source[XmlEvent] which can open the given file to read raw XML data.

    Returns a Source[XmlEvent] which can open the given file to read raw XML data.

    The returned Source is reusable. The underlying streams are managed by the open method and the close function it returns.

    file

    A file containing XML

    factory

    Factory instance for the underlying Javax parser

    returns

    A reusable Source[XmlEvent]

  12. def fromFileWithCharset(file: File, charset: String, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Like fromFile, but passes an explicit charset to the underlying XmlEventReader constructor.

    Like fromFile, but passes an explicit charset to the underlying XmlEventReader constructor.

    file

    A file containing XML

    charset

    A Charset name used to interpret the bytes to characters

    factory

    Factory instance for the underlying Javax parser

  13. def fromInputStream(rawXml: InputStream, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes.

    Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes.

    The returned Source will *not* attempt to close the rawXml stream; responsibility for closing rawXml lies with whoever created it.

    rawXml

    An InputStream containing raw XML bytes

    factory

    Factory instance for the underlying Javax parser

    returns

    A single-use Source[XmlEvent]

  14. def fromInputStreamWithCharset(rawXml: InputStream, charset: String, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes, passing the given charset to the underlying XMLEventReader constructor

    Returns a single-use Source[XmlEvent] which interprets the contents of the given InputStream as raw XML bytes, passing the given charset to the underlying XMLEventReader constructor

    The returned Source will *not* attempt to close the rawXml stream; responsibility for closing rawXml lies with whoever created it.

    rawXml

    An InputStream containing raw XML bytes

    charset

    Name of the charset used to interpret the bytes to characters.

    factory

    Factory instance for the underlying Javax parser

    returns

    A single-use Source[XmlEvent]

  15. def fromReader(rawXml: Reader, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Returns a single-use Source[XmlEvent] which interprets the contents of the given Reader as raw XML characters.

    Returns a single-use Source[XmlEvent] which interprets the contents of the given Reader as raw XML characters.

    The returned Source will *not* attempt to close the rawXml reader; responsibility for closing rawXml lies with whoever created it.

    rawXml

    A Reader containing raw XML character data

    factory

    Factory instance for the underlying Javax parser

    returns

    A single-use Source[XmlEvent]

  16. def fromString(rawXml: String, factory: XMLInputFactory = defaultFactory): Source[XmlEvent]

    Returns a Source[XmlEvent] which interprets the given string as raw XML.

    Returns a Source[XmlEvent] which interprets the given string as raw XML.

    rawXml

    A string of raw XML

    factory

    Factory instance for the underlying Javax parser

    returns

    A reusable Source[XmlEvent]

  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped