Class MediaDataTranslator
- java.lang.Object
-
- de.hybris.platform.impex.jalo.translators.AbstractSpecialValueTranslator
-
- de.hybris.platform.impex.jalo.media.MediaDataTranslator
-
- All Implemented Interfaces:
SpecialValueTranslator
public class MediaDataTranslator extends AbstractSpecialValueTranslator
Special translator which allows to import data from a file to a media item or vice versa.
It holds aMediaDataHandlerfor each thread for import/export the data. So you always have to set such an handler before using the translator.
-
-
Constructor Summary
Constructors Constructor Description MediaDataTranslator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MediaDataHandlergetHandler()Gets the handler currently mapped to current thread.static booleanhasHandler()voidinit(SpecialColumnDescriptor columnDescriptor)Called once upon header creation to do some initial setup logic.java.lang.StringperformExport(Item processedItem)Called each time an item is exported using the enclosing header.voidperformImport(java.lang.String cellValue, Item processedItem)Called each time a non-empty cell value has to be imported.static voidsetMediaDataHandler(MediaDataHandler handler)Sets theMediaDataHandlerfor current thread.static voidunsetMediaDataHandler()Unsets the handler which was mapped to the current thread for import/export.voidvalidate(java.lang.String expr)Validates the special column definition.-
Methods inherited from class de.hybris.platform.impex.jalo.translators.AbstractSpecialValueTranslator
isEmpty
-
-
-
-
Method Detail
-
setMediaDataHandler
public static void setMediaDataHandler(MediaDataHandler handler)
Sets theMediaDataHandlerfor current thread. This handler will be used for import/export if called by this thread.
ATTENTION: An already set handler will be overwritten.- Parameters:
handler- the handler which will be set for current thread.
-
unsetMediaDataHandler
public static final void unsetMediaDataHandler()
Unsets the handler which was mapped to the current thread for import/export.
-
hasHandler
public static final boolean hasHandler()
-
getHandler
public static final MediaDataHandler getHandler()
Gets the handler currently mapped to current thread.- Returns:
- current handler mapped to current thread
-
init
public void init(SpecialColumnDescriptor columnDescriptor) throws HeaderValidationException
Description copied from interface:SpecialValueTranslatorCalled once upon header creation to do some initial setup logic.- Specified by:
initin interfaceSpecialValueTranslator- Overrides:
initin classAbstractSpecialValueTranslator- Parameters:
columnDescriptor- the newly created column descriptor- Throws:
HeaderValidationException- indicates that the column descriptor is not configured properly
-
validate
public void validate(java.lang.String expr) throws HeaderValidationExceptionDescription copied from interface:SpecialValueTranslatorValidates the special column definition.- Specified by:
validatein interfaceSpecialValueTranslator- Overrides:
validatein classAbstractSpecialValueTranslator- Parameters:
expr- the definition expression- Throws:
HeaderValidationException- if the expression is not valid
-
performExport
public java.lang.String performExport(Item processedItem) throws ImpExException
Description copied from interface:SpecialValueTranslatorCalled each time an item is exported using the enclosing header.- Specified by:
performExportin interfaceSpecialValueTranslator- Overrides:
performExportin classAbstractSpecialValueTranslator- Parameters:
processedItem- the item to export- Returns:
- the string representation of the value to export
- Throws:
ImpExException- indicates an export error
-
performImport
public void performImport(java.lang.String cellValue, Item processedItem) throws ImpExExceptionDescription copied from interface:SpecialValueTranslatorCalled each time a non-empty cell value has to be imported.- Specified by:
performImportin interfaceSpecialValueTranslator- Overrides:
performImportin classAbstractSpecialValueTranslator- Parameters:
cellValue- the cell value stringprocessedItem- the item to import the value for- Throws:
ImpExException- indicates an import error
-
-