Class AbstractValueTranslator
- java.lang.Object
-
- de.hybris.platform.impex.jalo.translators.AbstractValueTranslator
-
- Direct Known Subclasses:
CollectionValueTranslator
,CopyrightTranslator
,FileLoaderValueTranslator
,MapValueTranslator
,MarketplaceBannerComponentTranslator
,MarketplaceCategoryTranslator
,MarketplaceConsignmentCodeTranslator
,MarketplaceProductsTranslator
,MarketplaceSlotsTranslator
,ObjectValueTranslator
,PriceTranslator
,SapRevenueCloudMarketIdTranslator
,SapRevenueCloudProductCodeTranslator
,SequenceIdTranslator
,SingleValueTranslator
public abstract class AbstractValueTranslator extends java.lang.Object
Base class of all value translator instances. These objects are used byStandardColumnDescriptor
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 callclearStatus()
at the beginning of each new translation.
-
-
Constructor Summary
Constructors Constructor Description AbstractValueTranslator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method 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 methodCategory.debug(Object)
directlyprotected void
error(java.lang.String msg)
Deprecated.since ages - use logging methodCategory.error(Object)
directlyabstract java.lang.String
exportValue(java.lang.Object value)
Translates an attribute value for export usage.StandardColumnDescriptor
getColumnDescriptor()
Returns the assignedStandardColumnDescriptor
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 methodCategory.info(Object)
directlyvoid
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 methodCategory.isDebugEnabled()
directlyprotected boolean
isInfoEnabled()
Deprecated.since ages - use logging methodCategory.isInfoEnabled()
directlyprotected 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 methodCategory.warn(Object)
directlyboolean
wasEmpty()
Indicates that the last call toimportValue(String, Item)
has produced an empty value in respect to the target attribute.boolean
wasUnresolved()
Indicates that the last call toimportValue(String, Item)
orexportValue(Object)
could not translate the value yet but may be tried later again.
-
-
-
Method Detail
-
createTranslator
public static AbstractValueTranslator createTranslator(ComposedType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
- Throws:
HeaderValidationException
-
createTranslator
public static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, AtomicType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
- Throws:
HeaderValidationException
-
createTranslator
public static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, CollectionType collectionType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException
- Throws:
HeaderValidationException
-
getFlexibleSearch
protected FlexibleSearch getFlexibleSearch()
-
clearStatus
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.
-
setError
protected void setError()
Sets the unresolved flag. Unresolved flag says that the last imported value was unresolved.
-
setEmpty
protected void setEmpty()
Sets the empty flag. Empty flag says that the last imported value was empty.
-
validate
public void validate(StandardColumnDescriptor columnDescriptor) throws HeaderValidationException
Validates the value translator once per header creation.- Parameters:
columnDescriptor
- descriptor where the value to translate belongs to- Throws:
HeaderValidationException
- validation has thrown errors
-
init
public void init(StandardColumnDescriptor descriptor)
Called once per header creation to allow configuring this translator using column modifiers etc.- Parameters:
descriptor
- descriptor where the value to translate belongs to
-
isDebugEnabled
@Deprecated protected boolean isDebugEnabled()
Deprecated.since ages - use logging methodCategory.isDebugEnabled()
directlyChecks if the debug method of the reader is enabled or if no reader set the logger will be checked.- Returns:
- is debug mode enabled?
-
debug
@Deprecated protected void debug(java.lang.String msg)
Deprecated.since ages - use logging methodCategory.debug(Object)
directlyDebugs a message with the reader or the current logger instance.- Parameters:
msg
- debug message
-
isInfoEnabled
@Deprecated protected boolean isInfoEnabled()
Deprecated.since ages - use logging methodCategory.isInfoEnabled()
directlyChecks if the info method of the reader is enabled or if no reader set the logger will be checked.- Returns:
- is info mode enabled?
-
info
@Deprecated protected void info(java.lang.String msg)
Deprecated.since ages - use logging methodCategory.info(Object)
directlyLogs an info message with the reader or the current logger instance.- Parameters:
msg
- info message
-
warn
@Deprecated protected void warn(java.lang.String msg)
Deprecated.since ages - use logging methodCategory.warn(Object)
directlyLogs an warn message with the reader or the current logger instance.- Parameters:
msg
- warn message
-
error
@Deprecated protected void error(java.lang.String msg)
Deprecated.since ages - use logging methodCategory.error(Object)
directlyLogs an error message with the reader or the current logger instance.- Parameters:
msg
- error message
-
getColumnDescriptor
public StandardColumnDescriptor getColumnDescriptor()
Returns the assignedStandardColumnDescriptor
instance.- Returns:
- StandardColumnDescriptor
- See Also:
init(StandardColumnDescriptor columnDescriptor)
-
importValue
public abstract java.lang.Object importValue(java.lang.String valueExpr, Item toItem) throws JaloInvalidParameterException
Translates a tokenized csv value for import usage. This means that the result object must be a instance of the expected attribute type.- Parameters:
valueExpr
- expression to translatetoItem
- the target item in case it already exist, null otherwise (for partOf attributes!)- Returns:
- Object translated value
- Throws:
JaloInvalidParameterException
- value can not be translated with this translator or is invalid
-
exportValue
public abstract java.lang.String exportValue(java.lang.Object value) throws JaloInvalidParameterException
Translates an attribute value for export usage. This means the attribute value must be transformed into a string which should be re-importable again.- Parameters:
value
- value to translate- Returns:
- String translated value
- Throws:
JaloInvalidParameterException
- value can not be translated with this translator or is invalid
-
wasUnresolved
public boolean wasUnresolved()
Indicates that the last call toimportValue(String, Item)
orexportValue(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 .
- Returns:
- true if the last value could not be translated yet
-
wasEmpty
public boolean wasEmpty()
Indicates that the last call toimportValue(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.- Returns:
- true if last call of
importValue(String, Item)
has produced an empty value, false otherwise
-
-