/** * INTERNAL: */ public boolean hasClassExtractor() { return getClassExtractor() != null; }
/** * INTERNAL: */ public boolean hasClassExtractor() { return getClassExtractor() != null; }
/** * INTERNAL: */ public boolean hasClassExtractor() { return getClassExtractor() != null; }
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ protected void initializeClassExtractor(AbstractSession session) throws DescriptorException { if (getClassExtractor() == null) { if (isChildDescriptor()) { setClassExtractor(getParentDescriptor().getInheritancePolicy().getClassExtractor()); } } else { getClassExtractor().initialize(getDescriptor(), session); } }
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ protected void initializeClassExtractor(AbstractSession session) throws DescriptorException { if (getClassExtractor() == null) { if (isChildDescriptor()) { setClassExtractor(getParentDescriptor().getInheritancePolicy().getClassExtractor()); } } else { getClassExtractor().initialize(getDescriptor(), session); } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ protected void initializeClassExtractor(AbstractSession session) throws DescriptorException { if (getClassExtractor() == null) { if (isChildDescriptor()) { setClassExtractor(getParentDescriptor().getInheritancePolicy().getClassExtractor()); } } else { getClassExtractor().initialize(getDescriptor(), session); } }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
/** * ADVANCED: * A class extraction method can be registered with the descriptor to override the default inheritance mechanism. * This allows for a user defined class indicator in place of providing an explicit class indicator field. * The method registered must be a static method on the class which has that descriptor. The method must take Record * as an argument (for example, a DatabaseRecord), and must return the class to use for that record. * This method will be used to decide which class to instantiate when reading from the database. * It is the application's responsibility to populate any typing information in the database required * to determine the class from the record. * If this method is used then the class indicator field and mapping cannot be used, and in addition, * the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly. * * @see #setWithAllSubclassesExpression(Expression) * @see #setOnlyInstancesExpression(Expression) */ public void setClassExtractionMethodName(String staticClassClassExtractionMethod) { if ((staticClassClassExtractionMethod == null) || (staticClassClassExtractionMethod.length() == 0)) { return; } if (!(getClassExtractor() instanceof MethodClassExtractor)) { setClassExtractor(new MethodClassExtractor()); } ((MethodClassExtractor)getClassExtractor()).setClassExtractionMethodName(staticClassClassExtractionMethod); }
/** * INTERNAL: * This method is invoked only for the abstract descriptors. */ public Class classFromRow(AbstractRecord rowFromDatabase, AbstractSession session) throws DescriptorException { if (hasClassExtractor()) { return getClassExtractor().extractClassFromRow(rowFromDatabase, session); } Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType()); if (classFieldValue == null) { throw DescriptorException.missingClassIndicatorField(rowFromDatabase, getDescriptor()); } return classFromValue(classFieldValue, session); }
/** * INTERNAL: * This method is invoked only for the abstract descriptors. */ @Override public Class classFromRow(AbstractRecord rowFromDatabase, AbstractSession session) throws DescriptorException { if (hasClassExtractor()) { return getClassExtractor().extractClassFromRow(rowFromDatabase, session); } Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType()); if (classFieldValue == null) { throw DescriptorException.missingClassIndicatorField(rowFromDatabase, getDescriptor()); } return classFromValue(classFieldValue, session); }
/** * INTERNAL: * This method is invoked only for the abstract descriptors. */ @Override public Class classFromRow(AbstractRecord rowFromDatabase, AbstractSession session) throws DescriptorException { if (hasClassExtractor()) { return getClassExtractor().extractClassFromRow(rowFromDatabase, session); } Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType()); if (classFieldValue == null) { throw DescriptorException.missingClassIndicatorField(rowFromDatabase, getDescriptor()); } return classFromValue(classFieldValue, session); }