public final class DelimitedColumnEventFormat extends Object implements EventFormat
Constructor and Description |
---|
DelimitedColumnEventFormat(EventTypeDefinition etd) |
Modifier and Type | Method and Description |
---|---|
static DelimitedColumnEventFormat |
create(EventTypeDefinition etd)
Create a new delimited column format.
|
static DelimitedColumnEventFormat |
create(String typeName)
Create a new delimited column format from a named type.
|
static DelimitedColumnEventFormat |
create(String typeName,
ClassLoader loader)
Create a new delimited column format from a named type.
|
String |
getDelimiter() |
EventTypeDefinition |
getEventTypeDefinition() |
List<Field> |
getFields()
Get the field list.
|
int |
getHeaderLines()
Get the number of header lines to skip in the file.
|
Object |
newContext()
Create a new context that may speed up parsing.
|
Event |
parse(String line)
Parse a line into an event.
|
Event |
parse(String line,
Object context)
Parse using a context.
|
DelimitedColumnEventFormat |
setDelimiter(String delim) |
DelimitedColumnEventFormat |
setFields(Field... fields)
Set the fields to be parsed.
|
DelimitedColumnEventFormat |
setFields(List<Field> fields)
Set the fields to be parsed.
|
DelimitedColumnEventFormat |
setHeaderLines(int lines)
Set the number of lines to skip before reading events.
|
@Inject public DelimitedColumnEventFormat(@Nonnull EventTypeDefinition etd)
@Nonnull public static DelimitedColumnEventFormat create(@Nonnull EventTypeDefinition etd)
etd
- The event type definition.@Nonnull public static DelimitedColumnEventFormat create(String typeName)
typeName
- The name of the type definition.IllegalArgumentException
- if the specified type cannot be found.@Nonnull public static DelimitedColumnEventFormat create(String typeName, ClassLoader loader)
typeName
- The name of the type definition.loader
- The class loader to load from.IllegalArgumentException
- if the specified type cannot be found.@Nonnull public EventTypeDefinition getEventTypeDefinition()
public DelimitedColumnEventFormat setDelimiter(@Nonnull String delim)
public int getHeaderLines()
EventFormat
getHeaderLines
in interface EventFormat
public DelimitedColumnEventFormat setHeaderLines(int lines)
lines
- The number of lines to skip.public DelimitedColumnEventFormat setFields(@Nonnull Field... fields)
fields
- The fields to be parsed by this format.public DelimitedColumnEventFormat setFields(@Nonnull List<Field> fields)
fields
- The fields to be parsed by this format.public Event parse(String line) throws InvalidRowException
EventFormat
parse
in interface EventFormat
line
- The line to parse.InvalidRowException
public Object newContext()
EventFormat
EventFormat.parse(String, Object)
;
will usually be a builder to be reused.
The context will only ever be used from one thread.
newContext
in interface EventFormat
public Event parse(String line, Object context) throws InvalidRowException
EventFormat
parse
in interface EventFormat
line
- The line to parse.context
- The parsing context.InvalidRowException