Class RowEvaluatorTableBuilder
- All Implemented Interfaces:
Documented, DocumentedIOHandler, TableBuilder
- Direct Known Subclasses:
AsciiTableBuilder, CsvTableBuilder
- Since:
- 24 Jun 2025
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRowEvaluatorTableBuilder(String[] extensions) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanImport(DataFlavor flavor) Indicates whether this builder is able to turn a resource of media type indicated byflavorinto a table.booleanIndicates whether this handler can read tables from a stream.RowEvaluator.Decoder<?>[]Returns the list of permitted decoders.intReturns the maximum number of rows that will be sampled to determine column data types.voidsetDecoderExcludeList(String excludeSemicolonList) Sets the list of decoders from a user-supplied string naming decoders not to use.voidsetDecoders(RowEvaluator.Decoder<?>[] decoders) Sets the list of permitted decoders.voidsetMaxSample(int maxSample) Sets the maximum number of rows that will be sampled to determine column data types.voidstreamStarTable(InputStream in, TableSink sink, String pos) Reads a table from an input stream and writes it a row at a time to a sink.Methods inherited from class DocumentedTableBuilder
getExtensions, looksLikeFileMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Documented
getXmlDescriptionMethods inherited from interface DocumentedIOHandler
docIncludesExample, readTextMethods inherited from interface TableBuilder
getFormatName, makeStarTable
-
Constructor Details
-
RowEvaluatorTableBuilder
Constructor.- Parameters:
extensions- list of lower-cased filename extensions, excluding the '.' character
-
-
Method Details
-
canImport
Description copied from interface:TableBuilderIndicates whether this builder is able to turn a resource of media type indicated byflavorinto a table. It should returntrueif it thinks that itsTableBuilder.streamStarTable(InputStream, TableSink, String)method stands a reasonable chance of successfully constructing aStarTablefrom aDataSourcewhose input stream is described by theDataFlavorflavor. It will typically make this determination based on the flavor's MIME type.This method should only return
trueif 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 oftext/plain.This method is used in supporting drag and drop functionality (see
StarTableFactory.canImport(java.awt.datatransfer.DataFlavor[])).- Parameters:
flavor- the DataFlavor whose suitability as stream input is to be assessed- Returns:
trueiff this builder reckons it stands a good chance of turning a stream of typeflavorinto aStarTable
-
streamStarTable
Description copied from interface:TableBuilderReads a table from an input stream and writes it a row at a time to a sink. Not all implementations will be able to do this; for instance, extracting the table from the data may be a two-pass process. Implementations which are unable to perform this function should throw aTableFormatException.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.- Parameters:
in- input stream containing table datasink- destination of the tablepos- position identifier describing the location of the table within the stream; seeDataSource.getPosition()(may be null)- Throws:
TableFormatException- if the table can't be streamed or the data is malformed
-
canStream
public boolean canStream()Description copied from class:DocumentedTableBuilderIndicates whether this handler can read tables from a stream.- Specified by:
canStreamin classDocumentedTableBuilder- Returns:
- true iff this handler can read from streams
-
setMaxSample
@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) Sets the maximum number of rows that will be sampled to determine column data types.- Parameters:
maxSample- maximum number of rows sampled; if <=0, all rows are sampled
-
getMaxSample
public int getMaxSample()Returns the maximum number of rows that will be sampled to determine column data types.- Returns:
- maximum number of rows sampled; if <=0, all rows are sampled
-
setDecoders
Sets the list of permitted 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.
- Parameters:
decoders- decoders that may be used to interpret CSV columns
-
getDecoders
Returns the list of permitted decoders.- Returns:
- decoders that may be used to interpret CSV columns
-
setDecoderExcludeList
@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) Sets the list of decoders from a user-supplied string naming decoders not to use.- Parameters:
excludeSemicolonList- semicolon-separated list of decoder names not to use
-