Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.XMLClassDescriptor


                    || ("".equals(className))
                    || (_missingTypes.contains(className))) {
                return null;
            }
           
            XMLClassDescriptor ret = (XMLClassDescriptor) _typeMap.get(className);
            if (LOG2.isDebugEnabled()) {
                LOG2.debug("Get descriptor for: " + className + " found: " + ret);
            }
            return ret;
        } //-- getDescriptor
View Full Code Here


            process((XMLClassDescriptor)classDesc);
            return;
        }

        //-- handle inheritence
        XMLClassDescriptor xmlClassDesc = null;
        ClassDescriptor extendsDesc = classDesc.getExtends();
        if (extendsDesc != null) {
            if (extendsDesc instanceof XMLClassDescriptor) {
                xmlClassDesc = (XMLClassDescriptor) extendsDesc;
            } else {
View Full Code Here

       
        clearError();

        if (type == null) return null;
       
        XMLClassDescriptor classDesc = (XMLClassDescriptor) _cacheViaClass.get(type);
       
        if (classDesc != null) return classDesc;

        //-- check mapping loader first
        //-- [proposed by George Stewart]
View Full Code Here

     * @param loader the ClassLoader to use
     * @return the XMLClassDescriptor for the given class name
    **/
    public XMLClassDescriptor resolve(String className, ClassLoader loader) {
       
        XMLClassDescriptor classDesc = null;
       
        if ((className == null) || (className.length() == 0)) {
            clearError(); //-- clear previous error flag
            setError("Cannot resolve a null or zero-length class name.");
            return null;
        }
           
        //-- first check mapping loader
        if (_mappingLoader != null) {
            classDesc = (XMLClassDescriptor)_mappingLoader.getDescriptor(className);
            if (classDesc != null)
                return classDesc;
        }
       
        //-- try and load class to check cache,
        Class _class = null;
        try {
            _class = loadClass(className, loader);
        }
        catch(ClassNotFoundException cnfe) {
            //-- save exception, for future calls with
            //-- the same classname
            if (_classNotFoundList == null)
                _classNotFoundList = new Hashtable();
            _classNotFoundList.put(className, cnfe);
        }
       
        if (_class != null) {
            classDesc = resolve(_class);
        }
        else clearError(); //-- clear error flag
       
        //-- try to load ClassDescriptor with no class being
        //-- present...does this make sense?
        if ((classDesc == null) && (_class == null)) {
            String dClassName = className+DESCRIPTOR_PREFIX;
            try {
              Class dClass = loadClass(dClassName, loader);
                classDesc = (XMLClassDescriptor) dClass.newInstance();
                if (classDesc.getJavaClass() != null) {
                    associate(classDesc.getJavaClass(), classDesc);
                }
            }
            catch(InstantiationException ie) { 
                //-- do nothing for now
            }
View Full Code Here

            setError("Cannot resolve a null or zero-length xml name.");
            return null;
        }
       
       
        XMLClassDescriptor classDesc = null;
        Enumeration enumeration             = null;
       
        //-- check name cache first...
        String nameKey = xmlName;
        if ((namespaceURI != null) && (namespaceURI.length() > 0))
            nameKey = namespaceURI + ':' + xmlName;
           
        classDesc = (XMLClassDescriptor)_cacheViaName.get(nameKey);
        if(classDesc != null)
            return classDesc;

        //-- next check mapping loader...
        XMLClassDescriptor possibleMatch = null;
        if (_mappingLoader != null) {
            enumeration = _mappingLoader.listDescriptors();
            while (enumeration.hasMoreElements()) {
                classDesc = (XMLClassDescriptor)enumeration.nextElement();
                if (xmlName.equals(classDesc.getXMLName())) {
View Full Code Here

            setError("Cannot resolve a null or zero-length xml name.");
            return null;
        }
       
        XCDEnumerator xcdEnumerator  = new XCDEnumerator();
        XMLClassDescriptor classDesc = null;
        Enumeration enumeration             = null;
       
        //-- check mapping loader first
        if (_mappingLoader != null) {
            enumeration = _mappingLoader.listDescriptors();
            while (enumeration.hasMoreElements()) {
                classDesc = (XMLClassDescriptor)enumeration.nextElement();
                if (xmlName.equals(classDesc.getXMLName())) {
                    xcdEnumerator.add(classDesc);
                }
            }
        }
       
        //-- next look in local cache
        enumeration = _cacheViaClass.elements();
        while (enumeration.hasMoreElements()) {
            classDesc = (XMLClassDescriptor)enumeration.nextElement();
            if (xmlName.equals(classDesc.getXMLName())) {
                xcdEnumerator.add(classDesc);
            }
        }
       
        return xcdEnumerator;
View Full Code Here

            //-- do nothing...handled below
        }
       
        //-- If not null, then JDK 1.2 or greater
        if (LIST_CLASS != null) {
            XMLClassDescriptor descriptor = null;
            loader = CoreDescriptors.class.getClassLoader();
            Class descriptorClass = null;
            try {
                if (loader == null) {
                    descriptorClass = Class.forName(LIST_DESCRIPTOR_NAME);
View Full Code Here

        }
           
        if ( _forceIntrospection && (!Types.isConstructable( cls )))
            throw new MappingException( "mapping.classNotConstructable", cls.getName() );

        XMLClassDescriptor xmlClass;
        FieldDescriptor[]  fields;
        ClassMapping       classMap;
        FieldMapping       fieldMap;

        boolean introspected = false;
        try {
            if (_forceIntrospection) {
                xmlClass = _introspector.generateClassDescriptor( cls );
                introspected = true;
            }
            else {
                xmlClass = _resolver.resolve( cls );
                introspected = _introspector.introspected(xmlClass);
            }
        }
        catch ( MarshalException except ) {
            throw new MappingException( except );
        }
        classMap = new ClassMapping();
        classMap.setName( cls.getName() );
        classMap.setDescription( "Default mapping for class " + cls.getName() );
       
        //-- prevent default access from showing up in the mapping
        classMap.setAccess(null);
       
        //-- map-to
        MapTo mapTo = new MapTo();
        mapTo.setXml( xmlClass.getXMLName() );
        mapTo.setNsUri( xmlClass.getNameSpaceURI() );
        mapTo.setNsPrefix( xmlClass.getNameSpacePrefix() );
        classMap.setMapTo( mapTo );
       
        //-- add mapping to hashtable before processing
        //-- fields so we can do recursive processing
        _mappings.put( cls, classMap );
       
        fields = xmlClass.getFields();
        for ( int i = 0 ; i < fields.length ; ++i ) {
           
            FieldDescriptor fdesc = fields[ i ];
           
            String fieldName = fdesc.getFieldName();
View Full Code Here

        }
           
        if ( _forceIntrospection && (!Types.isConstructable( cls )))
            throw new MappingException( "mapping.classNotConstructable", cls.getName() );

        XMLClassDescriptor xmlClass;
        FieldDescriptor[]  fields;
        ClassMapping       classMap;
        FieldMapping       fieldMap;

        boolean introspected = false;
        try {
            if (_forceIntrospection) {
                xmlClass = _introspector.generateClassDescriptor( cls );
                introspected = true;
            }
            else {
                xmlClass = _resolver.resolve( cls );
                introspected = _introspector.introspected(xmlClass);
            }
        }
        catch ( MarshalException except ) {
            throw new MappingException( except );
        }
        classMap = new ClassMapping();
        classMap.setName( cls.getName() );
        classMap.setDescription( "Default mapping for class " + cls.getName() );
       
        //-- prevent default access from showing up in the mapping
        classMap.setAccess(null);
       
        //-- map-to
        MapTo mapTo = new MapTo();
        mapTo.setXml( xmlClass.getXMLName() );
        mapTo.setNsUri( xmlClass.getNameSpaceURI() );
        mapTo.setNsPrefix( xmlClass.getNameSpacePrefix() );
        classMap.setMapTo( mapTo );
       
        //-- add mapping to hashtable before processing
        //-- fields so we can do recursive processing
        _mappings.put( cls, classMap );
       
        fields = xmlClass.getFields();
        for ( int i = 0 ; i < fields.length ; ++i ) {
           
            FieldDescriptor fdesc = fields[ i ];
           
            String fieldName = fdesc.getFieldName();
View Full Code Here

            //-- do nothing...handled below
        }
       
        //-- If not null, then JDK 1.2 or greater
        if (LIST_CLASS != null) {
            XMLClassDescriptor descriptor = null;
            loader = CoreDescriptors.class.getClassLoader();
            Class descriptorClass = null;
            try {
                if (loader == null) {
                    descriptorClass = Class.forName(LIST_DESCRIPTOR_NAME);
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.XMLClassDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.