private Object convertSingleValue( Column modelElement, String modelAttrName, Class<?> modelAttrClass, Object objResult) throws TranslatorException, InvalidNameException { if (objResult == null) { return null; } // GHH 20080326 - if attribute is not a string or empty, just // return null. if (!(objResult instanceof String)) { return objResult; } String strResult = (String) objResult; // MPW - 3.9.07 - Also return NULL when attribute is unset or empty string. // There is no way to differentiate between being unset and being the empty string. if (strResult.equals("")) { // $NON-NLS-1$ return null; } // MPW: 3-11-07: Added support for java.lang.Integer conversion. if (TypeFacility.RUNTIME_TYPES.TIMESTAMP.equals(modelAttrClass)) { String timestampFormat = modelElement.getFormat(); if (timestampFormat == null) { timestampFormat = LDAPConnectorConstants.ldapTimestampFormat; } SimpleDateFormat dateFormat = new SimpleDateFormat(timestampFormat); try { Date dateResult = dateFormat.parse(strResult); Timestamp tsResult = new Timestamp(dateResult.getTime()); return tsResult; } catch (ParseException pe) { throw new TranslatorException( pe, LDAPPlugin.Util.getString( "LDAPSyncQueryExecution.timestampParseFailed", modelAttrName)); // $NON-NLS-1$ } // TODO: Extend support for more types in the future. // Specifically, add support for byte arrays, since that's actually supported // in the underlying data source. } // extract rdn String type = modelElement.getProperty(LDAPExecutionFactory.RDN_TYPE, false); if (type != null) { String prefix = modelElement.getProperty(LDAPExecutionFactory.DN_PREFIX, false); LdapName name = new LdapName(strResult); if (prefix != null) { if (!name.getPrefix(name.size() - 1).toString().equals(prefix)) { throw new InvalidNameException(); } } else if (name.size() > 1) { throw new InvalidNameException(); } Rdn rdn = name.getRdn(name.size() - 1); if (!rdn.getType().equals(type)) { throw new InvalidNameException(); } return rdn.getValue(); } return strResult; // the Teiid type conversion logic will handle refine from here if necessary }