/** * 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); } }
if (descriptor.hasInheritance() && !descriptor.getInheritancePolicy().shouldUseClassNameAsIndicator()){ return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else {
if (descriptor.hasInheritance() && !descriptor.getInheritancePolicy().shouldUseClassNameAsIndicator()){ return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else {
if (descriptor.hasInheritance() && !descriptor.getInheritancePolicy().shouldUseClassNameAsIndicator()){ return descriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectValue); } else {
/** * 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; }
method.addLine("descriptor.getInheritancePolicy().setClassIndicatorFieldName(\"" + policy.getClassIndicatorField().getQualifiedName() + "\");"); if (policy.shouldUseClassNameAsIndicator()) { method.addLine("descriptor.getInheritancePolicy().useClassNameAsIndicator();"); } else {
method.addLine("descriptor.getInheritancePolicy().setClassIndicatorFieldName(\"" + policy.getClassIndicatorField().getQualifiedName() + "\");"); if (policy.shouldUseClassNameAsIndicator()) { method.addLine("descriptor.getInheritancePolicy().useClassNameAsIndicator();"); } else {
method.addLine("descriptor.getInheritancePolicy().setClassIndicatorFieldName(\"" + policy.getClassIndicatorField().getQualifiedName() + "\");"); if (policy.shouldUseClassNameAsIndicator()) { method.addLine("descriptor.getInheritancePolicy().useClassNameAsIndicator();"); } else {
setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator());
setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator());
setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator()); setClassIndicatorField(getDescriptor().buildField(getClassIndicatorField())); if (shouldUseClassNameAsIndicator()) { getClassIndicatorField().setType(ClassConstants.STRING); } else if (!getClassIndicatorMapping().isEmpty()) {
setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator()); setClassIndicatorField(getDescriptor().buildField(getClassIndicatorField())); if (shouldUseClassNameAsIndicator()) { getClassIndicatorField().setType(ClassConstants.STRING); } else if (!getClassIndicatorMapping().isEmpty()) {
setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator()); setClassIndicatorField(getDescriptor().buildField(getClassIndicatorField())); if (shouldUseClassNameAsIndicator()) { getClassIndicatorField().setType(ClassConstants.STRING); } else if (!getClassIndicatorMapping().isEmpty()) {