KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > map > event > RelationshipEvent


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.map.event;
21
22 import org.apache.cayenne.map.Entity;
23 import org.apache.cayenne.map.Relationship;
24
25 /**
26  * Represents events resulted from Relationship changes
27  * in CayenneModeler. This event is used for both ObjRelationships
28  * and DbRelationships.
29  *
30  *
31  * @author Misha Shengaout
32  * @author Andrus Adamchik
33  */

34 public class RelationshipEvent extends EntityEvent {
35     protected Relationship relationship;
36
37     /** Creates a Relationship change event. */
38     public RelationshipEvent(Object JavaDoc src, Relationship rel, Entity entity) {
39         super(src, entity);
40         setRelationship(rel);
41     }
42
43     /** Creates a Relationship event of a specified type. */
44     public RelationshipEvent(
45         Object JavaDoc src,
46         Relationship rel,
47         Entity entity,
48         int id) {
49
50         this(src, rel, entity);
51         setId(id);
52     }
53
54     /** Creates a Relationship name change event. */
55     public RelationshipEvent(
56         Object JavaDoc src,
57         Relationship rel,
58         Entity entity,
59         String JavaDoc oldName) {
60             
61         this(src, rel, entity);
62         setOldName(oldName);
63     }
64
65     /** Returns relationship associated with this event. */
66     public Relationship getRelationship() {
67         return relationship;
68     }
69
70     /**
71      * Sets relationship associated with this event.
72      *
73      * @param relationship The relationship to set
74      */

75     public void setRelationship(Relationship relationship) {
76         this.relationship = relationship;
77     }
78     
79     public String JavaDoc getNewName() {
80         return (relationship != null) ? relationship.getName() : null;
81     }
82 }
83
Popular Tags