Package uk.ac.starlink.vo

## Class TableSetSaxHandler

- java.lang.Object
- - org.xml.sax.helpers.DefaultHandler
  - - uk.ac.starlink.vo.TableSetSaxHandler

-     public class TableSetSaxHandler
      extends org.xml.sax.helpers.DefaultHandler

  Parses an XML document which describes Tabular Data as prescribed by the VODataService standard. It will pick up <table> elements (of type vs:Table), or elements that look like them, to build a picture of the tables and their columns and foreign keys. XML documents of this type are exposed by VOSI and TAP services.

  The easiest way to make use of this class is via the static method `readTableSet(java.net.URL, uk.ac.starlink.util.ContentCoding)` or the convenience `main(java.lang.String[])` method.

  See Also:
    IVOA VODataService Recommendation

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TableSetSaxHandler​()` | Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `characters​(char[] ch, int start, int length)` |
    `void` | `endDocument​()` |
    `void` | `endElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName)` |
    `void` | `endPrefixMapping​(java.lang.String prefix)` |
    `TableMeta[]` | `getNakedTables​()` | Returns the array of table metadata objects which were found outside of any schema.
    `SchemaMeta[]` | `getSchemas​(boolean includeNaked)` | Returns the array of schema metadata objects which have been read by this parser.
    `void` | `ignorableWhitespace​(char[] ch, int start, int length)` |
    `static void` | `main​(java.lang.String[] args)` | Main method to parse a tableset from the command line.
    `static TableSetSaxHandler` | `populateHandler​(java.net.URL url, uk.ac.starlink.util.ContentCoding coding)` | Uses an instance of this class to parse the document at a given URL.
    `void` | `processingInstruction​(java.lang.String target, java.lang.String data)` |
    `static TableMeta[]` | `readTables​(java.net.URL url, uk.ac.starlink.util.ContentCoding coding)` | Uses an instance of this class to read an XML document from a given URL and extracts a flat list of all the TableMeta objects it represents.
    `static SchemaMeta[]` | `readTableSet​(java.net.URL url, uk.ac.starlink.util.ContentCoding coding)` | Uses an instance of this class to read an XML document from a given URL and extract the SchemaMeta objects it represents.
    `void` | `setDocumentLocator​(org.xml.sax.Locator locator)` |
    `void` | `skippedEntity​(java.lang.String name)` |
    `void` | `startDocument​()` |
    `void` | `startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)` |
    `void` | `startPrefixMapping​(java.lang.String prefix, java.lang.String uri)` |

    - ### Methods inherited from class org.xml.sax.helpers.DefaultHandler

      `error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning`

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

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

- - ### Constructor Detail

    - #### TableSetSaxHandler

          public TableSetSaxHandler​()

      Constructor.

  - ### Method Detail

    - #### getSchemas

          public SchemaMeta[] getSchemas​(boolean includeNaked)

      Returns the array of schema metadata objects which have been read by this parser. Only non-empty following a parse.
      Parameters:
        `includeNaked` - if false, only the schemas actually encountered are returned; if true, then any naked tables will be included in a dummy schema in the result
      Returns:
        fully populated table metadata

    - #### getNakedTables

          public TableMeta[] getNakedTables​()

      Returns the array of table metadata objects which were found outside of any schema. Only non-empty following a parse.
      Returns:
        table metadata

    - #### startDocument

          public void startDocument​()

      Overrides:
        `startDocument` in class `org.xml.sax.helpers.DefaultHandler`

    - #### endDocument

          public void endDocument​()

      Overrides:
        `endDocument` in class `org.xml.sax.helpers.DefaultHandler`

    - #### startElement

          public void startElement​(java.lang.String uri,
                                   java.lang.String localName,
                                   java.lang.String qName,
                                   org.xml.sax.Attributes atts)

      Overrides:
        `startElement` in class `org.xml.sax.helpers.DefaultHandler`

    - #### endElement

          public void endElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName)

      Overrides:
        `endElement` in class `org.xml.sax.helpers.DefaultHandler`

    - #### characters

          public void characters​(char[] ch,
                                 int start,
                                 int length)

      Overrides:
        `characters` in class `org.xml.sax.helpers.DefaultHandler`

    - #### ignorableWhitespace

          public void ignorableWhitespace​(char[] ch,
                                          int start,
                                          int length)

      Overrides:
        `ignorableWhitespace` in class `org.xml.sax.helpers.DefaultHandler`

    - #### startPrefixMapping

          public void startPrefixMapping​(java.lang.String prefix,
                                         java.lang.String uri)

      Overrides:
        `startPrefixMapping` in class `org.xml.sax.helpers.DefaultHandler`

    - #### endPrefixMapping

          public void endPrefixMapping​(java.lang.String prefix)

      Overrides:
        `endPrefixMapping` in class `org.xml.sax.helpers.DefaultHandler`

    - #### processingInstruction

          public void processingInstruction​(java.lang.String target,
                                            java.lang.String data)

      Overrides:
        `processingInstruction` in class `org.xml.sax.helpers.DefaultHandler`

    - #### skippedEntity

          public void skippedEntity​(java.lang.String name)

      Overrides:
        `skippedEntity` in class `org.xml.sax.helpers.DefaultHandler`

    - #### setDocumentLocator

          public void setDocumentLocator​(org.xml.sax.Locator locator)

      Overrides:
        `setDocumentLocator` in class `org.xml.sax.helpers.DefaultHandler`

    - #### readTableSet

          public static SchemaMeta[] readTableSet​(java.net.URL url,
                                                  uk.ac.starlink.util.ContentCoding coding)
                                           throws java.io.IOException,
                                                  org.xml.sax.SAXException

      Uses an instance of this class to read an XML document from a given URL and extract the SchemaMeta objects it represents.
      Parameters:
        `url` - containing a TableSet document or similar
        `coding` - configures HTTP content-coding
      Returns:
        array of schema metadata objects giving table metadata
      Throws:
        `java.io.IOException`
        `org.xml.sax.SAXException`

    - #### readTables

          public static TableMeta[] readTables​(java.net.URL url,
                                               uk.ac.starlink.util.ContentCoding coding)
                                        throws java.io.IOException,
                                               org.xml.sax.SAXException

      Uses an instance of this class to read an XML document from a given URL and extracts a flat list of all the TableMeta objects it represents. This includes all the tables in schemas, as well as any outside any `<schema>` element.
      Parameters:
        `url` - containing a TableSet document or similar
        `coding` - configures HTTP content-coding
      Returns:
        flat list of all tables
      Throws:
        `java.io.IOException`
        `org.xml.sax.SAXException`

    - #### populateHandler

          public static TableSetSaxHandler populateHandler​(java.net.URL url,
                                                           uk.ac.starlink.util.ContentCoding coding)
                                                    throws java.io.IOException,
                                                           org.xml.sax.SAXException

      Uses an instance of this class to parse the document at a given URL.
      Parameters:
        `url` - containing a TableSet document or similar
        `coding` - configures HTTP content-coding
      Returns:
        handler containing located items
      Throws:
        `java.io.IOException`
        `org.xml.sax.SAXException`

    - #### main

          public static void main​(java.lang.String[] args)
                           throws java.io.IOException,
                                  org.xml.sax.SAXException

      Main method to parse a tableset from the command line.
      Parameters:
        `args` - first element is a URL to read from
      Throws:
        `java.io.IOException`
        `org.xml.sax.SAXException`

Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.