|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.EntitySettings<C,S,G>
C - the type of Context implementation supported by Processors of this entity.S - internal implementation of a CommonSettings, used to manage configuration of elements shared
with univocity-parsersG - type of the global configuration class (an instance of EntityParserSettings, used to configure
the parser (a concrete implementation of EntityParserInterface) and its entities.public abstract class EntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonSettings,G extends EntityParserSettings>
Manages configuration options for individual entities of an EntityList. Settings that also exist in
the parent EntityParserSettings will be used by default but can be overridden for an individual entity.
EntityList,
EntityParserInterface,
EntityParserSettings| Field Summary | |
|---|---|
protected String |
name
|
protected EntitySettings |
parentEntity
|
protected G |
parserSettings
|
protected com.univocity.parsers.common.processor.core.Processor<C> |
processor
|
| Constructor Summary | |
|---|---|
protected |
EntitySettings(String name,
S internalSettings,
EntitySettings parentEntity)
Internal constructor to be invoked the subclasses of EntitySettings |
| Method Summary | ||
|---|---|---|
protected EntitySettings<C,S,G> |
clone()
|
|
protected static com.univocity.parsers.common.CommonParserSettings |
createEmptyParserSettings()
Utility method to create new, empty instances of CommonParserSettings. |
|
com.univocity.parsers.common.fields.FieldSet<Enum> |
excludeFields(Enum... columns)
Selects columns which will not be read/written, by their names |
|
com.univocity.parsers.common.fields.FieldSet<String> |
excludeFields(String... fieldNames)
Selects fields which will not be read/written, by their names |
|
com.univocity.parsers.common.fields.FieldSet<Integer> |
excludeIndexes(Integer... fieldIndexes)
Selects columns which will not be read/written, by their positions |
|
String |
getEntityName()
Returns the name of the HTMLEntity |
|
int |
getErrorContentLength()
Configures the parser/writer to limit the length of displayed contents being parsed/written in the exception message when an error occurs |
|
protected S |
getInternalSettings()
Returns the internal CommonSettings used |
|
String |
getNullValue()
Returns the String representation of a null value. |
|
protected EntityList |
getParentEntityList()
Returns the entity list that "owns" this entity. |
|
com.univocity.parsers.common.processor.core.Processor<C> |
getProcessor()
Returns the current implementation of Processor to be used to process rows generated for this
entity. |
|
|
getProcessorErrorHandler()
Returns the custom error handler to be used to capture and handle errors that might happen while processing records with a Processor
or a RowWriterProcessor (i.e. |
|
boolean |
getTrimLeadingWhitespaces()
Returns whether or not leading whitespaces from values being read/written should be trimmed (defaults to true) |
|
boolean |
getTrimTrailingWhitespaces()
Returns whether or not trailing whitespaces from values being read/written should be trimmed (defaults to true) |
|
boolean |
isAutoConfigurationEnabled()
Indicates whether this settings object can automatically derive configuration options. |
|
boolean |
isProcessorErrorHandlerDefined()
Returns a flag indicating whether or not a ProcessorErrorHandler has been defined through the use of
method setProcessorErrorHandler(ProcessorErrorHandler) |
|
protected void |
runAutomaticConfiguration()
Run automatic configuration for the internal settings. |
|
com.univocity.parsers.common.fields.FieldSet<Enum> |
selectFields(Enum... columns)
Selects a sequence of fields for reading/writing by their names |
|
com.univocity.parsers.common.fields.FieldSet<String> |
selectFields(String... fieldNames)
Selects a sequence of fields for reading/writing by their names. |
|
com.univocity.parsers.common.fields.FieldSet<Integer> |
selectIndexes(Integer... fieldIndexes)
Selects a sequence of fields for reading/writing by their positions. |
|
void |
setAutoConfigurationEnabled(boolean autoConfigurationEnabled)
Indicates whether this settings object can automatically derive configuration options. |
|
void |
setErrorContentLength(int errorContentLength)
Configures the parser/writer to limit the length of displayed contents being parsed/written in the exception message when an error occurs. |
|
void |
setNullValue(String nullValue)
Sets the String representation of a null value. |
|
protected void |
setParent(EntityList parentEntityList)
Used to "inherit" default settings of a parent EntityParserSettings. |
|
void |
setProcessor(com.univocity.parsers.common.processor.core.Processor<C> processor)
Defines an implementation of Processor to be used to process rows generated for this
entity. |
|
void |
setProcessorErrorHandler(com.univocity.parsers.common.ProcessorErrorHandler<? extends com.univocity.parsers.common.Context> processorErrorHandler)
Defines a custom error handler to capture and handle errors that might happen while processing records with a Processor
or a RowWriterProcessor (i.e. |
|
void |
setTrimLeadingWhitespaces(boolean trimLeadingWhitespaces)
Defines whether or not leading whitespaces from values being read/written should be trimmed (defaults to true) |
|
void |
setTrimTrailingWhitespaces(boolean trimTrailingWhitespaces)
Defines whether or not trailing whitespaces from values being read/written should be trimmed (defaults to true) |
|
String |
toString()
|
|
void |
trimValues(boolean trim)
Configures the parser/writer to trim/keep leading and trailing whitespaces around values This has the same effect as invoking both setTrimLeadingWhitespaces(boolean)
and setTrimTrailingWhitespaces(boolean) with the same value. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected G extends EntityParserSettings parserSettings
protected final String name
protected com.univocity.parsers.common.processor.core.Processor<C extends com.univocity.parsers.common.Context> processor
protected final EntitySettings parentEntity
| Constructor Detail |
|---|
protected EntitySettings(String name,
S internalSettings,
EntitySettings parentEntity)
EntitySettings
name - the entity name, usually provided by the userinternalSettings - an internal implementation of a CommonSettings, used to manage configuration
of elements shared with univocity-parsers.
Not meant to be exposed/accessed directly by users.parentEntity - parent entity to build settings on top of| Method Detail |
|---|
protected final void setParent(EntityList parentEntityList)
EntityParserSettings. Used internally in
in the constructor of EntityParserSettings (which is the global setting object itself).
parentEntityList - the parent EntityList who "owns" all entities and their EntitySettingsprotected static final com.univocity.parsers.common.CommonParserSettings createEmptyParserSettings()
CommonParserSettings. For internal use only.
CommonParserSettings class.public final String getNullValue()
String representation of a null value.
When reading, if the parser does not read any character from the input for a particular value, the nullValue
is used instead of an empty String
When writing, if the writer has a null object to write to the output, the nullValue is used instead
of an empty String
public final void setNullValue(String nullValue)
String representation of a null value.
When reading, if the parser does not read any character from the input for a particular value, the nullValue
is used instead of an empty String
When writing, if the writer has a null object to write to the output, the nullValue is used instead
of an empty String
nullValue - the String representation of a null valuepublic final com.univocity.parsers.common.fields.FieldSet<String> selectFields(String... fieldNames)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence provided represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting fields "H3" and "H1" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
fieldNames - The field names to read/write
public final com.univocity.parsers.common.fields.FieldSet<String> excludeFields(String... fieldNames)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence of non-excluded fields represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting fields "H3" and "H1" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
fieldNames - The field names to exclude from the parsing/writing process
public final com.univocity.parsers.common.fields.FieldSet<Integer> selectIndexes(Integer... fieldIndexes)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence provided represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting indexes "2" and "0" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
fieldIndexes - The indexes to read/write
public final com.univocity.parsers.common.fields.FieldSet<Integer> excludeIndexes(Integer... fieldIndexes)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence of non-excluded fields represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting fields by index, such as "2" and "0" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
fieldIndexes - indexes of columns to exclude from the parsing/writing process
public final com.univocity.parsers.common.fields.FieldSet<Enum> selectFields(Enum... columns)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence provided represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting fields "H3" and "H1" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
columns - The columns to read/write
public final com.univocity.parsers.common.fields.FieldSet<Enum> excludeFields(Enum... columns)
When reading, only the values of the selected columns will be parsed, and the content of the other columns ignored.
The resulting rows will be returned with the selected columns only, in the order specified. If you want to
obtain the original row format, with all columns included and nulls in the fields that have not been selected,
set setColumnReorderingEnabled(boolean) with false if available.
When writing, the sequence of non-excluded fields represents the expected format of the input rows. For example, headers can be "H1,H2,H3", but the input data is coming with values for two columns and in a different order, such as "V_H3, V_H1". Selecting fields "H3" and "H1" will allow the writer to write values in the expected locations. Using the given example, the output row will be generated as: "V_H1,null,V_H3"
columns - The columns to exclude from the parsing/writing process
public final boolean isAutoConfigurationEnabled()
BeanWriterProcessor where the bean class contains a
Headers annotation, or to enable header extraction when the bean class of a BeanProcessor has
attributes mapping to header names.
Defaults to true
true if the automatic configuration feature is enabled, false otherwisepublic final void setAutoConfigurationEnabled(boolean autoConfigurationEnabled)
BeanWriterProcessor where the bean class contains a
Headers annotation, or to enable header extraction when the bean class of a
BeanProcessor has attributes mapping to header names.
autoConfigurationEnabled - a flag to turn the automatic configuration feature on/off.public final <T extends com.univocity.parsers.common.Context> com.univocity.parsers.common.ProcessorErrorHandler<T> getProcessorErrorHandler()
Processor
or a RowWriterProcessor (i.e. non-fatal DataProcessingExceptions).
The parsing/writing process won't stop (unless the error handler rethrows the DataProcessingException
or manually stops the process).
T - the Context type provided by the parser implementation.
DataProcessingException.public final void setProcessorErrorHandler(com.univocity.parsers.common.ProcessorErrorHandler<? extends com.univocity.parsers.common.Context> processorErrorHandler)
Processor
or a RowWriterProcessor (i.e. non-fatal DataProcessingExceptions).
The parsing parsing/writing won't stop (unless the error handler rethrows the DataProcessingException
or manually stops the process).
processorErrorHandler - the callback error handler with custom code to manage occurrences of DataProcessingException.public final boolean isProcessorErrorHandlerDefined()
ProcessorErrorHandler has been defined through the use of
method setProcessorErrorHandler(ProcessorErrorHandler)
true if the parser/writer is configured to use a ProcessorErrorHandlerpublic final int getErrorContentLength()
If set to 0, then no exceptions will include the content being manipulated in their attributes,
and the "<omitted>" string will appear in error messages as the parsed/written content.
defaults to -1 (no limit)
public final void setErrorContentLength(int errorContentLength)
If set to 0, then no exceptions will include the content being manipulated in their attributes,
and the "<omitted>" string will appear in error messages as the parsed/written content.
defaults to -1 (no limit)
errorContentLength - maximum length of contents displayed in exception messages in case of errors
while parsing/writing.protected final void runAutomaticConfiguration()
protected S getInternalSettings()
CommonSettings used
public final String getEntityName()
public final String toString()
toString in class Objectpublic final com.univocity.parsers.common.processor.core.Processor<C> getProcessor()
Processor to be used to process rows generated for this
entity. If no processor has been defined, a NoopProcessor will be returned.
Processorcom.univocity.parsers.common.processorpublic final void setProcessor(com.univocity.parsers.common.processor.core.Processor<C> processor)
Processor to be used to process rows generated for this
entity.
processor - the Processor implementation.com.univocity.parsers.common.processorpublic final boolean getTrimTrailingWhitespaces()
true)
true if trailing whitespaces from values being read/written should be trimmed, false otherwisepublic final void setTrimTrailingWhitespaces(boolean trimTrailingWhitespaces)
true)
trimTrailingWhitespaces - flag indicating whether to remove trailing whitespaces from values being read/writtenpublic final boolean getTrimLeadingWhitespaces()
true)
true if leading whitespaces from values being read/written should be trimmed, false otherwisepublic final void setTrimLeadingWhitespaces(boolean trimLeadingWhitespaces)
true)
trimLeadingWhitespaces - flag indicating whether to remove leading whitespaces from values being read/writtenpublic final void trimValues(boolean trim)
setTrimLeadingWhitespaces(boolean)
and setTrimTrailingWhitespaces(boolean) with the same value.
trim - a flag indicating whether whitespaces should be removed around values parsed/written.protected EntityList getParentEntityList()
protected EntitySettings<C,S,G> clone()
clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||