FileDocCategorySizeDatePackage
ExpressionOperatorConverter.javaAPI DocGlassfish v2 API4925Tue May 22 16:54:32 BST 2007oracle.toplink.essentials.internal.expressions

ExpressionOperatorConverter

public 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.

Fields Summary
Constructors Summary
Methods Summary
public java.lang.ObjectconvertDataValueToObjectValue(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.ObjectconvertObjectValueToDataValue(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;