001    /*
002      Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
003    
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser General Public
015      License along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017      USA */
018    
019    package org.objectweb.jac.ide;
020    
021    import org.objectweb.jac.util.Strings;
022    
023    
024    public class Role extends ModelElement implements Typed {
025    
026        public Role(Link link) {
027            this.link = link;
028        }
029    
030        public Role() {
031        }
032    
033        /** The link this role belongs to */
034        Link link;
035        public Link getLink() {
036            return link;
037        }
038        
039        public void setLink(Link link) {
040            this.link = link;
041        }
042        
043    
044        ModelElement end;
045        /**
046         * Gets the model element on which the link ends.
047         * 
048         * @return ending element */
049        public ModelElement getEnd() {
050            return end;
051        }   
052        /**
053         * Sets the value of the ending element.
054         */
055        public void setEnd(ModelElement end) {
056            this.end = end;
057        }
058    
059        ModelElement start;
060        /**
061         * Gets the model element from which the link starts.
062         * 
063         * @return starting element */
064        public ModelElement getStart() {
065            return start;
066        }   
067        /**
068         * Sets the value of the starting element.
069         */
070        public void setStart(ModelElement start) {
071            this.start = start;
072        }
073    
074        public Role oppositeRole() {
075            if (link.getStartRole()==this)
076                return link.getEndRole();
077            else
078                return link.getStartRole();
079        }
080    
081        public boolean isStartRole() {
082            return link.getStartRole()==this;
083        }
084    
085        public boolean isEndRole() {
086            return link.getEndRole()==this;
087        }
088    
089        public String getGenerationName() {
090            return Strings.toUSAscii(getName());
091        }
092    
093        public String getGenerationFullName() {
094            return Strings.toUSAscii(getFullName());
095        }
096    
097    }