| 1 |
/** |
| 2 |
* Copyright (c) 2002-2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v20.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM - Initial API and implementation |
| 10 |
*/ |
| 11 |
package org.eclipse.xsd.impl; |
| 12 |
|
| 13 |
|
| 14 |
import org.w3c.dom.Element; |
| 15 |
import org.w3c.dom.Node; |
| 16 |
|
| 17 |
import org.eclipse.emf.common.notify.Notification; |
| 18 |
import org.eclipse.emf.common.notify.NotificationChain; |
| 19 |
import org.eclipse.emf.ecore.EAttribute; |
| 20 |
import org.eclipse.emf.ecore.EClass; |
| 21 |
import org.eclipse.emf.ecore.InternalEObject; |
| 22 |
import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 23 |
import org.eclipse.xsd.XSDAnnotation; |
| 24 |
import org.eclipse.xsd.XSDConcreteComponent; |
| 25 |
import org.eclipse.xsd.XSDFactory; |
| 26 |
import org.eclipse.xsd.XSDNotationDeclaration; |
| 27 |
import org.eclipse.xsd.XSDPackage; |
| 28 |
import org.eclipse.xsd.util.XSDConstants; |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
* <!-- begin-user-doc --> |
| 33 |
* An implementation of the model object '<em><b>Notation Declaration</b></em>'. |
| 34 |
* <!-- end-user-doc --> |
| 35 |
* <p> |
| 36 |
* The following features are implemented: |
| 37 |
* </p> |
| 38 |
* <ul> |
| 39 |
* <li>{@link org.eclipse.xsd.impl.XSDNotationDeclarationImpl#getSystemIdentifier <em>System Identifier</em>}</li> |
| 40 |
* <li>{@link org.eclipse.xsd.impl.XSDNotationDeclarationImpl#getPublicIdentifier <em>Public Identifier</em>}</li> |
| 41 |
* <li>{@link org.eclipse.xsd.impl.XSDNotationDeclarationImpl#getAnnotation <em>Annotation</em>}</li> |
| 42 |
* </ul> |
| 43 |
* |
| 44 |
* @generated |
| 45 |
*/ |
| 46 |
public class XSDNotationDeclarationImpl |
| 47 |
extends XSDNamedComponentImpl |
| 48 |
implements XSDNotationDeclaration |
| 49 |
{ |
| 50 |
/** |
| 51 |
* The default value of the '{@link #getSystemIdentifier() <em>System Identifier</em>}' attribute. |
| 52 |
* <!-- begin-user-doc --> |
| 53 |
* <!-- end-user-doc --> |
| 54 |
* @see #getSystemIdentifier() |
| 55 |
* @generated |
| 56 |
* @ordered |
| 57 |
*/ |
| 58 |
protected static final String SYSTEM_IDENTIFIER_EDEFAULT = null; |
| 59 |
|
| 60 |
/** |
| 61 |
* The cached value of the '{@link #getSystemIdentifier() <em>System Identifier</em>}' attribute. |
| 62 |
* <!-- begin-user-doc --> |
| 63 |
* <!-- end-user-doc --> |
| 64 |
* @see #getSystemIdentifier() |
| 65 |
* @generated |
| 66 |
* @ordered |
| 67 |
*/ |
| 68 |
protected String systemIdentifier = SYSTEM_IDENTIFIER_EDEFAULT; |
| 69 |
|
| 70 |
/** |
| 71 |
* The default value of the '{@link #getPublicIdentifier() <em>Public Identifier</em>}' attribute. |
| 72 |
* <!-- begin-user-doc --> |
| 73 |
* <!-- end-user-doc --> |
| 74 |
* @see #getPublicIdentifier() |
| 75 |
* @generated |
| 76 |
* @ordered |
| 77 |
*/ |
| 78 |
protected static final String PUBLIC_IDENTIFIER_EDEFAULT = null; |
| 79 |
|
| 80 |
/** |
| 81 |
* The cached value of the '{@link #getPublicIdentifier() <em>Public Identifier</em>}' attribute. |
| 82 |
* <!-- begin-user-doc --> |
| 83 |
* <!-- end-user-doc --> |
| 84 |
* @see #getPublicIdentifier() |
| 85 |
* @generated |
| 86 |
* @ordered |
| 87 |
*/ |
| 88 |
protected String publicIdentifier = PUBLIC_IDENTIFIER_EDEFAULT; |
| 89 |
|
| 90 |
/** |
| 91 |
* The cached value of the '{@link #getAnnotation() <em>Annotation</em>}' containment reference. |
| 92 |
* <!-- begin-user-doc --> |
| 93 |
* <!-- end-user-doc --> |
| 94 |
* @see #getAnnotation() |
| 95 |
* @generated |
| 96 |
* @ordered |
| 97 |
*/ |
| 98 |
protected XSDAnnotation annotation; |
| 99 |
|
| 100 |
public static XSDNotationDeclaration createNotationDeclaration(Node node) |
| 101 |
{ |
| 102 |
if (XSDConstants.nodeType(node) == XSDConstants.NOTATION_ELEMENT) |
| 103 |
{ |
| 104 |
XSDNotationDeclaration xsdNotationDeclaration = XSDFactory.eINSTANCE.createXSDNotationDeclaration(); |
| 105 |
xsdNotationDeclaration.setElement((Element)node); |
| 106 |
return xsdNotationDeclaration; |
| 107 |
} |
| 108 |
|
| 109 |
return null; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* <!-- begin-user-doc --> |
| 114 |
* <!-- end-user-doc --> |
| 115 |
* @generated |
| 116 |
*/ |
| 117 |
protected XSDNotationDeclarationImpl() |
| 118 |
{ |
| 119 |
super(); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* <!-- begin-user-doc --> |
| 124 |
* <!-- end-user-doc --> |
| 125 |
* @generated |
| 126 |
*/ |
| 127 |
@Override |
| 128 |
protected EClass eStaticClass() |
| 129 |
{ |
| 130 |
return XSDPackage.Literals.XSD_NOTATION_DECLARATION; |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* <!-- begin-user-doc --> |
| 135 |
* <!-- end-user-doc --> |
| 136 |
* @generated |
| 137 |
*/ |
| 138 |
@Override |
| 139 |
public String getSystemIdentifier() |
| 140 |
{ |
| 141 |
return systemIdentifier; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* <!-- begin-user-doc --> |
| 146 |
* <!-- end-user-doc --> |
| 147 |
* @generated |
| 148 |
*/ |
| 149 |
@Override |
| 150 |
public void setSystemIdentifier(String newSystemIdentifier) |
| 151 |
{ |
| 152 |
String oldSystemIdentifier = systemIdentifier; |
| 153 |
systemIdentifier = newSystemIdentifier; |
| 154 |
if (eNotificationRequired()) |
| 155 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER, oldSystemIdentifier, systemIdentifier)); |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* <!-- begin-user-doc --> |
| 160 |
* <!-- end-user-doc --> |
| 161 |
* @generated |
| 162 |
*/ |
| 163 |
@Override |
| 164 |
public String getPublicIdentifier() |
| 165 |
{ |
| 166 |
return publicIdentifier; |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* <!-- begin-user-doc --> |
| 171 |
* <!-- end-user-doc --> |
| 172 |
* @generated |
| 173 |
*/ |
| 174 |
@Override |
| 175 |
public void setPublicIdentifier(String newPublicIdentifier) |
| 176 |
{ |
| 177 |
String oldPublicIdentifier = publicIdentifier; |
| 178 |
publicIdentifier = newPublicIdentifier; |
| 179 |
if (eNotificationRequired()) |
| 180 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER, oldPublicIdentifier, publicIdentifier)); |
| 181 |
} |
| 182 |
|
| 183 |
/** |
| 184 |
* <!-- begin-user-doc --> |
| 185 |
* <!-- end-user-doc --> |
| 186 |
* @generated |
| 187 |
*/ |
| 188 |
@Override |
| 189 |
public XSDAnnotation getAnnotation() |
| 190 |
{ |
| 191 |
return annotation; |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* <!-- begin-user-doc --> |
| 196 |
* <!-- end-user-doc --> |
| 197 |
* @generated |
| 198 |
*/ |
| 199 |
@Override |
| 200 |
public void setAnnotation(XSDAnnotation newAnnotation) |
| 201 |
{ |
| 202 |
if (newAnnotation != annotation) |
| 203 |
{ |
| 204 |
NotificationChain msgs = null; |
| 205 |
if (annotation != null) |
| 206 |
msgs = ((InternalEObject)annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION, null, msgs); |
| 207 |
if (newAnnotation != null) |
| 208 |
msgs = ((InternalEObject)newAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION, null, msgs); |
| 209 |
msgs = basicSetAnnotation(newAnnotation, msgs); |
| 210 |
if (msgs != null) msgs.dispatch(); |
| 211 |
} |
| 212 |
else if (eNotificationRequired()) |
| 213 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION, newAnnotation, newAnnotation)); |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* <!-- begin-user-doc --> |
| 218 |
* <!-- end-user-doc --> |
| 219 |
* @generated |
| 220 |
*/ |
| 221 |
@Override |
| 222 |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| 223 |
{ |
| 224 |
switch (featureID) |
| 225 |
{ |
| 226 |
case XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION: |
| 227 |
return basicSetAnnotation(null, msgs); |
| 228 |
} |
| 229 |
return super.eInverseRemove(otherEnd, featureID, msgs); |
| 230 |
} |
| 231 |
|
| 232 |
/** |
| 233 |
* <!-- begin-user-doc --> |
| 234 |
* <!-- end-user-doc --> |
| 235 |
* @generated |
| 236 |
*/ |
| 237 |
public NotificationChain basicSetAnnotation(XSDAnnotation newAnnotation, NotificationChain msgs) |
| 238 |
{ |
| 239 |
XSDAnnotation oldAnnotation = annotation; |
| 240 |
annotation = newAnnotation; |
| 241 |
if (eNotificationRequired()) |
| 242 |
{ |
| 243 |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION, oldAnnotation, newAnnotation); |
| 244 |
if (msgs == null) msgs = notification; else msgs.add(notification); |
| 245 |
} |
| 246 |
return msgs; |
| 247 |
} |
| 248 |
|
| 249 |
/** |
| 250 |
* <!-- begin-user-doc --> |
| 251 |
* <!-- end-user-doc --> |
| 252 |
* @generated |
| 253 |
*/ |
| 254 |
@Override |
| 255 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 256 |
{ |
| 257 |
switch (featureID) |
| 258 |
{ |
| 259 |
case XSDPackage.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER: |
| 260 |
return getSystemIdentifier(); |
| 261 |
case XSDPackage.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER: |
| 262 |
return getPublicIdentifier(); |
| 263 |
case XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION: |
| 264 |
return getAnnotation(); |
| 265 |
} |
| 266 |
return super.eGet(featureID, resolve, coreType); |
| 267 |
} |
| 268 |
|
| 269 |
/** |
| 270 |
* <!-- begin-user-doc --> |
| 271 |
* <!-- end-user-doc --> |
| 272 |
* @generated |
| 273 |
*/ |
| 274 |
@Override |
| 275 |
public void eSet(int featureID, Object newValue) |
| 276 |
{ |
| 277 |
switch (featureID) |
| 278 |
{ |
| 279 |
case XSDPackage.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER: |
| 280 |
setSystemIdentifier((String)newValue); |
| 281 |
return; |
| 282 |
case XSDPackage.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER: |
| 283 |
setPublicIdentifier((String)newValue); |
| 284 |
return; |
| 285 |
case XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION: |
| 286 |
setAnnotation((XSDAnnotation)newValue); |
| 287 |
return; |
| 288 |
} |
| 289 |
super.eSet(featureID, newValue); |
| 290 |
} |
| 291 |
|
| 292 |
/** |
| 293 |
* <!-- begin-user-doc --> |
| 294 |
* <!-- end-user-doc --> |
| 295 |
* @generated |
| 296 |
*/ |
| 297 |
@Override |
| 298 |
public void eUnset(int featureID) |
| 299 |
{ |
| 300 |
switch (featureID) |
| 301 |
{ |
| 302 |
case XSDPackage.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER: |
| 303 |
setSystemIdentifier(SYSTEM_IDENTIFIER_EDEFAULT); |
| 304 |
return; |
| 305 |
case XSDPackage.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER: |
| 306 |
setPublicIdentifier(PUBLIC_IDENTIFIER_EDEFAULT); |
| 307 |
return; |
| 308 |
case XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION: |
| 309 |
setAnnotation((XSDAnnotation)null); |
| 310 |
return; |
| 311 |
} |
| 312 |
super.eUnset(featureID); |
| 313 |
} |
| 314 |
|
| 315 |
/** |
| 316 |
* <!-- begin-user-doc --> |
| 317 |
* <!-- end-user-doc --> |
| 318 |
* @generated |
| 319 |
*/ |
| 320 |
@Override |
| 321 |
public boolean eIsSet(int featureID) |
| 322 |
{ |
| 323 |
switch (featureID) |
| 324 |
{ |
| 325 |
case XSDPackage.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER: |
| 326 |
return SYSTEM_IDENTIFIER_EDEFAULT == null ? systemIdentifier != null : !SYSTEM_IDENTIFIER_EDEFAULT.equals(systemIdentifier); |
| 327 |
case XSDPackage.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER: |
| 328 |
return PUBLIC_IDENTIFIER_EDEFAULT == null ? publicIdentifier != null : !PUBLIC_IDENTIFIER_EDEFAULT.equals(publicIdentifier); |
| 329 |
case XSDPackage.XSD_NOTATION_DECLARATION__ANNOTATION: |
| 330 |
return annotation != null; |
| 331 |
} |
| 332 |
return super.eIsSet(featureID); |
| 333 |
} |
| 334 |
|
| 335 |
/** |
| 336 |
* <!-- begin-user-doc --> |
| 337 |
* <!-- end-user-doc --> |
| 338 |
* @generated |
| 339 |
*/ |
| 340 |
@Override |
| 341 |
public String toString() |
| 342 |
{ |
| 343 |
if (eIsProxy()) return super.toString(); |
| 344 |
|
| 345 |
StringBuilder result = new StringBuilder(super.toString()); |
| 346 |
result.append(" (systemIdentifier: "); |
| 347 |
result.append(systemIdentifier); |
| 348 |
result.append(", publicIdentifier: "); |
| 349 |
result.append(publicIdentifier); |
| 350 |
result.append(')'); |
| 351 |
return result.toString(); |
| 352 |
} |
| 353 |
|
| 354 |
@Override |
| 355 |
public Element createElement() |
| 356 |
{ |
| 357 |
Element newElement = createElement(XSDConstants.NOTATION_ELEMENT); |
| 358 |
setElement(newElement); |
| 359 |
return newElement; |
| 360 |
} |
| 361 |
|
| 362 |
@Override |
| 363 |
public void validate() |
| 364 |
{ |
| 365 |
super.validate(); |
| 366 |
|
| 367 |
Element theElement = getElement(); |
| 368 |
if (theElement != null) |
| 369 |
{ |
| 370 |
checkAttributes |
| 371 |
(XSDConstants.PART1, |
| 372 |
"element-notation", |
| 373 |
theElement, |
| 374 |
new String [] |
| 375 |
{ |
| 376 |
XSDConstants.ID_ATTRIBUTE, |
| 377 |
XSDConstants.NAME_ATTRIBUTE, |
| 378 |
XSDConstants.PUBLIC_ATTRIBUTE, |
| 379 |
XSDConstants.SYSTEM_ATTRIBUTE |
| 380 |
}); |
| 381 |
|
| 382 |
checkComplexContent("annotated", XSDConstants.PART1, "element-notation", theElement); |
| 383 |
|
| 384 |
checkBuiltInTypeConstraint |
| 385 |
("ID", |
| 386 |
null, |
| 387 |
XSDConstants.PART1, |
| 388 |
"element-notation", |
| 389 |
theElement, |
| 390 |
XSDConstants.ID_ATTRIBUTE, |
| 391 |
false); |
| 392 |
} |
| 393 |
|
| 394 |
checkBuiltInTypeConstraint |
| 395 |
("NCName", |
| 396 |
getName(), |
| 397 |
XSDConstants.PART1, |
| 398 |
"element-notation", |
| 399 |
theElement, |
| 400 |
XSDConstants.NAME_ATTRIBUTE, |
| 401 |
true); |
| 402 |
|
| 403 |
checkBuiltInTypeConstraint |
| 404 |
("public", |
| 405 |
getPublicIdentifier(), |
| 406 |
XSDConstants.PART1, |
| 407 |
"element-notation", |
| 408 |
theElement, |
| 409 |
XSDConstants.PUBLIC_ATTRIBUTE, |
| 410 |
true); |
| 411 |
|
| 412 |
checkBuiltInTypeConstraint |
| 413 |
("anyURI", |
| 414 |
getSystemIdentifier(), |
| 415 |
XSDConstants.PART1, |
| 416 |
"element-notation", |
| 417 |
theElement, |
| 418 |
XSDConstants.SYSTEM_ATTRIBUTE, |
| 419 |
false); |
| 420 |
} |
| 421 |
|
| 422 |
@Override |
| 423 |
protected void reconcileAttributes(Element changedElement) |
| 424 |
{ |
| 425 |
super.reconcileAttributes(changedElement); |
| 426 |
|
| 427 |
if (changedElement.hasAttributeNS(null, XSDConstants.PUBLIC_ATTRIBUTE)) |
| 428 |
{ |
| 429 |
String newPublicIdentifier = changedElement.getAttributeNS(null, XSDConstants.PUBLIC_ATTRIBUTE); |
| 430 |
|
| 431 |
if (newPublicIdentifier == null || !newPublicIdentifier.equals(getPublicIdentifier())) |
| 432 |
{ |
| 433 |
setPublicIdentifier(newPublicIdentifier); |
| 434 |
} |
| 435 |
} |
| 436 |
else if (getPublicIdentifier() != null) |
| 437 |
{ |
| 438 |
setPublicIdentifier(null); |
| 439 |
} |
| 440 |
|
| 441 |
if (changedElement.hasAttributeNS(null, XSDConstants.SYSTEM_ATTRIBUTE)) |
| 442 |
{ |
| 443 |
String newSystemIdentifier = changedElement.getAttributeNS(null, XSDConstants.SYSTEM_ATTRIBUTE); |
| 444 |
|
| 445 |
if (newSystemIdentifier == null || !newSystemIdentifier.equals(getSystemIdentifier())) |
| 446 |
{ |
| 447 |
setSystemIdentifier(newSystemIdentifier); |
| 448 |
} |
| 449 |
} |
| 450 |
else if (getSystemIdentifier() != null) |
| 451 |
{ |
| 452 |
setSystemIdentifier(null); |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
@Override |
| 457 |
protected void changeAttribute(EAttribute eAttribute) |
| 458 |
{ |
| 459 |
if (isReconciling) |
| 460 |
{ |
| 461 |
return; |
| 462 |
} |
| 463 |
|
| 464 |
super.changeAttribute(eAttribute); |
| 465 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_NOTATION_DECLARATION__PUBLIC_IDENTIFIER) |
| 466 |
{ |
| 467 |
Element theElement = getElement(); |
| 468 |
if (theElement != null) |
| 469 |
{ |
| 470 |
niceSetAttribute(theElement, XSDConstants.PUBLIC_ATTRIBUTE, getPublicIdentifier()); |
| 471 |
} |
| 472 |
} |
| 473 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_NOTATION_DECLARATION__SYSTEM_IDENTIFIER) |
| 474 |
{ |
| 475 |
Element theElement = getElement(); |
| 476 |
if (theElement != null) |
| 477 |
{ |
| 478 |
niceSetAttribute(theElement, XSDConstants.SYSTEM_ATTRIBUTE, getSystemIdentifier()); |
| 479 |
} |
| 480 |
} |
| 481 |
} |
| 482 |
|
| 483 |
@Override |
| 484 |
public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM) |
| 485 |
{ |
| 486 |
XSDNotationDeclarationImpl clonedNotationDeclaration = |
| 487 |
(XSDNotationDeclarationImpl)getXSDFactory().createXSDNotationDeclaration(); |
| 488 |
clonedNotationDeclaration.isReconciling = true; |
| 489 |
|
| 490 |
if (getName() != null) |
| 491 |
{ |
| 492 |
clonedNotationDeclaration.setName(getName()); |
| 493 |
} |
| 494 |
clonedNotationDeclaration.setPublicIdentifier(getPublicIdentifier()); |
| 495 |
clonedNotationDeclaration.setSystemIdentifier(getSystemIdentifier()); |
| 496 |
|
| 497 |
if (deep) |
| 498 |
{ |
| 499 |
if (getAnnotation() != null) |
| 500 |
{ |
| 501 |
clonedNotationDeclaration.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM)); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
if (shareDOM && getElement() != null) |
| 506 |
{ |
| 507 |
clonedNotationDeclaration.setElement(getElement()); |
| 508 |
} |
| 509 |
|
| 510 |
clonedNotationDeclaration.isReconciling = shareDOM; |
| 511 |
return clonedNotationDeclaration; |
| 512 |
} |
| 513 |
} |