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 |
|---|---|
java.lang.String |
exportValue(java.lang.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.
|
java.lang.Object |
importValue(java.lang.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(java.lang.String collStr,
int pos,
char character)
Deprecated.
since ages - not needed any more - to hook in tokenizing override
splitAndUnescape(String) instead! |
protected boolean |
isEmpty(java.lang.String collStr)
Checks if given expression is empty.
|
protected java.lang.String |
joinAndEscape(java.util.List strings)
Concats collection element strings into one string delimited by the configured delimiter.
|
protected boolean |
processItem(java.lang.String token,
Item forItem,
java.util.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(java.util.List<java.lang.String> expressions,
Item forItem,
java.util.BitSet doAppendSet,
java.util.Collection coll,
boolean allowNull)
Processes all expressions at once.
|
protected java.util.List<java.lang.String> |
splitAndUnescape(java.lang.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 java.lang.Object importValue(java.lang.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(java.lang.String token,
Item forItem,
java.util.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(java.util.List<java.lang.String> expressions,
Item forItem,
java.util.BitSet doAppendSet,
java.util.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 java.lang.String exportValue(java.lang.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(java.lang.String collStr)
collStr - collection expression to checkprotected java.lang.String joinAndEscape(java.util.List strings)
As default this simply calls CSVUtils.joinAndEscape(List, char[], char, boolean).
strings - the collection element stringsprotected java.util.List<java.lang.String> splitAndUnescape(java.lang.String valueExpr)
As default this calls simply CSVUtils.splitAndUnescape(String, char[], boolean).
valueExpr - the cell valueprotected char getCollectionValueDelimiter()
@Deprecated
protected final boolean isDelimiter(java.lang.String collStr,
int pos,
char character)
splitAndUnescape(String) instead!Copyright © 2018 SAP SE. All Rights Reserved.