Package uk.ac.starlink.votable

## Class FitsPlusTableBuilder

- java.lang.Object
- - uk.ac.starlink.votable.FitsPlusTableBuilder

All Implemented Interfaces:
  `uk.ac.starlink.table.MultiTableBuilder`, `uk.ac.starlink.table.TableBuilder`

    public class FitsPlusTableBuilder
    extends java.lang.Object
    implements uk.ac.starlink.table.TableBuilder, uk.ac.starlink.table.MultiTableBuilder

Table builder which can read files in 'fits-plus' format (as written by `FitsPlusTableWriter`). This looks for a primary header in the FITS file which contains the VOTMETA header (in fact it is quite inflexible about what it recognises as this format - see `isMagic(byte[])`) and tries to interpret the data array as a 1-d array of bytes representing the XML of a VOTable document. This VOTable document should have one or more TABLE elements with no DATA content - the table data is got from the extension extension HDUs, one per table, and they must be BINTABLE extensions matching the metadata described by the VOTable.

The point of all this is so that you can store VOTables in the efficient FITS format (it can be mapped if it's on local disk, which makes table creation practically instantaneous, even for random access) without sacrificing any of the metadata that you want to encode in VOTable format.

Since:
  27 Aug 2004
Author:
  Mark Taylor (Starlink)
See Also:
  `FitsPlusTableWriter`

### Constructor Summary

Constructors
`FitsPlusTableBuilder()` Default constructor.
`FitsPlusTableBuilder​(uk.ac.starlink.fits.WideFits wide)` Constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `canImport​(java.awt.datatransfer.DataFlavor flavor)` Returns `true` for a flavor with the MIME type "application/fits".
`java.lang.String` `getFormatName()`
`static boolean` `isMagic​(byte[] buffer)` Tests whether a given buffer contains bytes which might be the first few bytes of a FitsPlus table.
`boolean` `looksLikeFile​(java.lang.String location)`
`uk.ac.starlink.table.StarTable` `makeStarTable​(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy storagePolicy)`
`uk.ac.starlink.table.TableSequence` `makeStarTables​(uk.ac.starlink.util.DataSource datsrc, uk.ac.starlink.table.StoragePolicy storagePolicy)`
`void` `streamStarTable​(java.io.InputStream in, uk.ac.starlink.table.TableSink sink, java.lang.String pos)`

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

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

### Constructor Detail

#### FitsPlusTableBuilder

    public FitsPlusTableBuilder()

Default constructor.

#### FitsPlusTableBuilder

    public FitsPlusTableBuilder​(uk.ac.starlink.fits.WideFits wide)

Constructor.

Parameters:
  `wide` - convention for representing extended columns; use null to avoid use of extended columns

### Method Detail

#### getFormatName

    public java.lang.String getFormatName()

Specified by:
  `getFormatName` in interface `uk.ac.starlink.table.TableBuilder`

#### looksLikeFile

    public boolean looksLikeFile​(java.lang.String location)

Specified by:
  `looksLikeFile` in interface `uk.ac.starlink.table.TableBuilder`

#### makeStarTable

    public uk.ac.starlink.table.StarTable makeStarTable​(uk.ac.starlink.util.DataSource datsrc,
                                                        boolean wantRandom,
                                                        uk.ac.starlink.table.StoragePolicy storagePolicy)
                                                 throws java.io.IOException

Specified by:
  `makeStarTable` in interface `uk.ac.starlink.table.TableBuilder`
Throws:
  `java.io.IOException`

#### makeStarTables

    public uk.ac.starlink.table.TableSequence makeStarTables​(uk.ac.starlink.util.DataSource datsrc,
                                                             uk.ac.starlink.table.StoragePolicy storagePolicy)
                                                      throws java.io.IOException

Specified by:
  `makeStarTables` in interface `uk.ac.starlink.table.MultiTableBuilder`
Throws:
  `java.io.IOException`

#### streamStarTable

    public void streamStarTable​(java.io.InputStream in,
                                uk.ac.starlink.table.TableSink sink,
                                java.lang.String pos)
                         throws java.io.IOException

Specified by:
  `streamStarTable` in interface `uk.ac.starlink.table.TableBuilder`
Throws:
  `java.io.IOException`

#### canImport

    public boolean canImport​(java.awt.datatransfer.DataFlavor flavor)

Returns `true` for a flavor with the MIME type "application/fits".

Specified by:
  `canImport` in interface `uk.ac.starlink.table.TableBuilder`

#### isMagic

    public static boolean isMagic​(byte[] buffer)

Tests whether a given buffer contains bytes which might be the first few bytes of a FitsPlus table. The criterion is that it looks like the start of a FITS header, and the first few cards look roughly like this:

         SIMPLE  =              T
         BITPIX  =              8
         NAXIS   =              1
         NAXIS1  =            ???
         VOTMETA =              T

Parameters:
  `buffer` - byte buffer containing leading few bytes of data
Returns:
  true if it looks like a FitsPlus file