001package org.andromda.cartridges.xmlschema.metafacades;
002
003import org.andromda.cartridges.xmlschema.XmlSchemaProfile;
004
005/**
006 * MetafacadeLogic implementation for org.andromda.cartridges.xmlschema.metafacades.XSDAttribute.
007 *
008 * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute
009 */
010public class XSDAttributeLogicImpl
011        extends XSDAttributeLogic
012{
013    private static final long serialVersionUID = 34L;
014    // ---------------- constructor -------------------------------
015
016    /**
017     * @param metaObject
018     * @param context
019     */
020    public XSDAttributeLogicImpl(Object metaObject, String context)
021    {
022        super(metaObject, context);
023    }
024
025    /**
026     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttributeLogic#handleGetMaxOccurs()
027     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute#getMaxOccurs()
028     */
029    protected String handleGetMaxOccurs()
030    {
031        String maxOccurs = null;
032        boolean isMany = this.isMany();
033        if (isMany)
034        {
035            maxOccurs = "unbounded";
036        }
037        else
038        {
039            maxOccurs = "1";
040        }
041        return maxOccurs;
042    }
043
044    /**
045     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttributeLogic#handleGetMinOccurs()
046     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute#getMinOccurs()
047     */
048    protected String handleGetMinOccurs()
049    {
050        String minOccurs = null;
051        boolean isRequired = this.isRequired();
052        if (isRequired)
053        {
054            minOccurs = "1";
055        }
056        else
057        {
058            minOccurs = "0";
059        }
060        return minOccurs;
061    }
062
063    /**
064     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttributeLogic#handleIsXsdAttribute()
065     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute#isXsdAttribute()
066     */
067    protected boolean handleIsXsdAttribute()
068    {
069        return this.hasStereotype(XmlSchemaProfile.STEREOTYPE_XML_ATTRIBUTE);
070    }
071
072    /**
073     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute#isXsdElement()
074     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttributeLogic#handleIsXsdElement()
075     */
076    protected boolean handleIsXsdElement()
077    {
078        return !this.isXsdAttribute();
079    }
080
081    /**
082     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttributeLogic#handleIsOwnerSchemaType()
083     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAttribute#isOwnerSchemaType()
084     */
085    protected boolean handleIsOwnerSchemaType()
086    {
087        final Object owner = this.getOwner();
088        return owner instanceof XSDComplexType || owner instanceof XSDEnumerationType;
089    }
090
091}