if (name == null) {
throw new IllegalArgumentException(SDOException.errorDefiningTypeNoName());
}
SDOType type = (SDOType)typeHelper.getType(uri, name);
if (null != type) {
return type;
}
boolean isDataType = dataObject.getBoolean("dataType");
if(isDataType) {
type = new SDODataType(uri, name, this);
} else {
type = new SDOType(uri, name, this);
if (dataObject.getBoolean("sequenced")) {
type.setSequenced(true);
type.setMixed(true);
}
}
type.setDataType(isDataType);
addType(type);
types.add(type);
type.setAbstract(dataObject.getBoolean("abstract"));
List baseTypes = dataObject.getList("baseType");
for (int i = 0; i < baseTypes.size(); i++) {
SDOType baseType = (SDOType)getValueFromObject(baseTypes.get(i), types);
type.addBaseType(baseType);
}
List aliasNames = dataObject.getList("aliasName");
for (int i = 0; i < aliasNames.size(); i++) {
Object aliasName = aliasNames.get(i);
type.getAliasNames().add(aliasName);
}
List openProps = ((SDODataObject)dataObject)._getOpenContentProperties();
for (int i = 0; i < openProps.size(); i++) {
SDOProperty nextProp = (SDOProperty)openProps.get(i);
Object value = getValueFromObject(dataObject.get(nextProp), types);
type.setInstanceProperty(nextProp, value);
}
List openPropsAttrs = ((SDODataObject)dataObject)._getOpenContentPropertiesAttributes();
for (int i = 0; i < openPropsAttrs.size(); i++) {
SDOProperty nextProp = (SDOProperty)openPropsAttrs.get(i);
Object value = getValueFromObject(dataObject.get(nextProp), types);
type.setInstanceProperty(nextProp, value);
}
if (!type.isDataType()) {
type.preInitialize(null, null);
}
List properties = dataObject.getList("property");
for (int i = 0; i < properties.size(); i++) {
Object nextValue = properties.get(i);
if (nextValue instanceof DataObject) {
buildPropertyFromDataObject((DataObject)nextValue, type, types);
}
}
type.setOpen(dataObject.getBoolean("open"));
if (type.isDataType()) {
QName typeQName = new QName(XMLConstants.SCHEMA_URL, name);
if (typeHelper.getWrappersHashMap().get(typeQName) != null) {
// In the case of a non-user-defined simple type, we already have built-in
// wrappers created, so do not continue on building a new WrapperType.
return type;
}
// Defining a new simple type from a DataObject.
// See also: SDOTypesGenerator:startNewSimpleType for "types from XSD" equivalent
// If this simple type is a restriction, get the QName for the base type and
// include it when creating the WrapperType. The QName will be used during
// conversions (eg. "myBinaryElement" could be a restriction of base64Binary
// or hexBinary.
QName currentTypeQName = null;
if (!type.getBaseTypes().isEmpty()) {
SDOType baseType = (SDOType) type.getBaseTypes().get(0);
currentTypeQName = new QName(XMLConstants.SCHEMA_URL, baseType.getName());
}
// Create the new WrapperType
SDOWrapperType wrapperType = new SDOWrapperType(type, name, this, currentTypeQName);