/** * Returns the Java class represented by this descriptor. * * @return The Java class */ public Class getJavaClass() { return _classDesc.getJavaClass(); } // -- getJavaClass
/** * Search there is a field descriptor which can accept one of the class descriptor which match the * given name and namespace. * * @param name XML name of the field * @param namespace namespace of the field * @param classDesc the class descriptor to match against * @param cdResolver the class descriptor resolver to use * @return An array of InheritanceMatch. * @throws MarshalException if the resolver called fails fatally */ protected InheritanceMatch[] searchInheritance( final String name, final String namespace, final XMLClassDescriptor classDesc) throws MarshalException { Iterator classDescriptorIterator = null; try { // -- A little required logic for finding Not-Yet-Loaded // -- descriptors String className = getJavaNaming().toJavaClassName(name); // -- should use namespace-to-prefix mappings, but // -- just create package for now. Class clazz = classDesc.getJavaClass(); String pkg = null; if (clazz != null) { while (clazz.getDeclaringClass() != null) { clazz = clazz.getDeclaringClass(); } pkg = clazz.getName(); int idx = pkg.lastIndexOf('.'); if (idx >= 0) { pkg = pkg.substring(0, idx + 1); className = pkg + className; } } getInternalContext() .getXMLClassDescriptorResolver() .resolve(className, classDesc.getClass().getClassLoader()); // -- end Not-Yet-Loaded descriptor logic // -- resolve all by XML name + namespace URI classDescriptorIterator = getInternalContext() .getXMLClassDescriptorResolver() .resolveAllByXMLName(name, namespace, null); } catch (ResolverException rx) { Throwable actual = rx.getCause(); if (actual instanceof MarshalException) { throw (MarshalException) actual; } if (actual != null) { throw new MarshalException(actual); } throw new MarshalException(rx); } Vector inheritanceList = null; XMLFieldDescriptor descriptor = null; XMLFieldDescriptor[] descriptors = classDesc.getElementDescriptors(); XMLClassDescriptor cdInherited = null; if (classDescriptorIterator.hasNext()) { while (classDescriptorIterator.hasNext() && (descriptor == null)) { cdInherited = (XMLClassDescriptor) classDescriptorIterator.next(); Class subclass = cdInherited.getJavaClass(); for (int i = 0; i < descriptors.length; i++) { if (descriptors[i] == null) { continue; } // -- skip descriptors with special internal name if (INTERNAL_XML_NAME.equals(descriptors[i].getXMLName())) { continue; } // -- check for inheritence Class superclass = descriptors[i].getFieldType(); // It is possible that the superclass is of type object if we use any node. if (superclass.isAssignableFrom(subclass) && (superclass != Object.class)) { descriptor = descriptors[i]; if (inheritanceList == null) { inheritanceList = new Vector(3); } inheritanceList.addElement(new InheritanceMatch(descriptor, cdInherited)); } } } // -- reset inherited class descriptor, if necessary if (descriptor == null) { cdInherited = null; } } if (inheritanceList != null) { InheritanceMatch[] result = new InheritanceMatch[inheritanceList.size()]; inheritanceList.toArray(result); return result; } return NO_MATCH_ARRAY; }