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 like
     
     Id, FirstName, LastName, Age
     1, John, Doe, 20
     2, Susan, Webber, 55
     3, Mike, Smith, 34
     
     
    You can parse and read the contents of this file into an entity by defining this annotation on a Entity class like
     
     @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;
        ...
     }
     
     
    Note: the getters and setter are omitted for brevity.
    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.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String file
      On Class ONLY, defines the file to be read.
    • 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 the FileConnectionFactory bean then provide the name of the bean
      int 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
      • skip

        int skip
        SKIP specifies the number of text lines (counting every new line) to skip before parsing the contents. HEADER may still be specified with SKIP.
        Returns:
        number of lines to skip
        Default:
        0
      • quote

        char quote
        QUOTE sets the quote, or qualifier, character used to wrap field values. Defaults to '"'.+
        Returns:
        char to use as quote
        Default:
        '\"'
      • escape

        char escape
        ESCAPE sets the escape character to use if no quoting character is in use. This is used in situations where the delimiter or new line characters are escaped with a preceding character, e.g. \,
        Returns:
        escape char
        Default:
        '\\'
      • source

        String source
        Source name; If overriding the FileConnectionFactory 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
      • ordinal

        boolean ordinal
        On Column ONLY, this defines the column as ordinal identity column. The data type must be integer. A FOR ORDINALITY column is typed as integer and will return the 1-based item number as its value.
        Returns:
        true if column is like PK/identity column
        Default:
        false
      • width

        int width
        On Column ONLY, WIDTH indicates the fixed-width length of a column in characters - not bytes. With the default ROW DELIMITER, a CR NL sequence counts as a single character.
        Returns:
        for fixed with, width of column
        Default:
        0