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,SequenceIdTranslator,SingleValueTranslator
Base class of all value translator instances. These objects are used by
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidResets 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 AbstractValueTranslatorcreateTranslator(AttributeDescriptor attributeDescriptor, AtomicType targetType, List<AbstractDescriptor.ColumnParams>[] patternLists) static AbstractValueTranslatorcreateTranslator(AttributeDescriptor attributeDescriptor, CollectionType collectionType, List<AbstractDescriptor.ColumnParams>[] patternLists) static AbstractValueTranslatorcreateTranslator(ComposedType targetType, List<AbstractDescriptor.ColumnParams>[] patternLists) protected voidDeprecated.protected voidDeprecated.since ages - use logging methodCategory.error(Object)directlyabstract StringexportValue(Object value) Translates an attribute value for export usage.Returns the assignedStandardColumnDescriptorinstance.protected FlexibleSearchabstract ObjectimportValue(String valueExpr, Item toItem) Translates a tokenized csv value for import usage.protected voidDeprecated.since ages - use logging methodCategory.info(Object)directlyvoidinit(StandardColumnDescriptor descriptor) Called once per header creation to allow configuring this translator using column modifiers etc.protected booleanDeprecated.since ages - use logging methodCategory.isDebugEnabled()directlyprotected booleanDeprecated.since ages - use logging methodCategory.isInfoEnabled()directlyprotected voidsetEmpty()Sets the empty flag.protected voidsetError()Sets the unresolved flag.voidvalidate(StandardColumnDescriptor columnDescriptor) Validates the value translator once per header creation.protected voidDeprecated.since ages - use logging methodCategory.warn(Object)directlybooleanwasEmpty()Indicates that the last call toimportValue(String, Item)has produced an empty value in respect to the target attribute.booleanIndicates that the last call toimportValue(String, Item)orexportValue(Object)could not translate the value yet but may be tried later again.
-
Constructor Details
-
AbstractValueTranslator
public AbstractValueTranslator()
-
-
Method Details
-
createTranslator
public static AbstractValueTranslator createTranslator(ComposedType targetType, List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException - Throws:
HeaderValidationException
-
createTranslator
public static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, AtomicType targetType, List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException - Throws:
HeaderValidationException
-
createTranslator
public static AbstractValueTranslator createTranslator(AttributeDescriptor attributeDescriptor, CollectionType collectionType, List<AbstractDescriptor.ColumnParams>[] patternLists) throws HeaderValidationException - Throws:
HeaderValidationException
-
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
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
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.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.since ages - use logging methodCategory.debug(Object)directlyDebugs a message with the reader or the current logger instance.- Parameters:
msg- debug message
-
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.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.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.since ages - use logging methodCategory.error(Object)directlyLogs an error message with the reader or the current logger instance.- Parameters:
msg- error message
-
getColumnDescriptor
Returns the assignedStandardColumnDescriptorinstance.- Returns:
- StandardColumnDescriptor
- See Also:
-
importValue
public abstract Object importValue(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
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
nullas empty value.- Returns:
- true if last call of
importValue(String, Item)has produced an empty value, false otherwise
-
Category.debug(Object)directly