KickJava   Java API By Example, From Geeks To Geeks.

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


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.Attribute;
23 import org.apache.cayenne.map.Entity;
24
25 /**
26  * Represents events resulted from Attribute changes
27  * in CayenneModeler. This event is used for both ObjAttributes
28  * and DbAttributes.
29  *
30  * @author Misha Shengaout
31  * @author Andrus Adamchik
32  */

33 public class AttributeEvent extends EntityEvent {
34     protected Attribute attribute;
35
36     /** Creates a Attribute change event. */
37     public AttributeEvent(Object JavaDoc src, Attribute attr, Entity entity) {
38         super(src, entity);
39         setAttribute(attr);
40     }
41
42     /** Creates a Attribute event of a specified type. */
43     public AttributeEvent(Object JavaDoc src, Attribute attr, Entity entity, int id) {
44         this(src, attr, entity);
45         setId(id);
46     }
47
48     /** Creates a Attribute name change event.*/
49     public AttributeEvent(Object JavaDoc src, Attribute attr, Entity entity, String JavaDoc oldName) {
50
51         this(src, attr, entity);
52         setOldName(oldName);
53     }
54
55     /** Get attribute (obj or db). */
56     public Attribute getAttribute() {
57         return attribute;
58     }
59
60     /**
61      * Sets the attribute.
62      * @param attribute The attribute to set
63      */

64     public void setAttribute(Attribute attribute) {
65         this.attribute = attribute;
66     }
67
68     public String JavaDoc getNewName() {
69         return (attribute != null) ? attribute.getName() : null;
70     }
71 }
72
Popular Tags