* @return the value that corresponds to the provided string representation
*/
protected Object getValueFromStringRep(Iterator sourceIterator, Iterator fullSourceIterator,
Map repToValueMap, String rep) {
Object value = null;
DataSqueezer squeezer = getDataSqueezer();
// Check if the string rep is empty. If so, just return the default value.
if (rep == null || rep.length() == 0)
return getDefaultValue();
// If required, find a value with an equivalent string representation and return it
boolean match = getMatch();
if (match) {
value = findValueWithStringRep(sourceIterator, fullSourceIterator, repToValueMap, rep, COMPLETE_REP_SOURCE);
if (value != null)
return value;
}
// Matching of the string representation was not successful or was disabled.
// Use the standard approaches to obtain the value from the rep.
char desc = rep.charAt(0);
String squeezed = rep.substring(1);
switch (desc) {
case DESC_VALUE:
// If the string rep is just the value itself, unsqueeze it
value = squeezer.unsqueeze(squeezed);
break;
case DESC_PRIMARY_KEY:
// Perform keyExpression match if not already attempted
if (!match && getKeyExpression() != null)
value = findValueWithStringRep(sourceIterator, fullSourceIterator, repToValueMap, rep, KEY_EXPRESSION_REP_SOURCE);
// If 'converter' is defined, try to perform conversion from primary key to value
if (value == null) {
IPrimaryKeyConverter converter = getConverter();
if (converter != null) {
Object pk = squeezer.unsqueeze(squeezed);
value = converter.getValue(pk);
}
}
break;
}