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.ObjectBase class of all value translator instances. These objects are used byStandardColumnDescriptorto 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 voidclearStatus()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 AbstractValueTranslatorcreateTranslator(AttributeDescriptor attributeDescriptor, AtomicType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists)static AbstractValueTranslatorcreateTranslator(AttributeDescriptor attributeDescriptor, CollectionType collectionType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists)static AbstractValueTranslatorcreateTranslator(ComposedType targetType, java.util.List<AbstractDescriptor.ColumnParams>[] patternLists)protected voiddebug(java.lang.String msg)Deprecated.since ages - use logging methodCategory.debug(Object)directlyprotected voiderror(java.lang.String msg)Deprecated.since ages - use logging methodCategory.error(Object)directlyabstract java.lang.StringexportValue(java.lang.Object value)Translates an attribute value for export usage.StandardColumnDescriptorgetColumnDescriptor()Returns the assignedStandardColumnDescriptorinstance.protected FlexibleSearchgetFlexibleSearch()abstract java.lang.ObjectimportValue(java.lang.String valueExpr, Item toItem)Translates a tokenized csv value for import usage.protected voidinfo(java.lang.String msg)Deprecated.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 booleanisDebugEnabled()Deprecated.since ages - use logging methodCategory.isDebugEnabled()directlyprotected booleanisInfoEnabled()Deprecated.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 voidwarn(java.lang.String msg)Deprecated.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.booleanwasUnresolved()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 assignedStandardColumnDescriptorinstance.- Returns:
- StandardColumnDescriptor
- See Also:
init(StandardColumnDescriptor columnDescriptor)
-
importValue
public abstract java.lang.Object importValue(java.lang.String valueExpr, Item toItem) throws JaloInvalidParameterExceptionTranslates 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 JaloInvalidParameterExceptionTranslates 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
-
-