@Target(value=TYPE) @Retention(value=RUNTIME) public @interface TextTable
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.Modifier and Type | Required Element and Description |
---|---|
String |
file
On Class ONLY, defines the file to be read.
|
Modifier and Type | Optional Element and 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.
|
public abstract String file
public abstract String delimiter
public abstract int header
public abstract int skip
public abstract char quote
public abstract char escape
public abstract String source
FileConnectionFactory
bean then
provide the name of the beanpublic abstract boolean notrim
public abstract boolean ordinal
Copyright © 2020. All rights reserved.