KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > Role


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.ide;
20
21 import org.objectweb.jac.util.Strings;
22
23
24 public class Role extends ModelElement implements Typed {
25
26     public Role(Link link) {
27         this.link = link;
28     }
29
30     public Role() {
31     }
32
33     /** The link this role belongs to */
34     Link link;
35     public Link getLink() {
36         return link;
37     }
38     
39     public void setLink(Link link) {
40         this.link = link;
41     }
42     
43
44     ModelElement end;
45     /**
46      * Gets the model element on which the link ends.
47      *
48      * @return ending element */

49     public ModelElement getEnd() {
50         return end;
51     }
52     /**
53      * Sets the value of the ending element.
54      */

55     public void setEnd(ModelElement end) {
56         this.end = end;
57     }
58
59     ModelElement start;
60     /**
61      * Gets the model element from which the link starts.
62      *
63      * @return starting element */

64     public ModelElement getStart() {
65         return start;
66     }
67     /**
68      * Sets the value of the starting element.
69      */

70     public void setStart(ModelElement start) {
71         this.start = start;
72     }
73
74     public Role oppositeRole() {
75         if (link.getStartRole()==this)
76             return link.getEndRole();
77         else
78             return link.getStartRole();
79     }
80
81     public boolean isStartRole() {
82         return link.getStartRole()==this;
83     }
84
85     public boolean isEndRole() {
86         return link.getEndRole()==this;
87     }
88
89     public String JavaDoc getGenerationName() {
90         return Strings.toUSAscii(getName());
91     }
92
93     public String JavaDoc getGenerationFullName() {
94         return Strings.toUSAscii(getFullName());
95     }
96
97 }
98
Popular Tags