SimpleType base = (SimpleType)simpleType.getBaseType(); if (base != null) simpleType = base;
baseType = (SimpleType)simpleType.getBaseType();
    public FieldInfo createFieldInfo        (XMLBindingComponent component, ClassInfoResolver resolver)    {                String xmlName = component.getXMLName();        String memberName = component.getJavaMemberName();        if (!memberName.startsWith("_"))            memberName = "_"+memberName;        XMLType xmlType = component.getXMLType();                ClassInfo classInfo = resolver.resolve(component);        XSType   xsType = null;        FieldInfo fieldInfo = null;        boolean enumeration = false;        boolean simpleTypeCollection = false;        if (xmlType != null) {            if (xmlType.isSimpleType()) {                SimpleType simpleType = (SimpleType)xmlType;                                String derivationMethod = simpleType.getDerivationMethod();                if (derivationMethod != null) {                    if (SchemaNames.RESTRICTION.equals(derivationMethod)) {                        SimpleType base = (SimpleType)simpleType.getBaseType();                        if (base != null) simpleType = base;                    }                }                //-- handle special case for enumerated types                if (simpleType.hasFacet(Facet.ENUMERATION)) {                    //-- LOok FoR CLasSiNfO iF ReSoLvR is NoT NuLL                    enumeration = true;                    if (resolver != null) {                        classInfo = resolver.resolve(simpleType);                    }                    if (classInfo != null) {                        xsType = classInfo.getSchemaType();                    }                }                else if (simpleType instanceof ListType) {                    if (!simpleType.isBuiltInType())                        simpleTypeCollection = true;                }                                if (xsType == null) {                    xsType = component.getJavaType();                }            }//--simpleType            else if (xmlType.isAnyType()) {                //-- Just treat as java.lang.Object.                if (classInfo != null)                    xsType = classInfo.getSchemaType();                if (xsType == null)                    xsType = new XSClass(SGTypes.Object);            }//--AnyType            else if (xmlType.isComplexType() && (xmlType.getName() != null)) {                //--if we use the type method then no class is output for                //--the element we are processing                if (_config.mappingSchemaType2Java()) {                    XMLBindingComponent temp = new XMLBindingComponent(_config);                    temp.setBinding(component.getBinding());                    temp.setView(xmlType);                    String className = temp.getQualifiedName();                    if (className != null) {                    	xsType = new XSClass(new JClass(className));                        className = null;                    }                }            }//--complexType        }        else {                        //-- patch for bug 1471 (No XMLType specified)            //-- treat unspecified type as anyType            switch (component.getAnnotated().getStructureType()) {                case Structure.ATTRIBUTE:                case Structure.ELEMENT:                    xsType = new XSClass(SGTypes.Object);                    break;                default:                    // probably a model-group                    break;            }        }        //--is the XSType found?        if (xsType == null) {            String className = component.getQualifiedName();            xsType = new XSClass(new JClass(className));            className = null;        }        //--create the fieldInfo        //-- check whether this should be a collection or not        int maxOccurs = component.getUpperBound();        int minOccurs = component.getLowerBound();        if (simpleTypeCollection || ((maxOccurs < 0) || (maxOccurs > 1))) {            String vName = memberName+"List";                        //--if xmlName is null it means that             //--we are processing a container object (group)            //--so we need to adjust the name of the members of the collection            CollectionInfo cInfo;            cInfo = _infoFactory.createCollection(xsType, vName, component.getJavaMemberName());                        XSList xsList = cInfo.getXSList();            if (!simpleTypeCollection) {                xsList.setMaximumSize(maxOccurs);                xsList.setMinimumSize(minOccurs);            }            fieldInfo = cInfo;        } else  {            switch (xsType.getType()) {                case XSType.ID_TYPE:                     fieldInfo = _infoFactory.createIdentity(memberName);                     break;                case XSType.COLLECTION:                    String collectionName = component.getCollectionType();                    fieldInfo = _infoFactory.createCollection( ((XSList) xsType).getContentType(),                                                               memberName,                                                               xmlName, collectionName);                    break;                default:                    fieldInfo = _infoFactory.createFieldInfo(xsType, memberName);                    break;            }        }        boolean createForElement = false;        boolean createForAttribute = false;        //--initialize the field        fieldInfo.setNodeName(xmlName);        fieldInfo.setRequired(minOccurs > 0);        switch (component.getAnnotated().getStructureType()) {            case Structure.ELEMENT:                 fieldInfo.setNodeType(XMLInfo.ELEMENT_TYPE);                 ElementDecl element = (ElementDecl)component.getAnnotated();                 createForElement = true;                 break;            case Structure.ATTRIBUTE:                fieldInfo.setNodeType(XMLInfo.ATTRIBUTE_TYPE);                createForAttribute = true;                break;            case Structure.MODELGROUP:            case Structure.GROUP:                fieldInfo.setNodeName("-error-if-this-is-used-");                fieldInfo.setContainer(true);                break;        }        //-- handle namespace URI / prefix        String nsURI = component.getTargetNamespace();        if ((nsURI != null) && (nsURI.length() > 0)) {            fieldInfo.setNamespaceURI(nsURI);            /**             * @todo set the prefix used in the XML Schema in              * order to use it inside the Marshalling Framework             */        }        //--handle default value        //--TO CLEAN UP IN A SEPARATE METHOD???        String value = component.getValue();        if (value != null) {            // various type adjustements            switch (xsType.getType()) {                case XSType.FLOAT_TYPE:                    value = value + 'f';                    break;                case XSType.BOOLEAN_TYPE:                    Boolean bool = new Boolean(value);                    value = bool.toString();                    break;                default:                    break;            }            if (value.length() == 0)                value="\"\"";            //-- XXX Need to change this...and we            //-- XXX need to validate the value...to be done at reading time.            //-- clean up value            //-- if the xsd field is mapped into a java.lang.String            if  (xsType.getJType().toString().equals("java.lang.String")) {                char ch = value.charAt(0);                switch (ch) {                    case '\'':                    case '\"':                        break;                    default:                        value = '\"' + value + '\"';                        break;                }            } else if (enumeration) {                //-- we'll need to change this                //-- when enumerations are no longer                //-- treated as strings                JType jType = null;                 if (classInfo != null) {                     jType = classInfo.getJClass();                }                 else {                     jType = xsType.getJType();                 }                                     String tmp = jType.getName() + ".valueOf(\"" + value;                tmp += "\")";                value = tmp;                                             }            //don't generate code for date/time type since the constructor that parses            //a string is throwing exception            else if (!xsType.getJType().isPrimitive() && !xsType.isDateTime()) {                 //XXX This works only if a constructor                 //XXX with String as parameter exists                 value = "new "+xsType.getJType().toString()+"(\""+value+"\")";            }            if (component.isFixed())                fieldInfo.setFixedValue(value);            else                fieldInfo.setDefaultValue(value);        }                //-- handle nillable values        if (component.isNillable())            fieldInfo.setNillable(true);                        //-- add annotated comments        String comment = createComment(component.getAnnotated());        if (comment != null)             fieldInfo.setComment(comment);        //--specific field handler or validator?        if (component.getXMLFieldHandler() != null)            fieldInfo.setXMLFieldHandler(component.getXMLFieldHandler());        if (component.getValidator() != null)            fieldInfo.setValidator(component.getValidator());        return fieldInfo;    }