// use 'java.lang.Object' instead.
if (simpleType.getStructureType() == Structure.UNION) {
return convertUnion(simpleType, packageName, useWrapper, useJava50);
} else if (base == null) {
String className = _config.getJavaNaming().toJavaClassName(simpleType.getName());
return new XSClass(new JClass(className));
}
xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName);
if (xsType != null) {
return xsType;
}
// If we don't have the XSType yet, we have to look at the Type Code
switch (base.getTypeCode()) {
case SimpleTypesFactory.ID_TYPE: //-- ID
return new XSId();
case SimpleTypesFactory.IDREF_TYPE: //-- IDREF
return new XSIdRef();
case SimpleTypesFactory.IDREFS_TYPE: //-- IDREFS
return new XSIdRefs(SourceGeneratorConstants.FIELD_INFO_VECTOR, useJava50);
case SimpleTypesFactory.NMTOKEN_TYPE: //-- NMTOKEN
XSNMToken xsNMToken = new XSNMToken();
xsNMToken.setFacets(simpleType);
return xsNMToken;
case SimpleTypesFactory.NMTOKENS_TYPE: //-- NMTOKENS
return new XSNMTokens(SourceGeneratorConstants.FIELD_INFO_VECTOR, useJava50);
case SimpleTypesFactory.ANYURI_TYPE: //--AnyURI
return new XSAnyURI();
case SimpleTypesFactory.BASE64BINARY_TYPE: //-- base64Bbinary
return new XSBase64Binary(useJava50);
case SimpleTypesFactory.HEXBINARY_TYPE: //-- hexBinary
return new XSHexBinary(useJava50);
case SimpleTypesFactory.BOOLEAN_TYPE: //-- boolean
return new XSBoolean(useWrapper);
case SimpleTypesFactory.BYTE_TYPE: //--byte
XSByte xsByte = new XSByte(useWrapper);
if (!simpleType.isBuiltInType()) {
xsByte.setFacets(simpleType);
}
return xsByte;
case SimpleTypesFactory.DATE_TYPE: //-- date
XSDate xsDate = new XSDate();
if (!simpleType.isBuiltInType()) {
xsDate.setFacets(simpleType);
}
return xsDate;
case SimpleTypesFactory.DATETIME_TYPE: //-- dateTime
XSDateTime xsDateTime = new XSDateTime();
if (!simpleType.isBuiltInType()) {
xsDateTime.setFacets(simpleType);
}
return xsDateTime;
case SimpleTypesFactory.DOUBLE_TYPE: //-- double
XSDouble xsDouble = new XSDouble(useWrapper);
if (!simpleType.isBuiltInType()) {
xsDouble.setFacets(simpleType);
}
return xsDouble;
case SimpleTypesFactory.DURATION_TYPE: //-- duration
XSDuration xsDuration = new XSDuration();
if (!simpleType.isBuiltInType()) {
xsDuration.setFacets(simpleType);
}
return xsDuration;
case SimpleTypesFactory.DECIMAL_TYPE: //-- decimal
XSDecimal xsDecimal = new XSDecimal();
if (!simpleType.isBuiltInType()) {
xsDecimal.setFacets(simpleType);
}
return xsDecimal;
case SimpleTypesFactory.FLOAT_TYPE: //-- float
XSFloat xsFloat = new XSFloat(useWrapper);
if (!simpleType.isBuiltInType()) {
xsFloat.setFacets(simpleType);
}
return xsFloat;
case SimpleTypesFactory.GDAY_TYPE: //--GDay
XSGDay xsGDay = new XSGDay();
if (!simpleType.isBuiltInType()) {
xsGDay.setFacets(simpleType);
}
return xsGDay;
case SimpleTypesFactory.GMONTHDAY_TYPE: //--GMonthDay
XSGMonthDay xsGMonthDay = new XSGMonthDay();
if (!simpleType.isBuiltInType()) {
xsGMonthDay.setFacets(simpleType);
}
return xsGMonthDay;
case SimpleTypesFactory.GMONTH_TYPE: //--GMonth
XSGMonth xsGMonth = new XSGMonth();
if (!simpleType.isBuiltInType()) {
xsGMonth.setFacets(simpleType);
}
return xsGMonth;
case SimpleTypesFactory.GYEARMONTH_TYPE: //--GYearMonth
XSGYearMonth xsGYearMonth = new XSGYearMonth();
if (!simpleType.isBuiltInType()) {
xsGYearMonth.setFacets(simpleType);
}
return xsGYearMonth;
case SimpleTypesFactory.GYEAR_TYPE: //--GYear
XSGYear xsGYear = new XSGYear();
if (!simpleType.isBuiltInType()) {
xsGYear.setFacets(simpleType);
}
return xsGYear;
case SimpleTypesFactory.INTEGER_TYPE: //-- integer
XSInteger xsInteger = new XSInteger(useWrapper);
if (!simpleType.isBuiltInType()) {
xsInteger.setFacets(simpleType);
}
return xsInteger;
case SimpleTypesFactory.INT_TYPE: //-- int
XSInt xsInt = new XSInt(useWrapper);
if (!simpleType.isBuiltInType()) {
xsInt.setFacets(simpleType);
}
return xsInt;
case SimpleTypesFactory.LANGUAGE_TYPE: //-- Language
//-- since we don't actually support this type, yet, we'll simply treat
//-- it as a string, but warn the user.
LOG.warn("Warning: Currently, the W3C datatype '" + simpleType.getName()
+ "' is supported only as a String by Castor Source Generator.");
return new XSString();
case SimpleTypesFactory.LONG_TYPE: //-- long
XSLong xsLong = new XSLong(useWrapper);
if (!simpleType.isBuiltInType()) {
xsLong.setFacets(simpleType);
}
return xsLong;
case SimpleTypesFactory.NCNAME_TYPE: //--NCName
return new XSNCName();
case SimpleTypesFactory.NON_POSITIVE_INTEGER_TYPE: //-- nonPositiveInteger
XSNonPositiveInteger xsNPInteger = new XSNonPositiveInteger(useWrapper);
xsNPInteger.setFacets(simpleType);
return xsNPInteger;
case SimpleTypesFactory.NON_NEGATIVE_INTEGER_TYPE: //-- nonNegativeInteger
XSNonNegativeInteger xsNNInteger = new XSNonNegativeInteger(useWrapper);
xsNNInteger.setFacets(simpleType);
return xsNNInteger;
case SimpleTypesFactory.NEGATIVE_INTEGER_TYPE: //-- negative-integer
XSNegativeInteger xsNInteger = new XSNegativeInteger(useWrapper);
xsNInteger.setFacets(simpleType);
return xsNInteger;
case SimpleTypesFactory.UNSIGNED_INT_TYPE: //-- unsigned-integer
XSUnsignedInt xsUnsignedInt = new XSUnsignedInt(useWrapper);
xsUnsignedInt.setFacets(simpleType);
return xsUnsignedInt;
case SimpleTypesFactory.UNSIGNED_SHORT_TYPE: //-- unsigned-short
XSUnsignedShort xsUnsignedShort = new XSUnsignedShort(useWrapper);
xsUnsignedShort.setFacets(simpleType);
return xsUnsignedShort;
case SimpleTypesFactory.UNSIGNED_BYTE_TYPE: //-- unsigned-byte
XSUnsignedByte xsUnsignedByte = new XSUnsignedByte(useWrapper);
xsUnsignedByte.setFacets(simpleType);
return xsUnsignedByte;
case SimpleTypesFactory.UNSIGNED_LONG_TYPE: //-- unsigned-long
XSUnsignedLong xsUnsignedLong = new XSUnsignedLong();
xsUnsignedLong.setFacets(simpleType);
return xsUnsignedLong;
case SimpleTypesFactory.NORMALIZEDSTRING_TYPE: //-- normalizedString
XSNormalizedString xsNormalString = new XSNormalizedString();
if (!simpleType.isBuiltInType()) {
xsNormalString.setFacets(simpleType);
}
return xsNormalString;
case SimpleTypesFactory.POSITIVE_INTEGER_TYPE: //-- positive-integer
XSPositiveInteger xsPInteger = new XSPositiveInteger(useWrapper);
xsPInteger.setFacets(simpleType);
return xsPInteger;
case SimpleTypesFactory.QNAME_TYPE: //-- QName
XSQName xsQName = new XSQName();
xsQName.setFacets(simpleType);
return xsQName;
case SimpleTypesFactory.STRING_TYPE: //-- string
xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName);
if (xsType == null) {
// Not an enumerated String type
XSString xsString = new XSString();
if (!simpleType.isBuiltInType()) {
xsString.setFacets(simpleType);
}
xsType = xsString;
}
break;
case SimpleTypesFactory.SHORT_TYPE: //-- short
XSShort xsShort = new XSShort(useWrapper);
if (!simpleType.isBuiltInType()) {
xsShort.setFacets(simpleType);
}
return xsShort;
case SimpleTypesFactory.TIME_TYPE: //-- time
XSTime xsTime = new XSTime();
if (!simpleType.isBuiltInType()) {
xsTime.setFacets(simpleType);
}
return xsTime;
case SimpleTypesFactory.TOKEN_TYPE: //-- token
//-- since we don't actually support this type, yet, we'll simply treat
//-- it as a string, but warn the user.
LOG.warn("Warning: Currently, the W3C datatype 'token'"
+ " is supported only as a String by Castor Source Generator.");
XSString xsString = new XSString();
if (!simpleType.isBuiltInType()) {
xsString.setFacets(simpleType);
}
return xsString;
default: //-- error
String name = simpleType.getName();
if (name == null || name.length() == 0) {
//--we know it is a restriction
name = simpleType.getBuiltInBaseType().getName();
}
LOG.warn("Warning: The W3C datatype '" + name + "' "
+ "is not currently supported by Castor Source Generator.");
String className = _config.getJavaNaming().toJavaClassName(name);
xsType = new XSClass(new JClass(className));
break;
}
return xsType;
} //-- convertType