public abstract class AbstractValueTranslator
extends java.lang.Object
StandardColumnDescriptor to translate a cell into attribute value(s) and
back again.
To signal that a value could not be translated properly (but may be tried again later) use setError(). This
way the surrounding algorithm merely marks the row as unresolved and tries to translate it in a second pass instead
of raising a error directly. Be sure to call clearStatus() at the beginning of each new translation.
| Constructor and Description |
|---|
AbstractValueTranslator() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearStatus()
Resets the empty and unresolved flag.
Unresolved flag says that the last imported value was unresolved. Empty flag says that the last imported value was empty. |
static AbstractValueTranslator |
createTranslator(AttributeDescriptor attributeDescriptor,
AtomicType targetType,
java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) |
static AbstractValueTranslator |
createTranslator(AttributeDescriptor attributeDescriptor,
CollectionType collectionType,
java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) |
static AbstractValueTranslator |
createTranslator(ComposedType targetType,
java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) |
protected void |
debug(java.lang.String msg)
Deprecated.
since ages - use logging method
Logger#debug(Object) directly |
protected void |
error(java.lang.String msg)
Deprecated.
since ages - use logging method
Logger#error(Object) directly |
abstract java.lang.String |
exportValue(java.lang.Object value)
Translates an attribute value for export usage.
|
StandardColumnDescriptor |
getColumnDescriptor()
Returns the assigned
StandardColumnDescriptor instance. |
protected FlexibleSearch |
getFlexibleSearch() |
abstract java.lang.Object |
importValue(java.lang.String valueExpr,
Item toItem)
Translates a tokenized csv value for import usage.
|
protected void |
info(java.lang.String msg)
Deprecated.
since ages - use logging method
Logger#info(Object) directly |
void |
init(StandardColumnDescriptor descriptor)
Called once per header creation to allow configuring this translator using column modifiers etc.
|
protected boolean |
isDebugEnabled()
Deprecated.
since ages - use logging method
Logger#isDebugEnabled() directly |
protected boolean |
isInfoEnabled()
Deprecated.
since ages - use logging method
Logger#isInfoEnabled() directly |
protected void |
setEmpty()
Sets the empty flag.
|
protected void |
setError()
Sets the unresolved flag.
|
void |
validate(StandardColumnDescriptor columnDescriptor)
Validates the value translator once per header creation.
|
protected void |
warn(java.lang.String msg)
Deprecated.
since ages - use logging method
Logger#warn(Object) directly |
boolean |
wasEmpty()
Indicates that the last call to
importValue(String, Item) has produced an empty value in respect to the
target attribute. |
boolean |
wasUnresolved()
Indicates that the last call to
importValue(String, Item) or exportValue(Object) could not
translate the value yet but may be tried later again. |
public static AbstractValueTranslator createTranslator(ComposedType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
HeaderValidationExceptionpublic static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, AtomicType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
HeaderValidationExceptionpublic static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, CollectionType collectionType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
HeaderValidationExceptionprotected FlexibleSearch getFlexibleSearch()
protected void clearStatus()
protected void setError()
protected void setEmpty()
public void validate(StandardColumnDescriptor columnDescriptor) throws HeaderValidationException
columnDescriptor - descriptor where the value to translate belongs toHeaderValidationException - validation has thrown errorspublic void init(StandardColumnDescriptor descriptor)
descriptor - descriptor where the value to translate belongs to@Deprecated protected boolean isDebugEnabled()
Logger#isDebugEnabled() directly@Deprecated protected void debug(java.lang.String msg)
Logger#debug(Object) directlymsg - debug message@Deprecated protected boolean isInfoEnabled()
Logger#isInfoEnabled() directly@Deprecated protected void info(java.lang.String msg)
Logger#info(Object) directlymsg - info message@Deprecated protected void warn(java.lang.String msg)
Logger#warn(Object) directlymsg - warn message@Deprecated protected void error(java.lang.String msg)
Logger#error(Object) directlymsg - error messagepublic StandardColumnDescriptor getColumnDescriptor()
StandardColumnDescriptor instance.init(StandardColumnDescriptor columnDescriptor )public abstract java.lang.Object importValue(java.lang.String valueExpr,
Item toItem)
throws JaloInvalidParameterException
valueExpr - expression to translatetoItem - the target item in case it already exist, null otherwise (for partOf attributes!)JaloInvalidParameterException - value can not be translated with this translator or is invalidpublic abstract java.lang.String exportValue(java.lang.Object value)
throws JaloInvalidParameterException
value - value to translateJaloInvalidParameterException - value can not be translated with this translator or is invalidpublic boolean wasUnresolved()
importValue(String, Item) or exportValue(Object) could not
translate the value yet but may be tried later again.
This applies mostly to importing item references which require the referenced item to be created first .
public boolean wasEmpty()
importValue(String, Item) has produced an empty value in respect to the
target attribute.
E.g. collection attributes may consider empty collections as empty value contrary to single valued attributes
which will only see null as empty value.
importValue(String, Item) has produced an empty value, false otherwiseCopyright © 2018 SAP SE. All Rights Reserved.