public abstract class RowEvaluatorTableBuilder extends DocumentedTableBuilder
Modifier | Constructor and Description |
---|---|
protected |
RowEvaluatorTableBuilder(String[] extensions)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(DataFlavor flavor)
Indicates whether this builder is able to turn a resource of
media type indicated by
flavor into a table. |
boolean |
canStream()
Indicates whether this handler can read tables from a stream.
|
RowEvaluator.Decoder<?>[] |
getDecoders()
Returns the list of permitted decoders.
|
int |
getMaxSample()
Returns the maximum number of rows that will be sampled to determine
column data types.
|
void |
setDecoderExcludeList(String excludeSemicolonList)
Sets the list of decoders from a user-supplied string naming
decoders not to use.
|
void |
setDecoders(RowEvaluator.Decoder<?>[] decoders)
Sets the list of permitted decoders.
|
void |
setMaxSample(int maxSample)
Sets the maximum number of rows that will be sampled to determine
column data types.
|
void |
streamStarTable(InputStream in,
TableSink sink,
String pos)
Reads a table from an input stream and writes it a row at a time
to a sink.
|
getExtensions, looksLikeFile
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormatName, makeStarTable
docIncludesExample, matchesExtension, readText, toLink
getXmlDescription
protected RowEvaluatorTableBuilder(String[] extensions)
extensions
- list of lower-cased filename extensions,
excluding the '.' characterpublic boolean canImport(DataFlavor flavor)
TableBuilder
flavor
into a table.
It should return true
if it thinks that its
TableBuilder.streamStarTable(java.io.InputStream, uk.ac.starlink.table.TableSink, java.lang.String)
method stands a reasonable chance of
successfully constructing a StarTable
from a
DataSource
whose input stream is described by the
DataFlavor
flavor
.
It will typically make this determination based on the flavor's
MIME type.
This method should only return true
if the flavor looks like
it is targeted at this builder; for instance a builder which
uses a text-based format should return false for a
flavor which indicates a MIME type of text/plain
.
This method is used in supporting drag and drop functionality
(see StarTableFactory.canImport(java.awt.datatransfer.DataFlavor[])
).
flavor
- the DataFlavor whose suitability as stream input
is to be assessedtrue
iff this builder reckons it stands a good
chance of turning a stream of type flavor
into a
StarTable
public void streamStarTable(InputStream in, TableSink sink, String pos) throws TableFormatException
TableBuilder
TableFormatException
.
The input stream should be prepared for use prior to calling
this method, so implementations should not in general attempt to
decompress or buffer istrm
.
in
- input stream containing table datasink
- destination of the tablepos
- position identifier describing the location of the
table within the stream;
see DataSource.getPosition()
(may be null)TableFormatException
- if the table can't be streamed or
the data is malformedpublic boolean canStream()
DocumentedTableBuilder
canStream
in class DocumentedTableBuilder
@ConfigMethod(property="maxSample", doc="<p>Controls how many rows of the input file are sampled\nto determine column datatypes.\nThis file format provides no header information about\ncolumn type, so the handler has to look at the column data\nto see what type of value appears to be present\nin each column, before even starting to read the data in.\nBy default it goes through the whole table when doing this,\nwhich can be time-consuming for large tables.\nIf this value is set, it limits the number of rows\nthat are sampled in this data characterisation pass,\nwhich can reduce read time substantially.\nHowever, if values near the end of the table differ\nin apparent type from those near the start,\nit can also result in getting the datatypes wrong.\n</p>", usage="<int>", example="100000", sequence=10) public void setMaxSample(int maxSample)
maxSample
- maximum number of rows sampled;
if <=0, all rows are sampledpublic int getMaxSample()
public void setDecoders(RowEvaluator.Decoder<?>[] decoders)
Note the order of the supplied decoder list is significant; a type earlier in the list will be preferred over one later in the list where the data is consistent with both.
In case of no match, a string decoder will be used, even if it does not appear in the supplied list.
decoders
- decoders that may be used to interpret CSV columnspublic RowEvaluator.Decoder<?>[] getDecoders()
@ConfigMethod(property="notypes", doc="<p>Specifies a semicolon-separated list of names for datatypes that will <em>not</em> appear in the columns of the table as read. Type names that can be excluded are <code>blank</code>, <code>boolean</code>, <code>short</code>, <code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>, <code>date</code>, <code>hms</code> and <code>dms</code>. So if you want to make sure that all integer and floating-point columns are 64-bit (i.e. <code>long</code> and <code>double</code> respectively) you can set this value to \"<code>short;int;float</code>\".</p>", usage="<type>[;<type>...]", example="short;float", sequence=11) public void setDecoderExcludeList(String excludeSemicolonList)
excludeSemicolonList
- semicolon-separated list of decoder
names not to useCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.