public class DelimitedColumnEntityFormat extends Object implements EntityFormat
Delimited text column entity format.
Constructor and Description |
---|
DelimitedColumnEntityFormat() |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(String label,
TypedName<?> attr)
Add a column.
|
void |
addColumn(TypedName<?> attr)
Associate an attribute with the next column.
|
void |
addColumns(TypedName<?>... columns)
Add columns to a format.
|
void |
clearColumns()
Clear the columns configured for this format.
|
List<TypedName<?>> |
getColumnList()
Get the list of columns, if
addColumn(TypedName) has been used. |
String |
getDelimiter()
Get the delimiter for the entity format.
|
Class<? extends EntityBuilder> |
getEntityBuilder()
Get the entity builder class.
|
EntityType |
getEntityType()
Get the entity type.
|
int |
getHeaderLines()
Get the number of header lines to read.
|
LineEntityParser |
makeParser(List<String> header)
Create an entity parser for a file.
|
EntityBuilder |
newEntityBuilder()
Instantiate a new entity builder.
|
void |
setDelimiter(String delim)
Set the delimiter to use for this entity format.
|
void |
setEntityBuilder(Class<? extends EntityBuilder> builder)
Set the entity builder class.
|
void |
setEntityType(EntityType type)
Set the entity type.
|
void |
setHeader(boolean header)
Set whether to read a header.
|
void |
setHeaderLines(int lines)
Set the number of header lines to read.
|
com.fasterxml.jackson.databind.node.ObjectNode |
toJSON()
Create a JSON description of this entity format.
|
public String getDelimiter()
Get the delimiter for the entity format.
public void setDelimiter(String delim)
Set the delimiter to use for this entity format.
delim
- The delimiter to use.public void setHeader(boolean header)
Set whether to read a header.
header
- true
to read a header line from the file.public int getHeaderLines()
Get the number of header lines to read.
getHeaderLines
in interface EntityFormat
public void setHeaderLines(int lines)
Set the number of header lines to read. Setting this disables setHeader(boolean)
.
lines
- The number of header lines to read.public void setEntityType(EntityType type)
Set the entity type.
type
- The entity type.public EntityType getEntityType()
Get the entity type.
getEntityType
in interface EntityFormat
public void setEntityBuilder(Class<? extends EntityBuilder> builder)
Set the entity builder class.
builder
- The entity builder class.public Class<? extends EntityBuilder> getEntityBuilder()
Get the entity builder class.
public EntityBuilder newEntityBuilder()
Instantiate a new entity builder.
public void addColumn(@Nullable TypedName<?> attr)
Associate an attribute with the next column. The first time this is called it specifies the label for the first column. The second time this is called it specifies the second column label and so forth.
Once this method has been called, addColumn(String, TypedName)
cannot be called.
attr
- The attribute to add as a column, or null
to skip the next column.IllegalStateException
- if non-labeled columns have already been specified.public void addColumns(TypedName<?>... columns)
Add columns to a format. This is exactly equivalent to calling addColumn(TypedName)
for each column.
columns
- The columns to add.public List<TypedName<?>> getColumnList()
Get the list of columns, if addColumn(TypedName)
has been used.
IllegalStateException
- if addColumn(TypedName)
or addColumns(TypedName[])
have not been called.public void addColumn(String label, @Nullable TypedName<?> attr)
Add a column.
label
- The header label.attr
- The attribute to add as a column, or null
to skip the next column.IllegalStateException
- if non-labeled columns have already been specified.public void clearColumns()
Clear the columns configured for this format.
public com.fasterxml.jackson.databind.node.ObjectNode toJSON()
EntityFormat
Create a JSON description of this entity format.
toJSON
in interface EntityFormat
public LineEntityParser makeParser(List<String> header)
EntityFormat
Create an entity parser for a file.
makeParser
in interface EntityFormat
header
- The header lines.