Index: src/main/java/org/exolab/castor/builder/TypeConversion.java =================================================================== --- src/main/java/org/exolab/castor/builder/TypeConversion.java (revision 7439) +++ src/main/java/org/exolab/castor/builder/TypeConversion.java (working copy) @@ -97,6 +97,7 @@ import org.exolab.castor.xml.schema.Structure; import org.exolab.castor.xml.schema.Union; import org.exolab.javasource.JClass; +import org.exolab.javasource.JNaming; import org.exolab.javasource.JType; /** @@ -147,7 +148,7 @@ */ public XSType convertType(final SimpleType simpleType, final String packageName, final boolean useJava50) { - return convertType(simpleType, packageName, _config.usePrimitiveWrapper(), useJava50); + return convertType(simpleType, packageName, _config.usePrimitiveWrapper(), useJava50, null); } /** @@ -159,10 +160,11 @@ * wrappers be used instead of the actual primitives (e.g. * java.lang.Integer instead of int) * @param useJava50 true if source code is to be generated for Java 5 + * @param javaClassBindingName valid java Class Name specified by corresponding binding component * @return the XSType which represets the given Simpletype */ public XSType convertType(final SimpleType simpleType, final String packageName, - final boolean useWrapper, final boolean useJava50) { + final boolean useWrapper, final boolean useJava50, final String javaClassBindingName) { if (simpleType == null) { return null; } @@ -184,7 +186,7 @@ return new XSClass(new JClass(className)); } - xsType = findXSTypeForEnumeration(simpleType, packageName); + xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName); if (xsType != null) { return xsType; } @@ -353,7 +355,7 @@ xsQName.setFacets(simpleType); return xsQName; case SimpleTypesFactory.STRING_TYPE: //-- string - xsType = findXSTypeForEnumeration(simpleType, packageName); + xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName); if (xsType == null) { // Not an enumerated String type XSString xsString = new XSString(); @@ -431,7 +433,7 @@ return new XSClass(SGTypes.OBJECT); } - XSType convertedType = convertType(common, packageName, useWrapper, useJava50); + XSType convertedType = convertType(common, packageName, useWrapper, useJava50, null); Union unionType = (Union) simpleType; Enumeration memberTypes = unionType.getMemberTypes(); while (memberTypes.hasMoreElements()) { @@ -509,9 +511,10 @@ * returns null. * @param simpleType the SimpleType being inspected * @param packageName current package name + * @param javaClassBindingName valid Java Class Name specified by corresponding binding component * @return an XSType for an enumerated type, null for a non-enumerated type. */ - private XSType findXSTypeForEnumeration(final SimpleType simpleType, final String packageName) { + private XSType findXSTypeForEnumeration(final SimpleType simpleType, final String packageName, final String javaClassBindingName) { if (!simpleType.hasFacet(Facet.ENUMERATION)) { return null; } @@ -521,17 +524,28 @@ //-- anonymous type if (typeName == null) { + if (javaClassBindingName != null) { + // handled by binding file + if (!JNaming.isInJavaLang(javaClassBindingName) && !JNaming.isReservedByCastor(javaClassBindingName) && !JNaming.isReservedByWindows(javaClassBindingName)) { + typeName = javaClassBindingName; + } + } + } + + if (typeName == null) { + // not handled by binding file Structure parent = simpleType.getParent(); if (parent instanceof ElementDecl) { typeName = ((ElementDecl) parent).getName(); } else if (parent instanceof AttributeDecl) { typeName = ((AttributeDecl) parent).getName(); } + typeName = typeName + "Type"; } String className = _config.getJavaNaming().toJavaClassName(typeName); - + // Get the appropriate package name for this type String typePackageName = packageName; if (typePackageName == null) { Index: src/main/java/org/exolab/castor/builder/binding/XMLBindingComponent.java =================================================================== --- src/main/java/org/exolab/castor/builder/binding/XMLBindingComponent.java (revision 7439) +++ src/main/java/org/exolab/castor/builder/binding/XMLBindingComponent.java (working copy) @@ -1270,7 +1270,7 @@ } result = _typeConversion.convertType((SimpleType) type, - packageName, useWrapper,_config.useJava50()); + packageName, useWrapper,_config.useJava50(), getJavaClassName()); } } Index: pom.xml =================================================================== --- pom.xml (revision 7439) +++ pom.xml (working copy) @@ -1,24 +1,21 @@ - + + 4.0.0 org.codehaus.castor castor-codegen 1.2.1-SNAPSHOT - jar Castor XML - Code generator - @@ -28,15 +25,9 @@ castor-maven-plugin 1.0 - - src/main/resources/org/exolab/castor/builder/binding/binding.xsd - - - org.exolab.castor.builder.binding - - - src/main/resources/org/exolab/castor/builder/binding.generation.properties - + src/main/resources/org/exolab/castor/builder/binding/binding.xsd + org.exolab.castor.builder.binding + src/main/resources/org/exolab/castor/builder/binding.generation.properties @@ -45,14 +36,14 @@ 1.1-M3-SNAPSHOT - @@ -63,12 +54,8 @@ 1.4 1.4 - - org/exolab/castor/builder/** - - - org/exolab/javasource/** - + org/exolab/castor/builder/** + org/exolab/javasource/** @@ -78,9 +65,7 @@ maven-jar-plugin - - src/main/resources/META-INF/MANIFEST.MF - + src/main/resources/META-INF/MANIFEST.MF @@ -134,15 +119,9 @@ - - scm:svn:http://svn.codehaus.org/castor/castor/trunk/codegen - - - scm:svn:https://svn.codehaus.org/castor/castor/trunk/codegen - - - http://svn.castor.codehaus.org/browse/castor/castor/trunk/codegen - + scm:svn:http://svn.codehaus.org/castor/castor/trunk/codegen + scm:svn:https://svn.codehaus.org/castor/castor/trunk/codegen + http://svn.castor.codehaus.org/browse/castor/castor/trunk/codegen @@ -186,6 +165,15 @@ true + + xerces + xercesImpl + 2.6.2 + test + + + + @@ -198,9 +186,7 @@ codehaus.org Castor Central Development Repository - - dav:https://dav.codehaus.org/snapshots.repository/castor/ - + dav:https://dav.codehaus.org/snapshots.repository/castor/ codehaus.org @@ -212,36 +198,27 @@ java.net java.net Maven Repository - - https://maven-repository.dev.java.net/nonav/repository - + https://maven-repository.dev.java.net/nonav/repository legacy maven2-repository.dev.java.net Java.net Repository for Maven 2 - - https://maven2-repository.dev.java.net/nonav/repository - + https://maven2-repository.dev.java.net/nonav/repository default codehaus-snapshots Maven Codehaus Snapshots - - http://snapshots.repository.codehaus.org - + http://snapshots.repository.codehaus.org Maven Codehaus Snapshots - - http://snapshots.maven.codehaus.org/maven2 - + http://snapshots.maven.codehaus.org/maven2 - true false @@ -250,5 +227,3 @@ - -