Package uk.ac.starlink.votable
Class VOTableBuilder
java.lang.Object
uk.ac.starlink.table.formats.DocumentedTableBuilder
uk.ac.starlink.votable.VOTableBuilder
- All Implemented Interfaces:
uk.ac.starlink.table.Documented
,uk.ac.starlink.table.formats.DocumentedIOHandler
,uk.ac.starlink.table.MultiTableBuilder
,uk.ac.starlink.table.TableBuilder
public class VOTableBuilder
extends uk.ac.starlink.table.formats.DocumentedTableBuilder
implements uk.ac.starlink.table.MultiTableBuilder
Implementation of the
TableBuilder
interface which
gets StarTable
s from VOTable documents.- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.VOTableBuilder
(boolean strict) Constructs a builder with explicit setting of whether VOTable standard interpreation is strict or not. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canImport
(DataFlavor flavor) Returnstrue
for flavors which have MIME types starting text/xml application/xml application/x-votable+xmlboolean
boolean
Returns the string "VOTable".uk.ac.starlink.table.StarTable
makeStarTable
(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy storagePolicy) Makes a StarTable out of a DataSource which points to a VOTable.uk.ac.starlink.table.TableSequence
makeStarTables
(uk.ac.starlink.util.DataSource datsrc, uk.ac.starlink.table.StoragePolicy storagePolicy) void
streamStarTable
(InputStream istrm, uk.ac.starlink.table.TableSink sink, String index) Acquires the data from a single TABLE element in a VOTable document, writing the result to a sink.Methods inherited from class uk.ac.starlink.table.formats.DocumentedTableBuilder
getExtensions, looksLikeFile
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface uk.ac.starlink.table.formats.DocumentedIOHandler
readText
Methods inherited from interface uk.ac.starlink.table.TableBuilder
looksLikeFile
-
Constructor Details
-
VOTableBuilder
public VOTableBuilder()Default constructor. Strictness of VOTable standard enforcement is determined byVOElementFactory.isStrictByDefault()
. -
VOTableBuilder
public VOTableBuilder(boolean strict) Constructs a builder with explicit setting of whether VOTable standard interpreation is strict or not.- Parameters:
strict
- true iff you want strict enforcement of VOTable standard- See Also:
-
-
Method Details
-
getFormatName
Returns the string "VOTable".- Specified by:
getFormatName
in interfaceuk.ac.starlink.table.TableBuilder
- Returns:
- format name
-
makeStarTable
public uk.ac.starlink.table.StarTable makeStarTable(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy storagePolicy) throws uk.ac.starlink.table.TableFormatException, IOException Makes a StarTable out of a DataSource which points to a VOTable. If the source has a position attribute, it is currently interpreted as an index into a breadth-first list of the TABLE elements in the document pointed to bydatsrc
, thus it must be a non-negative integer less than the number of TABLE elements. If it has no position attribute, the first TABLE element is used. The interpretation of the position should probably change or be extended in the future to allow XPath expressions.- Specified by:
makeStarTable
in interfaceuk.ac.starlink.table.TableBuilder
- Parameters:
datsrc
- the location of the VOTable document to usewantRandom
- whether, preferentially, a random access table should be returned (doesn't guarantee that it will be random)storagePolicy
- a StoragePolicy object which may be used to supply scratch storage if the builder needs it- Returns:
- a StarTable made out of
datsrc
, ornull
if this handler can't handle it - Throws:
uk.ac.starlink.table.TableFormatException
IOException
-
makeStarTables
public uk.ac.starlink.table.TableSequence makeStarTables(uk.ac.starlink.util.DataSource datsrc, uk.ac.starlink.table.StoragePolicy storagePolicy) throws uk.ac.starlink.table.TableFormatException, IOException - Specified by:
makeStarTables
in interfaceuk.ac.starlink.table.MultiTableBuilder
- Throws:
uk.ac.starlink.table.TableFormatException
IOException
-
canImport
Returnstrue
for flavors which have MIME types starting- text/xml
- application/xml
- application/x-votable+xml
- Specified by:
canImport
in interfaceuk.ac.starlink.table.TableBuilder
-
streamStarTable
public void streamStarTable(InputStream istrm, uk.ac.starlink.table.TableSink sink, String index) throws IOException Acquires the data from a single TABLE element in a VOTable document, writing the result to a sink. This can be used if only one-shot access to the data is required. Invocation of this method should be cheap on memory even for large XML documents and/or tables. Invocation is synchronous, so the method only returns when the streaming has been done (successfully or otherwise).Note that only table metadata that precedes the TABLE element in the XML stream can be picked up when using this method. If there are any XML elements following the end of the TABLE whose content would normally show up in table metadata, it will be ignored when using this method.
For more flexible streamed access to VOTable data, use a
TableContentHandler
.- Specified by:
streamStarTable
in interfaceuk.ac.starlink.table.TableBuilder
- Parameters:
istrm
- stream from which the VOTable document will be suppliedsink
- callback interface into which the table metadata and data will be dumpedindex
- if present, a string representation of the index of the table in the document to be read - "0" means the first one encountered, "1" means the second, etc. If it'snull
or not of numeric form the first table will be used- Throws:
IOException
-
canStream
public boolean canStream()- Specified by:
canStream
in classuk.ac.starlink.table.formats.DocumentedTableBuilder
-
docIncludesExample
public boolean docIncludesExample()- Specified by:
docIncludesExample
in interfaceuk.ac.starlink.table.formats.DocumentedIOHandler
-
getXmlDescription
- Specified by:
getXmlDescription
in interfaceuk.ac.starlink.table.Documented
-