# Class JoinStarTable

java.lang.Object
uk.ac.starlink.table.AbstractStarTable
uk.ac.starlink.table.JoinStarTable

All Implemented Interfaces:
  `Closeable, AutoCloseable, StarTable`

public class JoinStarTable extends AbstractStarTable
Joins a number of tables to produce a single combined table. The result consists of all the constituent tables side by side, so has a number of columns equal to the sum of the numbers of columns in all the constituent tables. The nth row of this table is composed by appending the nth rows of all the constituent tables together in sequence. The number of rows is equal to the smallest of all the number of rows in the constituent tables (typically they will all have the same number of rows). Random access is only available if it is available in all the constituent tables.

While this table is active, the columns that the constituent tables had at the time of its construction shouldn't change their characteristics in incompatible ways or disappear. It's OK to add new columns though.

Author:
  Mark Taylor (Starlink)

## Constructor Summary

Constructors
Constructor
Description
`JoinStarTable(StarTable[] tables)`
Constructs a new JoinStarTable from a list of constituent tables.
`JoinStarTable(StarTable[] tables, JoinFixAction[] fixCols)`
Constructs a new JoinStarTable from a list of constituent tables, optionally renaming duplicated column names.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Closes all the constituent tables.
`Object`
`getCell(long irow, int icol)`
The `AbstractStarTable` implementation of this method throws an `UnsupportedOperationException`, since unless otherwise provided there is no random access.
`int`
`getColumnCount()`
Returns the number of columns in this table.
`ColumnInfo`
`getColumnInfo(int icol)`
Returns the object describing the data in a given column.
`Object[]`
`getRow(long irow)`
The `AbstractStarTable` implementation of this method constructs a row by repeated invocation of `AbstractStarTable.getCell(long, int)`.
`RowAccess`
`getRowAccess()`
Returns an object which can provide random access to this table's data, if random access is implemented.
`long`
`getRowCount()`
Returns the number of rows in this table, if known.
`RowSequence`
`getRowSequence()`
Returns an object which can iterate over all the rows in the table sequentially.
`List<StarTable>`
`getTables()`
Returns an unmodifiable list of the constituent tables providing the base data for this join table.
`boolean`
`isRandom()`
The `AbstractStarTable` implementation of this method returns `false`.

### Methods inherited from class AbstractStarTable

`checkedLongToInt, getColumnAuxDataInfos, getName, getParameters, getRowSplittable, getURL, setName, setParameters, setURL`

### Methods inherited from class Object

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

### Methods inherited from interface StarTable

`getParameterByName, setParameter`

## Constructor Details

### JoinStarTable

public JoinStarTable(StarTable[] tables, JoinFixAction[] fixCols)
Constructs a new JoinStarTable from a list of constituent tables, optionally renaming duplicated column names.

Parameters:
  `tables` - array of constituent table objects providing the data and metadata for a new joined table
  `fixCols` - actions to be taken in modifying column names from the originals (may be null for no action)

### JoinStarTable

public JoinStarTable(StarTable[] tables)
Constructs a new JoinStarTable from a list of constituent tables. No column renaming is done.

Parameters:
  `tables` - array of constituent table objects providing the data and metadata for a new joined table

## Method Details

### getTables

public List<StarTable> getTables()
Returns an unmodifiable list of the constituent tables providing the base data for this join table.

Returns:
  list of tables

### getColumnCount

public int getColumnCount()
Description copied from interface: `StarTable`
Returns the number of columns in this table.

Specified by:
  `getColumnCount` in interface `StarTable`
Specified by:
  `getColumnCount` in class `AbstractStarTable`
Returns:
  the number of columns

### getRowCount

public long getRowCount()
Description copied from interface: `StarTable`
Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.

Specified by:
  `getRowCount` in interface `StarTable`
Specified by:
  `getRowCount` in class `AbstractStarTable`
Returns:
  the number of rows, or -1

### getColumnInfo

public ColumnInfo getColumnInfo(int icol)
Description copied from interface: `StarTable`
Returns the object describing the data in a given column.

Specified by:
  `getColumnInfo` in interface `StarTable`
Specified by:
  `getColumnInfo` in class `AbstractStarTable`
Parameters:
  `icol` - the column for which header information is required
Returns:
  a ValueInfo object for column `icol`

### isRandom

public boolean isRandom()
Description copied from class: `AbstractStarTable`
The `AbstractStarTable` implementation of this method returns `false`.

Specified by:
  `isRandom` in interface `StarTable`
Overrides:
  `isRandom` in class `AbstractStarTable`
Returns:
  `true` if table random access methods are available

### getCell

public Object getCell(long irow, int icol) throws IOException
Description copied from class: `AbstractStarTable`
The `AbstractStarTable` implementation of this method throws an `UnsupportedOperationException`, since unless otherwise provided there is no random access.

Specified by:
  `getCell` in interface `StarTable`
Overrides:
  `getCell` in class `AbstractStarTable`
Parameters:
  `irow` - the index of the cell's row
  `icol` - the index of the cell's column
Returns:
  the contents of this cell
Throws:
  `IOException` - if there is an error reading the data

### getRow

public Object[] getRow(long irow) throws IOException
Description copied from class: `AbstractStarTable`
The `AbstractStarTable` implementation of this method constructs a row by repeated invocation of `AbstractStarTable.getCell(long, int)`.

Specified by:
  `getRow` in interface `StarTable`
Overrides:
  `getRow` in class `AbstractStarTable`
Parameters:
  `irow` - the index of the row to retrieve
Returns:
  an array of the objects in each cell in row `irow`
Throws:
  `IOException` - if there is an error reading the data

### getRowSequence

public RowSequence getRowSequence() throws IOException
Description copied from interface: `StarTable`
Returns an object which can iterate over all the rows in the table sequentially. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.

Specified by:
  `getRowSequence` in interface `StarTable`
Specified by:
  `getRowSequence` in class `AbstractStarTable`
Returns:
  new RowSequence
Throws:
  `IOException` - if there is an error providing access

### getRowAccess

public RowAccess getRowAccess() throws IOException
Description copied from interface: `StarTable`
Returns an object which can provide random access to this table's data, if random access is implemented. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.

Specified by:
  `getRowAccess` in interface `StarTable`
Overrides:
  `getRowAccess` in class `AbstractStarTable`
Returns:
  new RowAccess
Throws:
  `IOException` - if there is an error setting up access

### close

public void close() throws IOException
Closes all the constituent tables.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `StarTable`
Overrides:
  `close` in class `AbstractStarTable`
Throws:
  `IOException`