KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > mdr > events > AttributeEvent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.api.mdr.events;
20
21 import javax.jmi.reflect.RefFeatured;
22
23 /** Class represeting MDR events related to changes
24  * of repository object (class/instance) attributes.
25  *
26  * @author Martin Matula
27  */

28 public class AttributeEvent extends MDRChangeEvent {
29     /** Value indicating unspecified position */
30     public static final int POSITION_NONE = -1;
31
32     /** Bitmask representing all event types related to instance attribute changes */
33     public static final int EVENTMASK_ATTRIBUTE = 0x101FFFF;
34     /** Bitmask representing all event types related to classifier attribute changes */
35     public static final int EVENTMASK_CLASSATTR = 0x102FFFF;
36     
37     /** Event type indicating that a value of a single-valued instance attribute is to be/was changed or
38      * a value element of a multi-valued instance attribute is to be/was changed.
39      */

40     public static final int EVENT_ATTRIBUTE_SET = 0x1010001;
41     /** Event type indicating that a value element of a multi-valued instance attribute is to be/was added */
42     public static final int EVENT_ATTRIBUTE_ADD = 0x1010002;
43     /** Event type indicating that a value element of a multi-valued instance attribute is to be/was removed */
44     public static final int EVENT_ATTRIBUTE_REMOVE = 0x1010004;
45
46     /** Event type indicating that a value of a single-valued classifier attribute is to be/was changed or
47      * a value element of a multi-valued classifier attribute is to be/was changed.
48      */

49     public static final int EVENT_CLASSATTR_SET = 0x1020001;
50     /** Event type indicating that a value element of a multi-valued classifier attribute is to be/was added
51      */

52     public static final int EVENT_CLASSATTR_ADD = 0x1020002;
53     /** Event type indicating that a value element of a multi-valued classifier attribute is to be/was removed
54      */

55     public static final int EVENT_CLASSATTR_REMOVE = 0x1020004;
56
57     private final String JavaDoc attrName;
58     private final Object JavaDoc oldElement;
59     private final Object JavaDoc newElement;
60     private final int position;
61
62     /** Creates new AttributeEvent instance.
63      * @param source Event source (class proxy or instance).
64      * @param type Event type.
65      * @param attrName Name of the attribute that was changed.
66      * @param oldElement Original attribute value (for single-valued) or value element (for multi-valued attribute) or null if not applicable (e.g. in case of ADD event).
67      * @param newElement New attribute value (for single-valued) or value element (for multi-valued attribute) or null if not applicable (e.g. in case of REMOVE event).
68      * @param position Position of the affected element or POSITION_NONE if not applicable (e.g. in case of unordered multi-valued attributes).
69      */

70     public AttributeEvent(RefFeatured source, int type, String JavaDoc attrName, Object JavaDoc oldElement, Object JavaDoc newElement, int position) {
71         super(source, type);
72         this.attrName = attrName;
73         this.oldElement = oldElement;
74         this.newElement = newElement;
75         this.position = position;
76     }
77
78     /** Returns name of an attribute affected by this event.
79      * @return Attribute name.
80      */

81     public String JavaDoc getAttributeName() {
82         return attrName;
83     }
84
85     /** Returns original value of the element affected by this event or null if not applicable.
86      * @return Original value of element.
87      */

88     public Object JavaDoc getOldElement() {
89         return oldElement;
90     }
91
92     /** Returns a new value of the element affected by this event or null if not applicable.
93      * @return New element value.
94      */

95     public Object JavaDoc getNewElement() {
96         return newElement;
97     }
98
99     /** Returns original position of element affected by this event or {@link #POSITION_NONE} if not applicable.
100      * @return Original position of affected element.
101      */

102     public int getPosition() {
103         return position;
104     }
105 }
106
Popular Tags