Package uk.ac.starlink.vo
Class TableSetSaxHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
uk.ac.starlink.vo.TableSetSaxHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) void
void
endElement
(String uri, String localName, String qName) void
endPrefixMapping
(String prefix) Returns the array of table metadata objects which were found outside of any schema.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 method to parse a tableset from the command line.static TableSetSaxHandler
populateHandler
(URL url, uk.ac.starlink.util.ContentCoding coding) Uses an instance of this class to parse the document at a given URL.void
processingInstruction
(String target, String data) static TableMeta[]
readTables
(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
(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
(Locator locator) void
skippedEntity
(String name) void
void
startElement
(String uri, String localName, String qName, Attributes atts) void
startPrefixMapping
(String prefix, 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
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
TableSetSaxHandler
public TableSetSaxHandler()Constructor.
-
-
Method Details
-
getSchemas
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
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()- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
-
endDocument
public void endDocument()- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
-
startElement
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) - Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Overrides:
skippedEntity
in classDefaultHandler
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
readTableSet
public static SchemaMeta[] readTableSet(URL url, uk.ac.starlink.util.ContentCoding coding) throws IOException, 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 similarcoding
- configures HTTP content-coding- Returns:
- array of schema metadata objects giving table metadata
- Throws:
IOException
SAXException
-
readTables
public static TableMeta[] readTables(URL url, uk.ac.starlink.util.ContentCoding coding) throws IOException, 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 similarcoding
- configures HTTP content-coding- Returns:
- flat list of all tables
- Throws:
IOException
SAXException
-
populateHandler
public static TableSetSaxHandler populateHandler(URL url, uk.ac.starlink.util.ContentCoding coding) throws IOException, SAXException Uses an instance of this class to parse the document at a given URL.- Parameters:
url
- containing a TableSet document or similarcoding
- configures HTTP content-coding- Returns:
- handler containing located items
- Throws:
IOException
SAXException
-
main
Main method to parse a tableset from the command line.- Parameters:
args
- first element is a URL to read from- Throws:
IOException
SAXException
-