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(URL, ContentCoding) or the convenience main(String[]) method.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidvoidendElement(String uri, String localName, String qName) voidendPrefixMapping(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.voidignorableWhitespace(char[] ch, int start, int length) static voidMain method to parse a tableset from the command line.static TableSetSaxHandlerpopulateHandler(URL url, uk.ac.starlink.util.ContentCoding coding) Uses an instance of this class to parse the document at a given URL.voidprocessingInstruction(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.voidsetDocumentLocator(Locator locator) voidskippedEntity(String name) voidvoidstartElement(String uri, String localName, String qName, Attributes atts) voidstartPrefixMapping(String prefix, String uri) Methods inherited from class DefaultHandler
error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warningMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler
-
endDocument
public void endDocument()- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler
-
startElement
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) - Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Overrides:
skippedEntityin classDefaultHandler
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin 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:
IOExceptionSAXException
-
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:
IOExceptionSAXException
-
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:
IOExceptionSAXException
-
main
Main method to parse a tableset from the command line.- Parameters:
args- first element is a URL to read from- Throws:
IOExceptionSAXException
-