KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > asm > Relation


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26
27 package org.aspectj.asm;
28
29 import java.util.*;
30 import java.io.Serializable JavaDoc;
31 import org.aspectj.compiler.base.ast.ASTObject;
32
33 /**
34  * @author Mik Kersten
35  */

36 public class Relation implements Serializable JavaDoc {
37
38     private String JavaDoc forwardNavigationName;
39     private String JavaDoc backNavigationName;
40     private String JavaDoc associationName;
41     private boolean symmetrical;
42     private boolean transitive;
43
44     public Relation(String JavaDoc forwardNavigationName,
45                     String JavaDoc backNavigationName,
46                     String JavaDoc associationName,
47                     boolean symmetrical,
48                     boolean transitive) {
49         this.forwardNavigationName = forwardNavigationName;
50         this.backNavigationName = backNavigationName;
51         this.associationName = associationName;
52         this.symmetrical = symmetrical;
53         this.transitive = transitive;
54     }
55
56     /**
57      * Constructor for asymetrical relations.
58      */

59     public Relation(String JavaDoc forwardNavigationName,
60                     String JavaDoc associationName,
61                     boolean transitive) {
62         this(forwardNavigationName, "<no back navigation name>", associationName, false, transitive);
63     }
64
65     public String JavaDoc getForwardNavigationName() {
66         return forwardNavigationName;
67     }
68
69     public String JavaDoc getBackNavigationName() {
70         return backNavigationName;
71     }
72
73     public String JavaDoc getAssociationName() {
74         return associationName;
75     }
76
77     public boolean isSymmetrical() {
78         return symmetrical;
79     }
80
81     public boolean isTransitive() {
82         return transitive;
83     }
84
85     public boolean equals(Object JavaDoc o) {
86         if (!(o instanceof Relation)) return false;
87         Relation r = (Relation)o;
88         return forwardNavigationName.equals(r.getForwardNavigationName())
89             && backNavigationName.equals(r.getBackNavigationName())
90             && associationName.equals(r.getAssociationName())
91             && (symmetrical == r.isSymmetrical())
92             && (transitive == r.isTransitive());
93     }
94
95     public String JavaDoc toString() {
96         if (symmetrical) {
97             return forwardNavigationName + " / " + backNavigationName;
98         } else {
99             return forwardNavigationName;
100         }
101     }
102 }
Popular Tags