ExpressionOperatorConverterpublic class ExpressionOperatorConverter extends ObjectTypeConverter INTERNAL:
Used by function operators in deployment xml generation to accomodate custom functions.
There is no more validation on read because any custom function has to be accepted.
The custom function is assumed to be a normal prefix function. The first element in the
databaseStrings of the operator is in the format of databaseString(, e.g. AVG(. "(" will
be removed on write and attached back on read. |
Methods Summary |
---|
public java.lang.Object | convertDataValueToObjectValue(java.lang.Object fieldValue, oracle.toplink.essentials.sessions.Session session)INTERNAL:
Returns the corresponding attribute value for the specified field value.
Object attributeValue = null;
if (fieldValue == null) {
attributeValue = getFieldToAttributeValues().get(Helper.getNullWrapper());
} else {
try {
fieldValue = ((AbstractSession)session).getDatasourcePlatform().getConversionManager().convertObject(fieldValue, getFieldClassification());
} catch (ConversionException e) {
throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e);
}
attributeValue = getFieldToAttributeValues().get(fieldValue);
//Custom function. Create an operator for it.
if (attributeValue == null) {
attributeValue = ExpressionOperator.simpleFunction(0, (String)fieldValue);
}
}
return attributeValue;
| public java.lang.Object | convertObjectValueToDataValue(java.lang.Object attributeValue, oracle.toplink.essentials.sessions.Session session)INTERNAL:
Convert to the data value.
Object fieldValue;
if (attributeValue == null) {
fieldValue = getAttributeToFieldValues().get(Helper.getNullWrapper());
} else {
fieldValue = getAttributeToFieldValues().get(attributeValue);
if (fieldValue == null) {
//Custom function. Remove "(".
if (((ExpressionOperator)attributeValue).getDatabaseStrings() != null) {
String databaseString = ((ExpressionOperator)attributeValue).getDatabaseStrings()[0];
fieldValue = databaseString.substring(0, databaseString.length()-1);
} else {
throw DescriptorException.noAttributeValueConversionToFieldValueProvided(attributeValue, getMapping());
}
}
}
return fieldValue;
|
|