1 19 package org.netbeans.tax; 20 21 import org.netbeans.tax.spec.DTD; 22 import org.netbeans.tax.spec.ParameterEntityReference; 23 import org.netbeans.tax.spec.DocumentType; 24 import org.netbeans.tax.spec.ConditionalSection; 25 26 31 public class TreeNotationDecl extends TreeNodeDecl implements DTD.Child, ParameterEntityReference.Child, DocumentType.Child, ConditionalSection.Child { 32 33 public static final String PROP_NAME = "name"; 35 public static final String PROP_PUBLIC_ID = "publicId"; 37 public static final String PROP_SYSTEM_ID = "systemId"; 39 40 41 private String name; 42 43 44 private String systemId; 45 46 47 private String publicId; 48 49 50 54 57 public TreeNotationDecl (String name, String publicId, String systemId) throws InvalidArgumentException { 58 super (); 59 60 checkName (name); 61 this.name = name; 62 63 checkPublicId (publicId); 64 checkSystemId (systemId); 65 checkExternalId (publicId, systemId); 66 this.systemId = systemId; 67 this.publicId = publicId; 68 } 69 70 71 72 protected TreeNotationDecl (TreeNotationDecl notationDecl) { 73 super (notationDecl); 74 75 this.name = notationDecl.name; 76 this.publicId = notationDecl.publicId; 77 this.systemId = notationDecl.systemId; 78 } 79 80 81 85 87 public Object clone () { 88 return new TreeNotationDecl (this); 89 } 90 91 93 public boolean equals (Object object, boolean deep) { 94 if (!!! super.equals (object, deep)) 95 return false; 96 97 TreeNotationDecl peer = (TreeNotationDecl) object; 98 if (!!! Util.equals (this.getName (), peer.getName ())) { 99 return false; 100 } 101 if (!!! Util.equals (this.getSystemId (), peer.getSystemId ())) { 102 return false; 103 } 104 if (!!! Util.equals (this.getPublicId (), peer.getPublicId ())) { 105 return false; 106 } 107 108 return true; 109 } 110 111 114 public void merge (TreeObject treeObject) throws CannotMergeException { 115 super.merge (treeObject); 116 117 TreeNotationDecl peer = (TreeNotationDecl) treeObject; 118 119 setNameImpl (peer.getName ()); 120 setSystemIdImpl (peer.getSystemId ()); 121 setPublicIdImpl (peer.getPublicId ()); 122 } 123 124 125 129 131 public String getName () { 132 return name; 133 } 134 135 137 private final void setNameImpl (String newName) { 138 String oldName = this.name; 139 140 this.name = newName; 141 142 firePropertyChange (PROP_NAME, oldName, newName); 143 } 144 145 149 public final void setName (String newName) throws ReadOnlyException, InvalidArgumentException { 150 if ( Util.equals (this.name, newName) ) 154 return; 155 checkReadOnly (); 156 checkName (newName); 157 158 setNameImpl (newName); 162 } 163 164 166 protected final void checkName (String name) throws InvalidArgumentException { 167 TreeUtilities.checkNotationDeclName (name); 168 } 169 170 172 public String getPublicId () { 173 return publicId; 174 } 175 176 178 private final void setPublicIdImpl (String newPublicId) { 179 String oldPublicId = this.publicId; 180 181 this.publicId = newPublicId; 182 183 firePropertyChange (PROP_PUBLIC_ID, oldPublicId, newPublicId); 184 } 185 186 190 public final void setPublicId (String newPublicId) throws ReadOnlyException, InvalidArgumentException { 191 if ( Util.equals (this.publicId, newPublicId) ) 195 return; 196 checkReadOnly (); 197 checkPublicId (newPublicId); 198 checkExternalId (newPublicId, this.systemId); 199 200 setPublicIdImpl (newPublicId); 204 } 205 206 208 protected final void checkPublicId (String publicId) throws InvalidArgumentException { 209 TreeUtilities.checkNotationDeclPublicId (publicId); 210 } 211 212 214 public String getSystemId () { 215 return systemId; 216 } 217 218 220 private final void setSystemIdImpl (String newSystemId) { 221 String oldSystemId = this.systemId; 222 223 this.systemId = newSystemId; 224 225 firePropertyChange (PROP_SYSTEM_ID, oldSystemId, newSystemId); 226 } 227 228 232 public final void setSystemId (String newSystemId) throws ReadOnlyException, InvalidArgumentException { 233 if ( Util.equals (this.systemId, newSystemId) ) 237 return; 238 checkReadOnly (); 239 checkSystemId (newSystemId); 240 checkExternalId (this.publicId, newSystemId); 241 242 setSystemIdImpl (newSystemId); 246 } 247 248 250 protected final void checkSystemId (String systemId) throws InvalidArgumentException { 251 TreeUtilities.checkNotationDeclSystemId (systemId); 252 } 253 254 255 257 protected final void checkExternalId (String publicId, String systemId) throws InvalidArgumentException { 258 if ( (publicId == null) && (systemId == null) ) { 259 throw new InvalidArgumentException (Util.THIS.getString ("EXC_invalid_nulls"), 260 new NullPointerException ()); 261 } 262 } 263 264 } 265 | Popular Tags |