Package org.teiid.spring.annotations
Annotation Type TextTable
-
@Target(TYPE) @Retention(RUNTIME) public @interface TextTable
Use this annotation on any Entity class, to read data from any flat file like CSV, fixed format etc.
For Example if you have a CSV file likeId, FirstName, LastName, Age 1, John, Doe, 20 2, Susan, Webber, 55 3, Mike, Smith, 34
@Entity @TextTable(file="/path/to/file.txt") public class Person { @Id private int id; @Column(name="FirstName") private String firstName; @Column(name="LastName") private String lastName; @Column(name="Age") private int age; ... }
You can define variety of other properties on this annotation to control headers, quoting, trimming and generating automatic identification numbers if your flat file does not have PK available.
For more information checkout TextTable in Teiid.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description String
delimiter
DELIMITER sets the field delimiter character to use.char
escape
ESCAPE sets the escape character to use if no quoting character is in use.int
header
HEADER specifies the text line number (counting every new line) on which the column names occur.boolean
notrim
Can be defined table or columns, NO TRIM specified on the TEXTTABLE, it will affect all column and header values.boolean
ordinal
On Column ONLY, this defines the column as ordinal identity column.char
quote
QUOTE sets the quote, or qualifier, character used to wrap field values.int
skip
SKIP specifies the number of text lines (counting every new line) to skip before parsing the contents.String
source
Source name; If overriding theFileConnectionFactory
bean then provide the name of the beanint
width
On Column ONLY, WIDTH indicates the fixed-width length of a column in characters - not bytes.
-
-
-
Element Detail
-
file
String file
On Class ONLY, defines the file to be read. Either relative to source's parent directory or absolute path- Returns:
- file name to read
-
-
-
delimiter
String delimiter
DELIMITER sets the field delimiter character to use. Defaults to ','- Returns:
- delimiter
- Default:
- ","
-
-
-
header
int header
HEADER specifies the text line number (counting every new line) on which the column names occur. If the HEADER option for a column is specified, then that will be used as the expected header name. All lines prior to the header will be skipped. If HEADER is specified, then the header line will be used to determine the TEXTTABLE column position by case-insensitive name matching. This is especially useful in situations where only a subset of the columns are needed. If the HEADER value is not specified, it defaults to 1. If HEADER is not specified, then columns are expected to match positionally with the text contents.- Returns:
- header row number
- Default:
- 1
-
-
-
source
String source
Source name; If overriding theFileConnectionFactory
bean then provide the name of the bean- Returns:
- source type
- Default:
- "file"
-
-
-
notrim
boolean notrim
Can be defined table or columns, NO TRIM specified on the TEXTTABLE, it will affect all column and header values. If NO TRIM is specified on a column, then the fixed or unqualified text value not be trimmed of leading and trailing white space.- Returns:
- true to not use trim on values; default true
- Default:
- true
-
-