/** PUBLIC: Add a type indicator conversion to this mapping. */ public void addClassIndicator(Class implementer, Object typeIndicator) { if (typeIndicator == null) { typeIndicator = Helper.getNullWrapper(); } getTypeIndicatorTranslation().put(implementer, typeIndicator); getTypeIndicatorTranslation().put(typeIndicator, implementer); }
/** INTERNAL: Return the type for a specified implementor */ protected Object getTypeForImplementor(Class implementor) { Object type = getTypeIndicatorTranslation().get(implementor); if (type == Helper.getNullWrapper()) { type = null; } return type; }
/** INTERNAL: Return the implementor for a specified type */ protected Object getImplementorForType(Object type, AbstractSession session) { if (type == null) { return getTypeIndicatorTranslation().get(Helper.getNullWrapper()); } // Must ensure the type is the same, i.e. Integer != BigDecimal. try { type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return getTypeIndicatorTranslation().get(type); }
/** INTERNAL: Set the type field classification through searching the indicators hashtable. */ @Override public void preInitialize(AbstractSession session) throws DescriptorException { super.preInitialize(session); if (getTypeIndicatorTranslation().isEmpty()) { return; } Class type = null; for (Iterator typeValuesEnum = getTypeIndicatorTranslation().values().iterator(); typeValuesEnum.hasNext() && (type == null); ) { Object value = typeValuesEnum.next(); if ((value != Helper.getNullWrapper()) && (!(value instanceof Class))) { type = value.getClass(); } } getTypeField().setType(type); }
/** * INTERNAL: Add indicators by classname. For use by the Mapping Workbench to avoid classpath * dependencies */ public void addClassNameIndicator(String className, Object typeIndicator) { if (typeIndicator == null) { typeIndicator = Helper.getNullWrapper(); } getTypeIndicatorNameTranslation().put(className, typeIndicator); }