/** * PUBLIC: * Add a class indicator for the root classes subclass. * The indicator is used to determine the class to use for a row read from the database, * and to query only instances of a class from the database. * Every concrete persistent subclass must have a single unique indicator defined for it. * If the root class is concrete then it must also define an indicator. * Only the root class's descriptor of the entire inheritance hierarchy can define the class indicator mapping. */ public void addClassIndicator(Class childClass, Object typeValue) { // Note we should think about supporting null values. // Store as key and value for bi-directional lookup. getClassIndicatorMapping().put(typeValue, childClass); getClassIndicatorMapping().put(childClass, typeValue); }
/** * PUBLIC: * Add a class indicator for the root classes subclass. * The indicator is used to determine the class to use for a row read from the database, * and to query only instances of a class from the database. * Every concrete persistent subclass must have a single unique indicator defined for it. * If the root class is concrete then it must also define an indicator. * Only the root class's descriptor of the entire inheritance hierarchy can define the class indicator mapping. */ public void addClassIndicator(Class childClass, Object typeValue) { // Note we should think about supporting null values. // Store as key and value for bi-directional lookup. getClassIndicatorMapping().put(typeValue, childClass); getClassIndicatorMapping().put(childClass, typeValue); }
/** * PUBLIC: * Add a class indicator for the root classes subclass. * The indicator is used to determine the class to use for a row read from the database, * and to query only instances of a class from the database. * Every concrete persistent subclass must have a single unique indicator defined for it. * If the root class is concrete then it must also define an indicator. * Only the root class's descriptor of the entire inheritance hierarchy can define the class indicator mapping. */ public void addClassIndicator(Class childClass, Object typeValue) { // Note we should think about supporting null values. // Store as key and value for bi-directional lookup. getClassIndicatorMapping().put(typeValue, childClass); getClassIndicatorMapping().put(childClass, typeValue); }
/** * INTERNAL: * Returns the indicator field value for the given class * If no abstract indicator mapping is specified, use the class name. */ protected Object getClassIndicatorValue(Class javaClass) { if (shouldUseClassNameAsIndicator()) { return javaClass.getName(); } else { return getClassIndicatorMapping().get(javaClass); } }
/** * INTERNAL: * Returns the indicator field value for the given class * If no abstract indicator mapping is specified, use the class name. */ protected Object getClassIndicatorValue(Class javaClass) { if (shouldUseClassNameAsIndicator()) { return javaClass.getName(); } else { return getClassIndicatorMapping().get(javaClass); } }
/** * INTERNAL: * Returns the indicator field value for the given class * If no abstract indicator mapping is specified, use the class name. */ protected Object getClassIndicatorValue(Class javaClass) { if (shouldUseClassNameAsIndicator()) { return javaClass.getName(); } else { return getClassIndicatorMapping().get(javaClass); } }
return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else { return ((Class)objectValue).getName();
return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else { return ((Class)objectValue).getName();
return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else { return ((Class)objectValue).getName();
/** * INTERNAL * This method returns the inheritance field value for an object to conform in an in-memory query. * Similar to getFieldValue, but deals with an instance rather than a Class object directly */ public Object typeValueFromObject(Object object, AbstractSession session) { // get the descriptor directly from the object, and use it to find the Java class ClassDescriptor objectDescriptor = session.getClassDescriptor(object); if (!objectDescriptor.hasInheritance() || objectDescriptor.getInheritancePolicy().shouldUseClassNameAsIndicator() || objectDescriptor.getInheritancePolicy().hasClassExtractor() ) { return (objectDescriptor.getJavaClassName()); } else { return objectDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectDescriptor.getJavaClass()); } }
/** * INTERNAL * This method returns the inheritance field value for an object to conform in an in-memory query. * Similar to getFieldValue, but deals with an instance rather than a Class object directly */ public Object typeValueFromObject(Object object, AbstractSession session) { // get the descriptor directly from the object, and use it to find the Java class ClassDescriptor objectDescriptor = session.getClassDescriptor(object); if (!objectDescriptor.hasInheritance() || objectDescriptor.getInheritancePolicy().shouldUseClassNameAsIndicator() || objectDescriptor.getInheritancePolicy().hasClassExtractor() ) { return (objectDescriptor.getJavaClassName()); } else { return objectDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectDescriptor.getJavaClass()); } }
/** * INTERNAL: * This method is used to turn the a raw database field value classFieldValue into a Class object. Used to determine * which class objects to build from database results, and for class type expression */ public Class classFromValue(Object classFieldValue, AbstractSession session) throws DescriptorException { Class concreteClass; if (!shouldUseClassNameAsIndicator()) { concreteClass = (Class)getClassIndicatorMapping().get(classFieldValue); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } else { try { String className = (String)classFieldValue; //PWK 2.5.1.7 can not use class for name, must go through conversion manager. //Should use the root ClassDescriptor's classloader to avoid loading from a loader other //than the one that loaded the project concreteClass = getDescriptor().getJavaClass().getClassLoader().loadClass(className); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } catch (ClassNotFoundException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } catch (ClassCastException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } return concreteClass; }
/** * INTERNAL * This method returns the inheritance field value for an object to conform in an in-memory query. * Similar to getFieldValue, but deals with an instance rather than a Class object directly */ public Object typeValueFromObject(Object object, AbstractSession session) { // get the descriptor directly from the object, and use it to find the Java class ClassDescriptor objectDescriptor = session.getClassDescriptor(object); if (!objectDescriptor.hasInheritance() || objectDescriptor.getInheritancePolicy().shouldUseClassNameAsIndicator() || objectDescriptor.getInheritancePolicy().hasClassExtractor() ) { return (objectDescriptor.getJavaClassName()); } else { return objectDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectDescriptor.getJavaClass()); } }
/** * INTERNAL: * This method is used to turn the a raw database field value classFieldValue into a Class object. Used to determine * which class objects to build from database results, and for class type expression */ public Class classFromValue(Object classFieldValue, AbstractSession session) throws DescriptorException { Class concreteClass; if (!shouldUseClassNameAsIndicator()) { concreteClass = (Class)getClassIndicatorMapping().get(classFieldValue); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } else { try { String className = (String)classFieldValue; //PWK 2.5.1.7 can not use class for name, must go through conversion manager. //Should use the root ClassDescriptor's classloader to avoid loading from a loader other //than the one that loaded the project concreteClass = getDescriptor().getJavaClass().getClassLoader().loadClass(className); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } catch (ClassNotFoundException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } catch (ClassCastException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } return concreteClass; }
/** * INTERNAL: * This method is used to turn the a raw database field value classFieldValue into a Class object. Used to determine * which class objects to build from database results, and for class type expression */ public Class classFromValue(Object classFieldValue, AbstractSession session) throws DescriptorException { Class concreteClass; if (!shouldUseClassNameAsIndicator()) { concreteClass = (Class)getClassIndicatorMapping().get(classFieldValue); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } else { try { String className = (String)classFieldValue; //PWK 2.5.1.7 can not use class for name, must go through conversion manager. //Should use the root ClassDescriptor's classloader to avoid loading from a loader other //than the one that loaded the project concreteClass = getDescriptor().getJavaClass().getClassLoader().loadClass(className); if (concreteClass == null) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } catch (ClassNotFoundException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } catch (ClassCastException e) { throw DescriptorException.missingClassForIndicatorFieldValue(classFieldValue, getDescriptor()); } } return concreteClass; }
if (leafElementType != null) { XPathQName leafElementXPathQName = new XPathQName(leafElementType, ((XMLRecord) nestedRow).isNamespaceAware()); Object indicator = aDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementXPathQName); if(indicator != null) { newElementClass = (Class) indicator;
Object indicator = xmlDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType); if(indicator != null) { classValue = (Class)indicator;
Object indicator = xmlDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType); if(indicator != null) { classValue = (Class)indicator;
Object indicator = xmlDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType);
setClassIndicatorMapping(getParentDescriptor().getInheritancePolicy().getClassIndicatorMapping()); setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator());