throw new IllegalArgumentException(SDOException.conversionError(null)); return null; } else if (!(value instanceof List)) { throw new IllegalArgumentException(SDOException.conversionError(null)); } else { List theList = (List) value;
throw new IllegalArgumentException(SDOException.conversionError(null)); return null; } else if (!(value instanceof List)) { throw new IllegalArgumentException(SDOException.conversionError(null)); } else { List theList = (List) value;
/** * Convert the specified value to an {@link Type#getInstanceClass() * instance} of the specified type. Supported conversions are listed in * Section 14 of the SDO specification. * * @param type the target {@link Type#isDataType() data type}. * @param value the value to convert * @return a value of the specified type's instance class * @throws IllegalArgumentException if the value could not be converted * @see #convert(Property, Object) */ public Object convert(Type type, Object value) { Class convertClass = null; if (((SDOType) type).isDataType()) { convertClass = type.getInstanceClass(); } /*else { convertClass = ((org.eclipse.persistence.sdo.SDOType) type).getImplClass(); }*/ if (value.getClass() == ClassConstants.STRING) { return convertFromStringValue((String) value, type); } else if (convertClass == ClassConstants.STRING) { return convertToStringValue(value, type); } else { try { return getXMLConversionManager().convertObject(value, convertClass); } catch (ConversionException e) { throw new IllegalArgumentException(SDOException.conversionError(e)); } } }
/** * Convert the specified value to an {@link Type#getInstanceClass() * instance} of the specified type. Supported conversions are listed in * Section 14 of the SDO specification. * * @param type the target {@link Type#isDataType() data type}. * @param value the value to convert * @return a value of the specified type's instance class * @throws IllegalArgumentException if the value could not be converted * @see #convert(Property, Object) */ public Object convert(Type type, Object value) { Class convertClass = null; if (((SDOType) type).isDataType()) { convertClass = type.getInstanceClass(); } /*else { convertClass = ((org.eclipse.persistence.sdo.SDOType) type).getImplClass(); }*/ if (value.getClass() == ClassConstants.STRING) { return convertFromStringValue((String) value, type); } else if (convertClass == ClassConstants.STRING) { return convertToStringValue(value, type); } else { try { return getXMLConversionManager().convertObject(value, convertClass); } catch (ConversionException e) { throw new IllegalArgumentException(SDOException.conversionError(e)); } } }
/** * INTERNAL: */ public Object convertValueToClass(Property prop, Object valueToConvert, Class convertToClass) { try { if (valueToConvert == null) { return null; } if (convertToClass == ClassConstants.STRING) { return convertToStringValue(valueToConvert, prop.getType(), ((SDOProperty) prop).getXsdType()); } else { SDOProperty sdoProp = (SDOProperty) prop; DatabaseMapping xmlMapping = sdoProp.getXmlMapping(); if (xmlMapping != null && xmlMapping.isDirectToFieldMapping() && sdoProp.getXsdType() != null) { return getXMLConversionManager().convertObject(valueToConvert, convertToClass, sdoProp.getXsdType()); } else { return getXMLConversionManager().convertObject(valueToConvert, convertToClass); } } } catch (ConversionException e) { throw new IllegalArgumentException(SDOException.conversionError(e)); } }
/** * INTERNAL: */ public Object convertValueToClass(Property prop, Object valueToConvert, Class convertToClass) { try { if (valueToConvert == null) { return null; } if (convertToClass == ClassConstants.STRING) { return convertToStringValue(valueToConvert, prop.getType(), ((SDOProperty) prop).getXsdType()); } else { SDOProperty sdoProp = (SDOProperty) prop; DatabaseMapping xmlMapping = sdoProp.getXmlMapping(); if (xmlMapping != null && xmlMapping.isDirectToFieldMapping() && sdoProp.getXsdType() != null) { return getXMLConversionManager().convertObject(valueToConvert, convertToClass, sdoProp.getXsdType()); } else { return getXMLConversionManager().convertObject(valueToConvert, convertToClass); } } } catch (ConversionException e) { throw new IllegalArgumentException(SDOException.conversionError(e)); } }