public class CollectionValueTranslator extends AbstractValueTranslator
| Constructor and Description |
|---|
CollectionValueTranslator(CollectionType targetType,
AbstractValueTranslator elementTranslator)
Instantiates a new collection translator instance for collections of type
targetType translatable by
elementTranslator. |
CollectionValueTranslator(CollectionType targetType,
AbstractValueTranslator elementTranslator,
char delimiter)
Not public constructors for testing purposes.
|
| Modifier and Type | Method and Description |
|---|---|
String |
exportValue(Object value)
Translates an attribute value for export usage.
|
protected char |
getCollectionValueDelimiter()
Returns the used element delimiter in collections for defined descriptor.
|
AbstractValueTranslator |
getElementTranslator()
Returns the used translator for an single element of collection.
|
Object |
importValue(String valueExpr,
Item forItem)
Translates a tokenized csv value for import usage.
|
void |
init(StandardColumnDescriptor descriptor)
Called once per header creation to allow configuring this translator using column modifiers etc.
|
protected boolean |
isDelimiter(String collStr,
int pos,
char character)
Deprecated.
not needed any more - to hook in tokenizing override
splitAndUnescape(String) instead! |
protected boolean |
isEmpty(String collStr)
Checks if given expression is empty.
|
protected String |
joinAndEscape(List strings)
Concats collection element strings into one string delimited by the configured delimiter.
|
protected boolean |
processItem(String token,
Item forItem,
Collection col,
boolean append,
boolean allowNull)
Translates given token to an value (item attribute) and adds or removes it to given list.
|
protected void |
processItems(List<String> expressions,
Item forItem,
BitSet doAppendSet,
Collection coll,
boolean allowNull)
Processes all expressions at once.
|
protected List<String> |
splitAndUnescape(String valueExpr)
Used for tokenizing the cell string into several collection element tokens.
|
void |
validate(StandardColumnDescriptor columnDescriptor)
Validates the value translator once per header creation.
|
clearStatus, createTranslator, createTranslator, createTranslator, debug, error, getColumnDescriptor, getFlexibleSearch, info, isDebugEnabled, isInfoEnabled, setEmpty, setError, warn, wasEmpty, wasUnresolvedpublic CollectionValueTranslator(CollectionType targetType, AbstractValueTranslator elementTranslator)
targetType translatable by
elementTranslator.targetType - type of collection elementselementTranslator - translator for translating elements of collectionpublic CollectionValueTranslator(CollectionType targetType, AbstractValueTranslator elementTranslator, char delimiter)
targetType - type of collection elementselementTranslator - translator for translating elements of collectiondelimiter - delimiter to use for element separationpublic void validate(StandardColumnDescriptor columnDescriptor) throws HeaderValidationException
AbstractValueTranslatorvalidate in class AbstractValueTranslatorcolumnDescriptor - descriptor where the value to translate belongs toHeaderValidationException - validation has thrown errorspublic void init(StandardColumnDescriptor descriptor)
AbstractValueTranslatorinit in class AbstractValueTranslatordescriptor - descriptor where the value to translate belongs topublic Object importValue(String valueExpr, Item forItem) throws JaloInvalidParameterException
AbstractValueTranslatorimportValue in class AbstractValueTranslatorvalueExpr - expression to translateforItem - the target item in case it already exist, null otherwise (for partOf attributes!)JaloInvalidParameterException - value can not be translated with this translator or is invalidprotected boolean processItem(String token, Item forItem, Collection col, boolean append, boolean allowNull)
token - string representation of one valueforItem - existing item if exist (can be null)col - existing collection for adding/removing (non null)append - add (true) or remove (false) attribute to/from existing collection?allowNull - if the string is translated to null, do you want to ignore it?protected void processItems(List<String> expressions, Item forItem, BitSet doAppendSet, Collection coll, boolean allowNull)
ItemExpressionTranslator.convertAllToJalo(Item, List, List) to perform a
single query fetching *all* items at once to avoid database roundtrip.expressions - forItem - doAppendSet - coll - allowNull - public String exportValue(Object value) throws JaloInvalidParameterException
AbstractValueTranslatorexportValue in class AbstractValueTranslatorvalue - value to translateJaloInvalidParameterException - value can not be translated with this translator or is invalidpublic AbstractValueTranslator getElementTranslator()
protected boolean isEmpty(String collStr)
collStr - collection expression to checkprotected String joinAndEscape(List strings)
As default this simply calls CSVUtils.joinAndEscape(List, char[], char, boolean).
strings - the collection element stringsprotected List<String> splitAndUnescape(String valueExpr)
As default this calls simply CSVUtils.splitAndUnescape(String, char[], boolean).
valueExpr - the cell valueprotected char getCollectionValueDelimiter()
@Deprecated protected final boolean isDelimiter(String collStr, int pos, char character)
splitAndUnescape(String) instead!Copyright © 2017 SAP SE. All Rights Reserved.