001package org.andromda.cartridges.xmlschema.metafacades;
002
003/**
004 * MetafacadeLogic implementation for org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEnd.
005 *
006 * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEnd
007 */
008public class XSDAssociationEndLogicImpl
009        extends XSDAssociationEndLogic
010{
011    private static final long serialVersionUID = 34L;
012    // ---------------- constructor -------------------------------
013
014    /**
015     * @param metaObject
016     * @param context
017     */
018    public XSDAssociationEndLogicImpl(Object metaObject, String context)
019    {
020        super(metaObject, context);
021    }
022
023    /**
024     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEndLogic#handleGetMaxOccurs()
025     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEnd#getMaxOccurs()
026     */
027    protected String handleGetMaxOccurs()
028    {
029        String maxOccurs = null;
030        boolean isMany = this.isMany();
031        if (isMany)
032        {
033            maxOccurs = "unbounded";
034        }
035        else
036        {
037            maxOccurs = "1";
038        }
039        return maxOccurs;
040    }
041
042    /**
043     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEndLogic#handleGetMinOccurs()
044     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEnd#getMinOccurs()
045     */
046    protected String handleGetMinOccurs()
047    {
048        String minOccurs = null;
049        boolean isRequired = this.isRequired();
050        if (isRequired)
051        {
052            minOccurs = "1";
053        }
054        else
055        {
056            minOccurs = "0";
057        }
058        return minOccurs;
059    }
060
061    /**
062     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEndLogic#handleIsOwnerSchemaType()
063     * @see org.andromda.cartridges.xmlschema.metafacades.XSDAssociationEnd#isOwnerSchemaType()
064     */
065    protected boolean handleIsOwnerSchemaType()
066    {
067        final Object owner = this.getType();
068        return owner instanceof XSDComplexType || owner instanceof XSDEnumerationType;
069    }
070
071}