* the schema
* @throws XMLSchemaFileImportException
*/
private static void readObjectClass( Element element, Schema schema ) throws XMLSchemaFileImportException
{
ObjectClassImpl oc = null;
// OID
Attribute oidAttribute = element.attribute( OID_TAG );
if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
{
oc = new ObjectClassImpl( oidAttribute.getValue() );
}
else
{
throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoOIDInClass" ) ); //$NON-NLS-1$
}
// Schema
oc.setSchema( schema.getName() );
oc.setSchemaObject( schema );
// Aliases
Element aliasesElement = element.element( ALIASES_TAG );
if ( aliasesElement != null )
{
List<String> aliases = new ArrayList<String>();
for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); )
{
Element aliasElement = ( Element ) i.next();
aliases.add( aliasElement.getText() );
}
if ( aliases.size() >= 1 )
{
oc.setNames( aliases.toArray( new String[0] ) );
}
}
// Description
Element descriptionElement = element.element( DESCRIPTION_TAG );
if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$
{
oc.setDescription( descriptionElement.getText() );
}
// Superiors
Element superiorsElement = element.element( SUPERIORS_TAG );
if ( superiorsElement != null )
{
List<String> superiors = new ArrayList<String>();
for ( Iterator<?> i = superiorsElement.elementIterator( SUPERIOR_TAG ); i.hasNext(); )
{
Element superiorElement = ( Element ) i.next();
superiors.add( superiorElement.getText() );
}
if ( superiors.size() >= 1 )
{
oc.setSuperClassesNames( superiors.toArray( new String[0] ) );
}
}
// Class Type
Element classTypeElement = element.element( TYPE_TAG );
if ( ( classTypeElement != null ) && ( !classTypeElement.getText().equals( "" ) ) ) //$NON-NLS-1$
{
try
{
oc.setType( ObjectClassTypeEnum.valueOf( classTypeElement.getText() ) );
}
catch ( IllegalArgumentException e )
{
throw new XMLSchemaFileImportException(
Messages.getString( "XMLSchemaFileImporter.UnconvertableValue" ), e ); //$NON-NLS-1$
}
}
// Obsolete
Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG );
if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
{
oc.setObsolete( readBoolean( obsoleteAttribute.getValue() ) );
}
// Mandatory Attribute Types
Element mandatoryElement = element.element( MANDATORY_TAG );
if ( mandatoryElement != null )
{
List<String> mandatoryATs = new ArrayList<String>();
for ( Iterator<?> i = mandatoryElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); )
{
Element attributeTypeElement = ( Element ) i.next();
mandatoryATs.add( attributeTypeElement.getText() );
}
if ( mandatoryATs.size() >= 1 )
{
oc.setMustNamesList( mandatoryATs.toArray( new String[0] ) );
}
}
// Optional Attribute Types
Element optionalElement = element.element( OPTIONAL_TAG );
if ( optionalElement != null )
{
List<String> optionalATs = new ArrayList<String>();
for ( Iterator<?> i = optionalElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); )
{
Element attributeTypeElement = ( Element ) i.next();
optionalATs.add( attributeTypeElement.getText() );
}
if ( optionalATs.size() >= 1 )
{
oc.setMayNamesList( optionalATs.toArray( new String[0] ) );
}
}
// Adding the object class to the schema
schema.addObjectClass( oc );