|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.starlink.table.StarTableFactory
Manufactures StarTable
objects from generic inputs.
This factory delegates the actual table creation to external
TableBuilder
objects; the generic input is passed to each one
in turn until one can make a StarTable from it, which object
is returned to the caller.
JDBC is also used to create tables under appropriate circumstances.
By default, if the corresponding classes are present, the following TableBuilders are installed:
The factory has a flag wantRandom which determines
whether random-access tables are
preferred results of the makeStarTable methods.
Setting this flag to true does not guarantee
that returned tables will have random access
(the Tables.randomTable(uk.ac.starlink.table.StarTable)
method should be used for that),
but this flag is passed to builders as a hint in case they know
how to make either random or non-random tables.
Constructor Summary | |
StarTableFactory()
Constructs a StarTableFactory with a default list of builders which will not preferentially construct random-access tables. |
|
StarTableFactory(boolean wantRandom)
Constructs a StarTableFactory with a default list of builders specifying whether it should preferentially construct random-access tables. |
Method Summary | |
boolean |
canImport(DataFlavor[] flavors)
Indicates whether a particular set of DataFlavor ojects offered by a Transferable
is suitable for attempting to turn the Transferable
into a StarTable. |
List |
getBuilders()
Gets the list of builders which actually do the table construction. |
JDBCHandler |
getJDBCHandler()
Returns the JDBC handler object used by this factory. |
StarTable |
makeStarTable(DataSource datsrc)
Constructs a readable StarTable from a DataSource object. |
StarTable |
makeStarTable(String location)
Constructs a readable StarTable from a location string, which can represent a filename or URL, including a jdbc: protocol URL if an appropriate JDBC driver is installed. |
StarTable |
makeStarTable(Transferable trans)
Constructs a StarTable from a Transferable object. |
StarTable |
makeStarTable(URL url)
Constructs a readable StarTable from a URL. |
void |
setBuilders(TableBuilder[] builders)
Sets the list of builders which actually do the table construction. |
void |
setJDBCHandler(JDBCHandler handler)
Sets the JDBC handler object used by this factory. |
void |
setWantRandom(boolean wantRandom)
Sets whether random-access tables are by preference created by this factory. |
boolean |
wantRandom()
Returns the wantRandom flag. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StarTableFactory()
public StarTableFactory(boolean wantRandom)
wantRandom
- whether random-access tables are preferredMethod Detail |
public List getBuilders()
TableBuilder
objects used to
construct StarTablespublic void setBuilders(TableBuilder[] builders)
builders
- an array of TableBuilder objects used to
construct StarTablespublic void setWantRandom(boolean wantRandom)
wantRandom
- whether, preferentially, this factory should
create random-access tablespublic boolean wantRandom()
public StarTable makeStarTable(DataSource datsrc) throws IOException
datsrc
- the data source containing the table data
UnknownTableFormatException
- if no handler capable of turning
datsrc into a table is available
IOException
- if one of the handlers encounters an error
constructing a tablepublic StarTable makeStarTable(String location) throws IOException
location
- the name of the table resource
UnknownTableFormatException
- if no handler capable of turning
location into a table is available
IOException
- if one of the handlers encounters an error
constructing a tablepublic StarTable makeStarTable(URL url) throws IOException
url
- the URL where the table lives
UnknownTableFormatException
- if no handler capable of turning
datsrc into a table is available
IOException
- if one of the handlers encounters an error
constructing a tablepublic StarTable makeStarTable(Transferable trans) throws IOException
Transferable
object.
In conjunction with a suitable TransferHandler
this makes it easy to accept drop of an object representing a table
which has been dragged from another application.
The implementation of this method currently tries the following on a given transferable to turn it into a table:
URL
object, passes that to the
URL factory method
InputStream
, turns it into a
DataSource
and passes that to the
DataSource constructor
This method doesn't throw an exception if it fails to come up with a StarTable, it merely returns null. This is because with many flavours to choose from, it's not clear which exception ought to get thrown.
trans
- the Transferable object to construct a table from
IOException
canImport(java.awt.datatransfer.DataFlavor[])
public boolean canImport(DataFlavor[] flavors)
Transferable
is suitable for attempting to turn the Transferable
into a StarTable.
Each of the builder objects is queried about whether it can
import the given flavour, and if one says it can, a true value
is returned. A true value is also returned if one of the flavours
has a representation class of URL
.
flavors
- the data flavours offeredpublic JDBCHandler getJDBCHandler()
public void setJDBCHandler(JDBCHandler handler)
handler
- the JDBC handler
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |