1 23 24 29 30 package com.sun.jdo.api.persistence.model.mapping.impl; 31 32 import java.beans.PropertyVetoException ; 33 34 import com.sun.jdo.api.persistence.model.ModelException; 35 import com.sun.jdo.api.persistence.model.ModelVetoException; 36 import com.sun.jdo.api.persistence.model.mapping.*; 37 38 44 public abstract class MappingMemberElementImpl extends MappingElementImpl 45 implements MappingMemberElement 46 { 47 48 MappingClassElement _declaringClass; 49 50 54 public MappingMemberElementImpl () 55 { 56 this(null, null); 57 } 58 59 64 public MappingMemberElementImpl (String name, 65 MappingClassElement declaringClass) 66 { 67 super(name); 68 _declaringClass = declaringClass; 69 } 70 71 75 public MappingClassElement getDeclaringClass () { return _declaringClass; } 76 77 85 public boolean equals (Object obj) 86 { 87 if (super.equals(obj) && (obj instanceof MappingMemberElement)) 88 { 89 MappingClassElement declaringClass = getDeclaringClass(); 90 MappingClassElement objDeclaringClass = 91 ((MappingMemberElement)obj).getDeclaringClass(); 92 93 return ((declaringClass == null) ? (objDeclaringClass == null) : 94 declaringClass.equals(objDeclaringClass)); 95 } 96 97 return false; 98 } 99 100 104 public int hashCode () 105 { 106 MappingClassElement declaringClass = getDeclaringClass(); 107 108 return (super.hashCode() + 109 ((declaringClass == null) ? 0 : declaringClass.hashCode())); 110 } 111 112 119 protected final void firePropertyChange (String name, Object o, Object n) 120 { 121 boolean noChange = ((o != null) && (n != null) && o.equals(n)); 125 MappingClassElement classElement = getDeclaringClass(); 126 127 super.firePropertyChange(name, o, n); 128 129 if ((classElement != null) && !noChange) 130 classElement.setModified(true); 131 } 132 133 141 protected final void fireVetoableChange (String name, Object o, Object n) 142 throws PropertyVetoException 143 { 144 boolean noChange = ((o != null) && (n != null) && o.equals(n)); 148 MappingClassElement classElement = getDeclaringClass(); 149 150 super.fireVetoableChange(name, o, n); 151 152 if ((classElement != null) && !noChange) 153 { 154 ((MappingClassElementImpl)classElement).fireVetoableChange( 155 PROP_MODIFIED, Boolean.FALSE, Boolean.TRUE); 156 } 157 } 158 159 161 165 public void setDeclaringClass (MappingClassElement declaringClass) 166 { 167 _declaringClass = declaringClass; 168 } 169 } 170 | Popular Tags |