# Class AllWiseTableBuilder

java.lang.Object
uk.ac.starlink.ttools.example.AllWiseTableBuilder

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

Direct Known Subclasses:
  `AllWiseTableBuilder.Count, AllWiseTableBuilder.NoCount`

public class AllWiseTableBuilder extends Object implements uk.ac.starlink.table.TableBuilder
TableBuilder implementation for the ASCII files comprising the AllWise data release. At time of writing these files are available from http://irsadist.ipac.caltech.edu/wise-allwise/. The files are formatted as pipe-separated ASCII, and optionally compressed. Note that reading seems to be considerably faster for the gzip than for the bzip2 form of the input files (though the gzip ones are a bit bigger).

For FITS output (though not colfits) two passes through the input ASCII file are required, the first one (much faster) just to count the rows. There are therefore two variants of this input handler, one which does a row count and one which does not. If the row count is known, it would be possible to adapt this handler so you tell it the row count up front and only one pass is required.

Since:
  6 Feb 2014
Author:
  Mark Taylor

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`AllWiseTableBuilder.Count`
Input handler which reads AllWise ASCII files and does count the rows first.
`static class`
`AllWiseTableBuilder.NoCount`
Input handler which reads AllWise ASCII files and does not count the rows first.

## Constructor Summary

Constructors
Constructor
Description
`AllWiseTableBuilder()`
Default mode constructor.
`AllWiseTableBuilder(String name, boolean preCount)`
Configurable constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canImport(DataFlavor flavor)`
`static long`
`countLines(uk.ac.starlink.util.DataSource datsrc)`
Counts the lines in the ASCII file at the given location.
`String`
`getFormatName()`
`boolean`
`looksLikeFile(String location)`
`uk.ac.starlink.table.StarTable`
`makeStarTable(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy storagePolicy)`
`void`
`streamStarTable(InputStream in, uk.ac.starlink.table.TableSink sink, String pos)`

### Methods inherited from class Object

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

## Constructor Details

### AllWiseTableBuilder

public AllWiseTableBuilder()
Default mode constructor.

### AllWiseTableBuilder

public AllWiseTableBuilder(String name, boolean preCount)
Configurable constructor.

Parameters:
  `name` - handler name
  `preCount` - true to return a table that knows its row count

## Method Details

### canImport

public boolean canImport(DataFlavor flavor)

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

### getFormatName

public String getFormatName()

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

### looksLikeFile

public boolean looksLikeFile(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 IOException

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

### streamStarTable

public void streamStarTable(InputStream in, uk.ac.starlink.table.TableSink sink, String pos)

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

### countLines

public static long countLines(uk.ac.starlink.util.DataSource datsrc) throws IOException
Counts the lines in the ASCII file at the given location.

Parameters:
  `datsrc` - data source
Returns:
  number of '\n'-terminated lines in the file
Throws:
  `IOException`