KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > model > jdo > impl > PersistenceMemberElementImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * PersistenceMemberElementImpl.java
26  *
27  * Created on March 2, 2000, 5:17 PM
28  */

29
30 package com.sun.jdo.api.persistence.model.jdo.impl;
31
32 import java.beans.PropertyVetoException JavaDoc;
33
34 import com.sun.jdo.api.persistence.model.jdo.PersistenceMemberElement;
35 import com.sun.jdo.api.persistence.model.jdo.PersistenceClassElement;
36
37 /**
38  *
39  * @author raccah
40  * @version %I%
41  */

42 public abstract class PersistenceMemberElementImpl
43     extends PersistenceElementImpl implements PersistenceMemberElement.Impl
44 {
45     /** Create new PersistenceMemberElementImpl with no corresponding name.
46      * This constructor should only be used for cloning and archiving.
47      */

48     public PersistenceMemberElementImpl ()
49     {
50         this(null);
51     }
52
53     /** Creates new PersistenceMemberElementImpl with the corresponding name
54      * @param name the name of the element
55      */

56     public PersistenceMemberElementImpl (String JavaDoc name)
57     {
58         super(name);
59     }
60
61     /** Fires property change event. This method overrides that of
62      * PersistenceElementImpl to update the PersistenceClassElementImpl's
63      * modified status.
64      * @param name property name
65      * @param o old value
66      * @param n new value
67      */

68     protected final void firePropertyChange (String JavaDoc name, Object JavaDoc o, Object JavaDoc n)
69     {
70         // even though o == null and n == null will signify a change, that
71
// is consistent with PropertyChangeSupport's behavior and is
72
// necessary for this to work
73
boolean noChange = ((o != null) && (n != null) && o.equals(n));
74         PersistenceClassElement classElement =
75             ((PersistenceMemberElement)_element).getDeclaringClass();
76
77         super.firePropertyChange(name, o, n);
78
79         if ((classElement != null) && !noChange)
80             classElement.setModified(true);
81     }
82
83     /** Fires vetoable change event. This method overrides that of
84      * PersistenceElementImpl to give listeners a chance to block
85      * changes on the persistence class element modified status.
86      * @param name property name
87      * @param o old value
88      * @param n new value
89      * @exception PropertyVetoException when the change is vetoed by a listener
90      */

91     protected final void fireVetoableChange (String JavaDoc name, Object JavaDoc o, Object JavaDoc n)
92         throws PropertyVetoException JavaDoc
93     {
94         // even though o == null and n == null will signify a change, that
95
// is consistent with PropertyChangeSupport's behavior and is
96
// necessary for this to work
97
boolean noChange = ((o != null) && (n != null) && o.equals(n));
98         PersistenceClassElement classElement =
99             ((PersistenceMemberElement)_element).getDeclaringClass();
100
101         super.fireVetoableChange(name, o, n);
102
103         if ((classElement != null) && !noChange)
104         {
105             ((PersistenceElementImpl)classElement.getImpl()).
106                 fireVetoableChange(PROP_MODIFIED, Boolean.FALSE, Boolean.TRUE);
107         }
108     }
109 }
110
Popular Tags