olg.csv.bean.getter
Class AbstractGetter

Package class diagram package AbstractGetter
java.lang.Object
  extended by olg.csv.bean.getter.AbstractGetter
Direct Known Subclasses:
ConcateGetter, ConstantGetter, DefaultGetter

public abstract class AbstractGetter
extends Object

This class extracts a string from a row. In the bean reading process from a Strings List, this class is used to extract a string identified as property of the bean to produce.


Field Summary
private  String defaultValue
          This value is apply when this getter cannot extract String from a row.
private  AbstractStringFilter filter
          An optional filter.
 
Constructor Summary
AbstractGetter()
           
 
Method Summary
protected abstract  String doGet(Row line)
          Returns a String built from the given row.
 String get(Row line)
          Returns a String from a row. if a filter is defined, the string returned by doGet method is filtered.If this String is empty or null, the default value is returned.
static AbstractGetter getConcate(List<AbstractGetter> getters, String defaultValue)
          Returns a new instance of a concate Getter.
static AbstractGetter getConstant(String defaultValue)
          Returns a new instance of a constant Getter.
static AbstractGetter getDefault(String rang, String defaultValue)
          Returns a new instance of the default getter.
 String getDefaultValue()
          In case of this getter cannot extract a string from list, it's possible to apply a default value in replacement of.
 AbstractStringFilter getFilter()
          Returns the filter used to filter the String returned by doGet(Row).
 void setDefaultValue(String defaultValue)
          Sets the given value as default value.
 void setFilter(AbstractStringFilter filter)
          Sets the given filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultValue

private String defaultValue
This value is apply when this getter cannot extract String from a row. null as default value.


filter

private AbstractStringFilter filter
An optional filter.null as default value.

Constructor Detail

AbstractGetter

public AbstractGetter()
Method Detail

getDefaultValue

public final String getDefaultValue()
In case of this getter cannot extract a string from list, it's possible to apply a default value in replacement of.

Returns:
the default value
See Also:
doGet(Row)

setDefaultValue

public final void setDefaultValue(String defaultValue)
Sets the given value as default value.

Parameters:
defaultValue - the default value to use when the filtered "getted" string is null or empty.
See Also:
doGet(Row)

getFilter

public final AbstractStringFilter getFilter()
Returns the filter used to filter the String returned by doGet(Row).

Returns:
the filter.

setFilter

public final void setFilter(AbstractStringFilter filter)
Sets the given filter.

Parameters:
filter - the fitler.

doGet

protected abstract String doGet(Row line)
Returns a String built from the given row.

Parameters:
line - the row from which extract the string.
Returns:
a String built from the given row

get

public final String get(Row line)
Returns a String from a row. if a filter is defined, the string returned by doGet method is filtered.If this String is empty or null, the default value is returned.

throws an IllegalArgumentException When Error occurs if the given line is null.

Parameters:
line - the row.
Returns:
the string extracted from the row.

getDefault

public static final AbstractGetter getDefault(String rang,
                                              String defaultValue)
Returns a new instance of the default getter. This getter extracts the string at the given rank in the row.

Parameters:
rang - the cell number in the row. Must be greater or equals than 0 or conformed to the sheet cell number format.
defaultValue - default value to apply if the filtered String at the given rank is null or empty.
Returns:
the default getter.

getConcate

public static final AbstractGetter getConcate(List<AbstractGetter> getters,
                                              String defaultValue)
Returns a new instance of a concate Getter. This getter products a string based on concate strings issued of the givent Getters List.

Parameters:
getters - List of AbstractGetters which product a String from a Row. Must not be null or empty.
defaultValue - default value to apply if the filtered string from concate is null or empty.
Returns:
an instance of a concate getter.

getConstant

public static final AbstractGetter getConstant(String defaultValue)
Returns a new instance of a constant Getter. This getter always return the given value regardless of the row.

Parameters:
defaultValue - the value the getter returns
Returns:
an instance of a constant getter.


Copyright © 2014. All Rights Reserved.