public class DelimitedColumnEntityFormat extends java.lang.Object implements EntityFormat
Delimited text column entity format.
Constructor and Description |
---|
DelimitedColumnEntityFormat() |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(java.lang.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.
|
static DelimitedColumnEntityFormat |
fromJSON(java.lang.String name,
java.lang.ClassLoader loader,
com.fasterxml.jackson.databind.JsonNode json) |
AttributeSet |
getAttributes()
Get the set of attributes entities from format may have, if known.
|
long |
getBaseId()
Get the base entity ID for this source.
|
java.util.List<TypedName<?>> |
getColumnList()
Get the list of columns, if
addColumn(TypedName) has been used. |
java.lang.String |
getDelimiter()
Get the delimiter for the entity format.
|
java.lang.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(java.util.List<java.lang.String> header)
Create an entity parser for a file.
|
EntityBuilder |
newEntityBuilder()
Instantiate a new entity builder.
|
void |
setBaseId(long base)
Set the base entity ID for this source.
|
void |
setDelimiter(java.lang.String delim)
Set the delimiter to use for this entity format.
|
void |
setEntityBuilder(java.lang.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.
|
java.lang.String |
toString() |
public java.lang.String getDelimiter()
Get the delimiter for the entity format.
public void setDelimiter(java.lang.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 long getBaseId()
Get the base entity ID for this source.
public void setBaseId(long base)
Set the base entity ID for this source. If an entity column is not defined, then the line number will be added to this value to obtain a synthetic ID.
base
- The base entity ID.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(java.lang.Class<? extends EntityBuilder> builder)
Set the entity builder class.
builder
- The entity builder class.public java.lang.Class<? extends EntityBuilder> getEntityBuilder()
Get the entity builder class.
getEntityBuilder
in interface EntityFormat
@Nullable public AttributeSet getAttributes()
EntityFormat
Get the set of attributes entities from format may have, if known.
getAttributes
in interface EntityFormat
null
if that information is not known.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.java.lang.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 java.util.List<TypedName<?>> getColumnList()
Get the list of columns, if addColumn(TypedName)
has been used.
java.lang.IllegalStateException
- if addColumn(TypedName)
or addColumns(TypedName[])
have not been called.public void addColumn(java.lang.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.java.lang.IllegalStateException
- if non-labeled columns have already been specified.public void clearColumns()
Clear the columns configured for this format.
public java.lang.String toString()
toString
in class java.lang.Object
public com.fasterxml.jackson.databind.node.ObjectNode toJSON()
EntityFormat
Create a JSON description of this entity format.
toJSON
in interface EntityFormat
public static DelimitedColumnEntityFormat fromJSON(java.lang.String name, java.lang.ClassLoader loader, com.fasterxml.jackson.databind.JsonNode json)
public LineEntityParser makeParser(java.util.List<java.lang.String> header)
EntityFormat
Create an entity parser for a file.
makeParser
in interface EntityFormat
header
- The header lines.