Index: org/exolab/castor/xml/schema/reader/ComplexTypeUnmarshaller.java =================================================================== --- org/exolab/castor/xml/schema/reader/ComplexTypeUnmarshaller.java (Revision 7373) +++ org/exolab/castor/xml/schema/reader/ComplexTypeUnmarshaller.java (Arbeitskopie) @@ -58,7 +58,6 @@ import org.exolab.castor.xml.schema.ElementDecl; import org.exolab.castor.xml.schema.Group; import org.exolab.castor.xml.schema.ModelGroup; -import org.exolab.castor.xml.schema.Resolver; import org.exolab.castor.xml.schema.Schema; import org.exolab.castor.xml.schema.SchemaException; import org.exolab.castor.xml.schema.SchemaNames; @@ -66,18 +65,48 @@ import org.exolab.castor.xml.schema.XMLType; /** - * A class for Unmarshalling ComplexTypes + * A class for unmarshalling XML Schema definitions. * @author Keith Visco * @version $Revision$ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $ **/ public class ComplexTypeUnmarshaller extends ComponentReader { - - //--------------------/ - //- Member Variables -/ - //--------------------/ - /** + * Represents the textual representation of the value '0' + */ + private static final String VALUE_0 = "0"; + + /** + * Represents the textual representation of the value '1' + */ + private static final String VALUE_1 = "1"; + + /** + * Represents the textual representation of the value 'false' + */ + private static final String VALUE_FALSE = "false"; + + /** + * Represents the textual representation of the value 'true' + */ + private static final String VALUE_TRUE = "true"; + + /** + * Represents the XML schema keyword 'restrictions' + */ + private static final String KEYWORD_RESTRICTIONS = "restrictions"; + + /** + * Represents the XML schema keyword 'extensions' + */ + private static final String KEYWORD_EXTENSION = "extension"; + + /** + * Represents the XML schema keyword 'derivedBy' + */ + private static final String KEYWORD_DERIVED_BY = "derivedBy"; + + /** * The current ComponentReader **/ private ComponentReader unmarshaller; @@ -91,28 +120,22 @@ * The Attribute reference for the Attribute we are constructing **/ private ComplexType _complexType = null; - private boolean allowAnnotation = true; - private boolean foundAnnotation = false; - private boolean foundAnyAttribute = false; - private boolean foundAttributes = false; - private boolean foundSimpleContent = false; + private boolean allowAnnotation = true; + private boolean foundAnnotation = false; + private boolean foundAnyAttribute = false; + private boolean foundAttributes = false; + private boolean foundSimpleContent = false; private boolean foundComplexContent = false; - private boolean foundModelGroup = false; + private boolean foundModelGroup = false; - - private Schema _schema = null; - - //----------------/ - //- Constructors -/ - //----------------/ - /** - * Creates a new ComplexTypeUnmarshaller. - * @param internalContext the internalContext to get some configuration settings from - * @param schema the Schema to which the ComplexType belongs - * @param atts the AttributeList + * Creates a new {@link ComplexTypeUnmarshaller} instance. + * @param internalContext the {@link InternalContext} instance to get some configuration settings from + * @param schema the {@link Schema} to which the {@link ComplexType} belongs. + * @param atts the attribute list associated with this {@link ComplexType}. + * @see Schema **/ public ComplexTypeUnmarshaller( final InternalContext internalContext, @@ -136,21 +159,23 @@ String content = atts.getValue(SchemaNames.MIXED); if (content != null) { - if (content.equals("true")) - _complexType.setContentType(ContentType.valueOf("mixed")); - if (content.equals("false")) - _complexType.setContentType(ContentType.valueOf("elementOnly")); + if (content.equals(VALUE_TRUE) || content.equals(VALUE_1)) { + _complexType.setContentType(ContentType.mixed); + } + if (content.equals(VALUE_FALSE) || content.equals(VALUE_0)) { + _complexType.setContentType(ContentType.elemOnly); + } } //-- base and derivedBy String base = atts.getValue(SchemaNames.BASE_ATTR); if ((base != null) && (base.length() > 0)) { - String derivedBy = atts.getValue("derivedBy"); + String derivedBy = atts.getValue(KEYWORD_DERIVED_BY); _complexType.setDerivationMethod(derivedBy); if ((derivedBy == null) || (derivedBy.length() == 0) || - (derivedBy.equals("extension"))) + (derivedBy.equals(KEYWORD_EXTENSION))) { XMLType baseType= schema.getType(base); if (baseType == null) @@ -158,7 +183,7 @@ else _complexType.setBaseType(baseType); } - else if (derivedBy.equals("restrictions")) { + else if (derivedBy.equals(KEYWORD_RESTRICTIONS)) { String err = "restrictions not yet supported for ."; throw new SchemaException(err); }