ch.dieseite.colladaloader.coreproc

## Class SaxParser<CI,RI>

- java.lang.Object
- - ch.dieseite.colladaloader.coreproc.SaxParser<CI,RI>

-     public class SaxParser<CI,RI>
      extends java.lang.Object

  SaxParser scans a XML stream and compares it to a search pattern.

  A pattern is wrapped in a SaxParser.Context and matches if XML depth and XML tag name of stream is arrived. In this case a "SaxParser.Record" object is created. It can be either:
- a) added as a child into a current parent Record object (on nested patterns) or
- b) be returned via callback (if pattern is parent)

SaxParser process more than one patterns as "OR" and nested patterns as "AND". Nested patterns implicate children, top levels parents.

Its a good practice to define exactly one parent and zero or more children per scan. The less children is defined, the less memory is used. Max allowed xml depth is Long.BYTES*8.

A pattern can either match by tag name (Syntax: "tagName") or tag name and attribute value (Syntax: "tagName#attribName=value") what gives it a stricter fine search. Each xml depth is separated by "/". An Example can be found in linking schema specifications under <target>

Note: This Class has no depencies to other classes and contains a Main() testMethod

This source is free; you can redistribute it and/or modify it under the terms of the GNU General Public License and by nameing of the originally author

Version:
  3.1
Author:
  Markus Zimmermann http://www.die-seite.ch

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SaxParser.Context<CI,RI>` A helper class a) to cache callbacks from SaxParser b) to define a certain tag in a certain xml tree to be found and c) additional infos what to do next with that Record
    `static class` | `SaxParser.Record<CI,RI>` A wrapper that contains xml tag datas
    `(package private) static interface` | `SaxParser.RecordHandler<CI,RI>`
    `private static class` | `SaxParser.SaxHandler<CI,RI>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private SaxParser.RecordHandler<CI,RI>` | `handler`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `SaxParser()`
    `` | `SaxParser(SaxParser.RecordHandler<CI,RI> handler)` handler is a callback (see interface descriptions)

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <CI,RI> SaxParser.Context<CI,RI>` | `createSearchContext(java.lang.String xmlSearchPattern, SaxParser.Context<CI,RI> parent)` Creates a search context containing search pattern If context is nested then add parent context
    `void` | `parse(SaxParser.Context<CI,RI>[] params, java.lang.String filename)` Starts xml scan

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### handler

          private SaxParser.RecordHandler<CI,RI> handler

  - ### Constructor Detail

    - #### SaxParser

          private SaxParser()

    - #### SaxParser

          public SaxParser(SaxParser.RecordHandler<CI,RI> handler)

      handler is a callback (see interface descriptions)
      Parameters:
        `handler` - mustn't be null

  - ### Method Detail

    - #### parse

          public void parse(SaxParser.Context<CI,RI>[] params,
                            java.lang.String filename)
                     throws javax.xml.parsers.ParserConfigurationException,
                            org.xml.sax.SAXException,
                            java.io.IOException

      Starts xml scan
      Parameters:
        `params` - , created with createSearchContext()
        `filename` - (absolute Path)
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`

    - #### createSearchContext

          public static <CI,RI> SaxParser.Context<CI,RI> createSearchContext(java.lang.String xmlSearchPattern,
                                                                             SaxParser.Context<CI,RI> parent)

      Creates a search context containing search pattern If context is nested then add parent context
      Parameters:
        `xmlSearchPattern` - i.e. "rootDoc/tags/tag/subtag" or "rootDoc/tags/tag/subtag#attribName=value"
        `parent` - or null if it's the first parent context
      Returns: