com.univocity.parsers.remote
Class RemoteEntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonParserSettings,G extends RemoteParserSettings,T extends RemoteFollower>

java.lang.Object
  extended by com.univocity.parsers.common.EntitySettings<C,S,G>
      extended by com.univocity.parsers.remote.RemoteEntitySettings<C,S,G,T>
Type Parameters:
C - the type of Context implementation supported by Processors of this entity.
S - an internal configuration object that extends from CommonParserSettings, and is used to manage configuration of elements shared with univocity-parsers
G - type of the global configuration class (an instance of RemoteEntitySettings, used to configure the parser (a concrete implementation of EntityParserInterface) and its entities.
All Implemented Interfaces:
Cloneable

public abstract class RemoteEntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonParserSettings,G extends RemoteParserSettings,T extends RemoteFollower>
extends EntitySettings<C,S,G>

Manages configuration options for individual entities of a RemoteEntityList. Settings that also exist in the parent RemoteParserSettings will be used by default but can be overridden for an individual entity.

Author:
uniVocity Software Pty Ltd - dev@univocity.com

Field Summary
protected  Map<String,T> followers
           
protected  Object owner
           
protected  Set<String> requestParameters
           
 
Fields inherited from class com.univocity.parsers.common.EntitySettings
name, parentEntity, parserSettings, processor
 
Constructor Summary
protected RemoteEntitySettings(String entityName, S entitySettings, RemoteEntitySettings parentEntity)
          Internal constructor to be invoked the subclasses of EntitySettings
 
Method Summary
protected  EntitySettings<C,S,G> clone()
           
 String getEmptyValue()
          Returns the value to be used when the content parsed for a field of some record evaluates to an empty String Defaults to null
abstract  Set<String> getFieldNames()
          Returns the name of all fields associated with a remote entity.
protected  S getInternalSettings()
          Returns the internal CommonSettings used
 Nesting getNesting()
          Returns the nesting strategy to apply to rows associated to a "parent" row, such as results parsed from a link accessed by a RemoteFollower.
protected  RemoteEntityList getParentEntityList()
          Returns the entity list that "owns" this entity.
 T getRemoteFollower(String followerName)
          Obtains a RemoteFollowers associated with this entity.
 Map<String,T> getRemoteFollowers()
          Returns a (unmodifiable) map of RemoteFollowers associated with this entity.
 void ignoreFollowingErrors(boolean ignoreLinkFollowingErrors)
          Configures the parser to ignore (or not) invalid, malformed or unavailable links when following urls to collect additional data associated to a current result.
 boolean isColumnReorderingEnabled()
          Identifies whether fields should be reordered when field selection methods such as EntitySettings.selectFields(String...) are used.
 boolean isIgnoreFollowingErrors()
          Returns a flag indicating whether the parser will ignore invalid, malformed or unavailable links when following urls to collect additional data associated to a current result.
abstract  void removeField(String fieldName)
          Removes a field from the entity.
 void setColumnReorderingEnabled(boolean columnReorderingEnabled)
          Defines whether fields should be reordered when field selection methods such as EntitySettings.selectFields(String...) are used.
 void setEmptyValue(String emptyValue)
          Defines the value to be used when the content parsed for a field of some record evaluates to an empty String Defaults to null
 void setNesting(Nesting combineLinkFollowingRows)
          Configures the nesting strategy to apply to rows associated to a "parent" row, such as results parsed from a link accessed by a RemoteFollower.
 
Methods inherited from class com.univocity.parsers.common.EntitySettings
createEmptyParserSettings, excludeFields, excludeFields, excludeIndexes, getEntityName, getErrorContentLength, getNullValue, getProcessor, getProcessorErrorHandler, getTrimLeadingWhitespaces, getTrimTrailingWhitespaces, isAutoConfigurationEnabled, isProcessorErrorHandlerDefined, runAutomaticConfiguration, selectFields, selectFields, selectIndexes, setAutoConfigurationEnabled, setErrorContentLength, setNullValue, setParent, setProcessor, setProcessorErrorHandler, setTrimLeadingWhitespaces, setTrimTrailingWhitespaces, toString, trimValues
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requestParameters

protected Set<String> requestParameters

followers

protected Map<String,T extends RemoteFollower> followers

owner

protected Object owner
Constructor Detail

RemoteEntitySettings

protected RemoteEntitySettings(String entityName,
                               S entitySettings,
                               RemoteEntitySettings parentEntity)
Internal constructor to be invoked the subclasses of EntitySettings

Parameters:
entityName - the entity name, usually provided by the user
entitySettings - 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

getNesting

public final Nesting getNesting()
Returns the nesting strategy to apply to rows associated to a "parent" row, such as results parsed from a link accessed by a RemoteFollower. Defaults to the parent entity's getNesting() or if undefined, the RemoteParserSettings.getNesting() setting.

Returns:
the nesting strategy to use when processing results associated with a parent row.

setNesting

public final void setNesting(Nesting combineLinkFollowingRows)
Configures the nesting strategy to apply to rows associated to a "parent" row, such as results parsed from a link accessed by a RemoteFollower. Defaults to the parent entity's getNesting() or if undefined, the RemoteParserSettings.getNesting() setting.

Parameters:
combineLinkFollowingRows - the nesting strategy to use when processing results associated with a parent row.

ignoreFollowingErrors

public final void ignoreFollowingErrors(boolean ignoreLinkFollowingErrors)
Configures the parser to ignore (or not) invalid, malformed or unavailable links when following urls to collect additional data associated to a current result. If set to false, the parser will throw an Exception when attempting to follow a link that is invalid, malformed or unavailable. If true, the parser will simply ignore the error and proceed. Defaults to true

Parameters:
ignoreLinkFollowingErrors - true if the parser will ignore errors when accessing linked page, false otherwise.

isIgnoreFollowingErrors

public final boolean isIgnoreFollowingErrors()
Returns a flag indicating whether the parser will ignore invalid, malformed or unavailable links when following urls to collect additional data associated to a current result. Defaults to true

Returns:
true if the parser is set to ignore errors when accessing linked page

getInternalSettings

protected S getInternalSettings()
Description copied from class: EntitySettings
Returns the internal CommonSettings used

Overrides:
getInternalSettings in class EntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonParserSettings,G extends RemoteParserSettings>
Returns:
the internal settings

getFieldNames

public abstract Set<String> getFieldNames()
Returns the name of all fields associated with a remote entity. The definition of fields and how they are populated is delegated to concrete implementations of this class.

Returns:
a unmodifiable, ordered LinkedHashSet of field names available from this entity.

removeField

public abstract void removeField(String fieldName)
Removes a field from the entity. Removed fields will not be used by the parser and any configuration associated with it will be lost.

Parameters:
fieldName - name of the field that should be be removed.

isColumnReorderingEnabled

public final boolean isColumnReorderingEnabled()
Identifies whether fields should be reordered when field selection methods such as EntitySettings.selectFields(String...) are used.

When enabled, each parsed record will contain values only for the selected columns. The values will be ordered according to the selection.

When disabled, each parsed record will contain values for all columns, in their original sequence. Fields which were not selected will contain null values, as defined in EntitySettings.getNullValue(). Defaults to true

Returns:
a flag indicating whether or not selected fields should be reordered

setColumnReorderingEnabled

public final void setColumnReorderingEnabled(boolean columnReorderingEnabled)
Defines whether fields should be reordered when field selection methods such as EntitySettings.selectFields(String...) are used.

When enabled, each parsed record will contain values only for the selected columns. The values will be ordered according to the selection.

When disabled, each parsed record will contain values for all columns, in their original sequence. Fields which were not selected will contain null values, as defined in EntitySettings.getNullValue(). Defaults to true

Parameters:
columnReorderingEnabled - the flag indicating whether or not selected fields should be reordered

getEmptyValue

public final String getEmptyValue()
Returns the value to be used when the content parsed for a field of some record evaluates to an empty String Defaults to null

Returns:
the value to be used instead of empty String (i.e. "") when the content of a field is empty.

setEmptyValue

public final void setEmptyValue(String emptyValue)
Defines the value to be used when the content parsed for a field of some record evaluates to an empty String Defaults to null

Parameters:
emptyValue - the value to be used instead of empty String (i.e. "") when the content of a field is empty.

getRemoteFollowers

public Map<String,T> getRemoteFollowers()
Returns a (unmodifiable) map of RemoteFollowers associated with this entity.

Returns:
the RemoteFollowers associated with this entity.

getParentEntityList

protected RemoteEntityList getParentEntityList()
Description copied from class: EntitySettings
Returns the entity list that "owns" this entity.

Overrides:
getParentEntityList in class EntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonParserSettings,G extends RemoteParserSettings>
Returns:
the parent entity list.

getRemoteFollower

public T getRemoteFollower(String followerName)
Obtains a RemoteFollowers associated with this entity.

Parameters:
followerName - name of the RemoteFollower to return
Returns:
the RemoteFollower associated with this entity, or null if not found.

clone

protected EntitySettings<C,S,G> clone()
Overrides:
clone in class EntitySettings<C extends com.univocity.parsers.common.Context,S extends com.univocity.parsers.common.CommonParserSettings,G extends RemoteParserSettings>


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.