| 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 java.util.Collection; |
| 15 |
import java.util.List; |
| 16 |
|
| 17 |
import org.w3c.dom.Element; |
| 18 |
import org.w3c.dom.Node; |
| 19 |
|
| 20 |
import org.eclipse.emf.common.notify.Notification; |
| 21 |
import org.eclipse.emf.common.notify.NotificationChain; |
| 22 |
import org.eclipse.emf.common.util.EList; |
| 23 |
import org.eclipse.emf.ecore.EAttribute; |
| 24 |
import org.eclipse.emf.ecore.EClass; |
| 25 |
import org.eclipse.emf.ecore.EReference; |
| 26 |
import org.eclipse.emf.ecore.InternalEObject; |
| 27 |
import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 28 |
import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 29 |
import org.eclipse.emf.ecore.util.InternalEList; |
| 30 |
|
| 31 |
import org.eclipse.xsd.XSDAnnotation; |
| 32 |
import org.eclipse.xsd.XSDComplexTypeDefinition; |
| 33 |
import org.eclipse.xsd.XSDConcreteComponent; |
| 34 |
import org.eclipse.xsd.XSDDiagnosticSeverity; |
| 35 |
import org.eclipse.xsd.XSDFactory; |
| 36 |
import org.eclipse.xsd.XSDIdentityConstraintCategory; |
| 37 |
import org.eclipse.xsd.XSDIdentityConstraintDefinition; |
| 38 |
import org.eclipse.xsd.XSDPackage; |
| 39 |
import org.eclipse.xsd.XSDSchema; |
| 40 |
import org.eclipse.xsd.XSDXPathDefinition; |
| 41 |
import org.eclipse.xsd.XSDXPathVariety; |
| 42 |
import org.eclipse.xsd.util.XSDConstants; |
| 43 |
|
| 44 |
|
| 45 |
/** |
| 46 |
* <!-- begin-user-doc --> |
| 47 |
* An implementation of the model object '<em><b>Identity Constraint Definition</b></em>'. |
| 48 |
* <!-- end-user-doc --> |
| 49 |
* <p> |
| 50 |
* The following features are implemented: |
| 51 |
* </p> |
| 52 |
* <ul> |
| 53 |
* <li>{@link org.eclipse.xsd.impl.XSDIdentityConstraintDefinitionImpl#getIdentityConstraintCategory <em>Identity Constraint Category</em>}</li> |
| 54 |
* <li>{@link org.eclipse.xsd.impl.XSDIdentityConstraintDefinitionImpl#getAnnotation <em>Annotation</em>}</li> |
| 55 |
* <li>{@link org.eclipse.xsd.impl.XSDIdentityConstraintDefinitionImpl#getReferencedKey <em>Referenced Key</em>}</li> |
| 56 |
* <li>{@link org.eclipse.xsd.impl.XSDIdentityConstraintDefinitionImpl#getSelector <em>Selector</em>}</li> |
| 57 |
* <li>{@link org.eclipse.xsd.impl.XSDIdentityConstraintDefinitionImpl#getFields <em>Fields</em>}</li> |
| 58 |
* </ul> |
| 59 |
* |
| 60 |
* @generated |
| 61 |
*/ |
| 62 |
public class XSDIdentityConstraintDefinitionImpl |
| 63 |
extends XSDNamedComponentImpl |
| 64 |
implements XSDIdentityConstraintDefinition |
| 65 |
{ |
| 66 |
/** |
| 67 |
* The default value of the '{@link #getIdentityConstraintCategory() <em>Identity Constraint Category</em>}' attribute. |
| 68 |
* <!-- begin-user-doc --> |
| 69 |
* <!-- end-user-doc --> |
| 70 |
* @see #getIdentityConstraintCategory() |
| 71 |
* @generated |
| 72 |
* @ordered |
| 73 |
*/ |
| 74 |
protected static final XSDIdentityConstraintCategory IDENTITY_CONSTRAINT_CATEGORY_EDEFAULT = XSDIdentityConstraintCategory.KEY_LITERAL; |
| 75 |
|
| 76 |
/** |
| 77 |
* The offset of the flags representing the value of the '{@link #getIdentityConstraintCategory() <em>Identity Constraint Category</em>}' attribute. |
| 78 |
* <!-- begin-user-doc --> |
| 79 |
* <!-- end-user-doc --> |
| 80 |
* @generated |
| 81 |
* @ordered |
| 82 |
*/ |
| 83 |
protected static final int IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET = 8; |
| 84 |
|
| 85 |
/** |
| 86 |
* The flags representing the default value of the '{@link #getIdentityConstraintCategory() <em>Identity Constraint Category</em>}' attribute. |
| 87 |
* <!-- begin-user-doc --> |
| 88 |
* <!-- end-user-doc --> |
| 89 |
* @generated |
| 90 |
* @ordered |
| 91 |
*/ |
| 92 |
protected static final int IDENTITY_CONSTRAINT_CATEGORY_EFLAG_DEFAULT = IDENTITY_CONSTRAINT_CATEGORY_EDEFAULT.ordinal() << IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET; |
| 93 |
|
| 94 |
/** |
| 95 |
* The array of enumeration values for '{@link XSDIdentityConstraintCategory Identity Constraint Category}' |
| 96 |
* <!-- begin-user-doc --> |
| 97 |
* <!-- end-user-doc --> |
| 98 |
* @generated |
| 99 |
* @ordered |
| 100 |
*/ |
| 101 |
private static final XSDIdentityConstraintCategory[] IDENTITY_CONSTRAINT_CATEGORY_EFLAG_VALUES = XSDIdentityConstraintCategory.values(); |
| 102 |
|
| 103 |
/** |
| 104 |
* The flags representing the value of the '{@link #getIdentityConstraintCategory() <em>Identity Constraint Category</em>}' attribute. |
| 105 |
* <!-- begin-user-doc --> |
| 106 |
* <!-- end-user-doc --> |
| 107 |
* @see #getIdentityConstraintCategory() |
| 108 |
* @generated |
| 109 |
* @ordered |
| 110 |
*/ |
| 111 |
protected static final int IDENTITY_CONSTRAINT_CATEGORY_EFLAG = 0x3 << IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET; |
| 112 |
|
| 113 |
/** |
| 114 |
* The cached value of the '{@link #getAnnotation() <em>Annotation</em>}' containment reference. |
| 115 |
* <!-- begin-user-doc --> |
| 116 |
* <!-- end-user-doc --> |
| 117 |
* @see #getAnnotation() |
| 118 |
* @generated |
| 119 |
* @ordered |
| 120 |
*/ |
| 121 |
protected XSDAnnotation annotation; |
| 122 |
|
| 123 |
/** |
| 124 |
* The cached value of the '{@link #getReferencedKey() <em>Referenced Key</em>}' reference. |
| 125 |
* <!-- begin-user-doc --> |
| 126 |
* <!-- end-user-doc --> |
| 127 |
* @see #getReferencedKey() |
| 128 |
* @generated |
| 129 |
* @ordered |
| 130 |
*/ |
| 131 |
protected XSDIdentityConstraintDefinition referencedKey; |
| 132 |
|
| 133 |
/** |
| 134 |
* The cached value of the '{@link #getSelector() <em>Selector</em>}' containment reference. |
| 135 |
* <!-- begin-user-doc --> |
| 136 |
* <!-- end-user-doc --> |
| 137 |
* @see #getSelector() |
| 138 |
* @generated |
| 139 |
* @ordered |
| 140 |
*/ |
| 141 |
protected XSDXPathDefinition selector; |
| 142 |
|
| 143 |
/** |
| 144 |
* The cached value of the '{@link #getFields() <em>Fields</em>}' containment reference list. |
| 145 |
* <!-- begin-user-doc --> |
| 146 |
* <!-- end-user-doc --> |
| 147 |
* @see #getFields() |
| 148 |
* @generated |
| 149 |
* @ordered |
| 150 |
*/ |
| 151 |
protected EList<XSDXPathDefinition> fields; |
| 152 |
|
| 153 |
public static XSDIdentityConstraintDefinition createIdentityConstraintDefinition(Node node) |
| 154 |
{ |
| 155 |
switch (XSDConstants.nodeType(node)) |
| 156 |
{ |
| 157 |
case XSDConstants.KEY_ELEMENT: |
| 158 |
case XSDConstants.KEYREF_ELEMENT: |
| 159 |
case XSDConstants.UNIQUE_ELEMENT: |
| 160 |
{ |
| 161 |
XSDIdentityConstraintDefinition xsdIdentityConstraintDefinition = |
| 162 |
XSDFactory.eINSTANCE.createXSDIdentityConstraintDefinition(); |
| 163 |
xsdIdentityConstraintDefinition.setElement((Element)node); |
| 164 |
return xsdIdentityConstraintDefinition; |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
return null; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* <!-- begin-user-doc --> |
| 173 |
* <!-- end-user-doc --> |
| 174 |
* @generated |
| 175 |
*/ |
| 176 |
protected XSDIdentityConstraintDefinitionImpl() |
| 177 |
{ |
| 178 |
super(); |
| 179 |
} |
| 180 |
|
| 181 |
/** |
| 182 |
* <!-- begin-user-doc --> |
| 183 |
* <!-- end-user-doc --> |
| 184 |
* @generated |
| 185 |
*/ |
| 186 |
@Override |
| 187 |
protected EClass eStaticClass() |
| 188 |
{ |
| 189 |
return XSDPackage.Literals.XSD_IDENTITY_CONSTRAINT_DEFINITION; |
| 190 |
} |
| 191 |
|
| 192 |
/** |
| 193 |
* <!-- begin-user-doc --> |
| 194 |
* <!-- end-user-doc --> |
| 195 |
* @generated |
| 196 |
*/ |
| 197 |
@Override |
| 198 |
public XSDIdentityConstraintCategory getIdentityConstraintCategory() |
| 199 |
{ |
| 200 |
return IDENTITY_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & IDENTITY_CONSTRAINT_CATEGORY_EFLAG) >>> IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET]; |
| 201 |
} |
| 202 |
|
| 203 |
/** |
| 204 |
* <!-- begin-user-doc --> |
| 205 |
* <!-- end-user-doc --> |
| 206 |
* @generated |
| 207 |
*/ |
| 208 |
@Override |
| 209 |
public void setIdentityConstraintCategory(XSDIdentityConstraintCategory newIdentityConstraintCategory) |
| 210 |
{ |
| 211 |
XSDIdentityConstraintCategory oldIdentityConstraintCategory = IDENTITY_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & IDENTITY_CONSTRAINT_CATEGORY_EFLAG) >>> IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET]; |
| 212 |
if (newIdentityConstraintCategory == null) newIdentityConstraintCategory = IDENTITY_CONSTRAINT_CATEGORY_EDEFAULT; |
| 213 |
eFlags = eFlags & ~IDENTITY_CONSTRAINT_CATEGORY_EFLAG | newIdentityConstraintCategory.ordinal() << IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET; |
| 214 |
if (eNotificationRequired()) |
| 215 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY, oldIdentityConstraintCategory, newIdentityConstraintCategory)); |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* <!-- begin-user-doc --> |
| 220 |
* <!-- end-user-doc --> |
| 221 |
* @generated |
| 222 |
*/ |
| 223 |
@Override |
| 224 |
public XSDAnnotation getAnnotation() |
| 225 |
{ |
| 226 |
return annotation; |
| 227 |
} |
| 228 |
|
| 229 |
/** |
| 230 |
* <!-- begin-user-doc --> |
| 231 |
* <!-- end-user-doc --> |
| 232 |
* @generated |
| 233 |
*/ |
| 234 |
@Override |
| 235 |
public void setAnnotation(XSDAnnotation newAnnotation) |
| 236 |
{ |
| 237 |
if (newAnnotation != annotation) |
| 238 |
{ |
| 239 |
NotificationChain msgs = null; |
| 240 |
if (annotation != null) |
| 241 |
msgs = ((InternalEObject)annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION, null, msgs); |
| 242 |
if (newAnnotation != null) |
| 243 |
msgs = ((InternalEObject)newAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION, null, msgs); |
| 244 |
msgs = basicSetAnnotation(newAnnotation, msgs); |
| 245 |
if (msgs != null) msgs.dispatch(); |
| 246 |
} |
| 247 |
else if (eNotificationRequired()) |
| 248 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION, newAnnotation, newAnnotation)); |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* <!-- begin-user-doc --> |
| 253 |
* <!-- end-user-doc --> |
| 254 |
* @generated |
| 255 |
*/ |
| 256 |
public NotificationChain basicSetAnnotation(XSDAnnotation newAnnotation, NotificationChain msgs) |
| 257 |
{ |
| 258 |
XSDAnnotation oldAnnotation = annotation; |
| 259 |
annotation = newAnnotation; |
| 260 |
if (eNotificationRequired()) |
| 261 |
{ |
| 262 |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION, oldAnnotation, newAnnotation); |
| 263 |
if (msgs == null) msgs = notification; else msgs.add(notification); |
| 264 |
} |
| 265 |
return msgs; |
| 266 |
} |
| 267 |
|
| 268 |
/** |
| 269 |
* <!-- begin-user-doc --> |
| 270 |
* <!-- end-user-doc --> |
| 271 |
* @generated |
| 272 |
*/ |
| 273 |
@Override |
| 274 |
public XSDIdentityConstraintDefinition getReferencedKey() |
| 275 |
{ |
| 276 |
return referencedKey; |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* <!-- begin-user-doc --> |
| 281 |
* <!-- end-user-doc --> |
| 282 |
* @generated |
| 283 |
*/ |
| 284 |
@Override |
| 285 |
public void setReferencedKey(XSDIdentityConstraintDefinition newReferencedKey) |
| 286 |
{ |
| 287 |
XSDIdentityConstraintDefinition oldReferencedKey = referencedKey; |
| 288 |
referencedKey = newReferencedKey; |
| 289 |
if (eNotificationRequired()) |
| 290 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY, oldReferencedKey, referencedKey)); |
| 291 |
} |
| 292 |
|
| 293 |
/** |
| 294 |
* <!-- begin-user-doc --> |
| 295 |
* <!-- end-user-doc --> |
| 296 |
* @generated |
| 297 |
*/ |
| 298 |
@Override |
| 299 |
public XSDXPathDefinition getSelector() |
| 300 |
{ |
| 301 |
return selector; |
| 302 |
} |
| 303 |
|
| 304 |
/** |
| 305 |
* <!-- begin-user-doc --> |
| 306 |
* <!-- end-user-doc --> |
| 307 |
* @generated |
| 308 |
*/ |
| 309 |
@Override |
| 310 |
public void setSelector(XSDXPathDefinition newSelector) |
| 311 |
{ |
| 312 |
if (newSelector != selector) |
| 313 |
{ |
| 314 |
NotificationChain msgs = null; |
| 315 |
if (selector != null) |
| 316 |
msgs = ((InternalEObject)selector).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR, null, msgs); |
| 317 |
if (newSelector != null) |
| 318 |
msgs = ((InternalEObject)newSelector).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR, null, msgs); |
| 319 |
msgs = basicSetSelector(newSelector, msgs); |
| 320 |
if (msgs != null) msgs.dispatch(); |
| 321 |
} |
| 322 |
else if (eNotificationRequired()) |
| 323 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR, newSelector, newSelector)); |
| 324 |
} |
| 325 |
|
| 326 |
/** |
| 327 |
* <!-- begin-user-doc --> |
| 328 |
* <!-- end-user-doc --> |
| 329 |
* @generated |
| 330 |
*/ |
| 331 |
public NotificationChain basicSetSelector(XSDXPathDefinition newSelector, NotificationChain msgs) |
| 332 |
{ |
| 333 |
XSDXPathDefinition oldSelector = selector; |
| 334 |
selector = newSelector; |
| 335 |
if (eNotificationRequired()) |
| 336 |
{ |
| 337 |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR, oldSelector, newSelector); |
| 338 |
if (msgs == null) msgs = notification; else msgs.add(notification); |
| 339 |
} |
| 340 |
return msgs; |
| 341 |
} |
| 342 |
|
| 343 |
/** |
| 344 |
* <!-- begin-user-doc --> |
| 345 |
* <!-- end-user-doc --> |
| 346 |
* @generated |
| 347 |
*/ |
| 348 |
@Override |
| 349 |
public EList<XSDXPathDefinition> getFields() |
| 350 |
{ |
| 351 |
if (fields == null) |
| 352 |
{ |
| 353 |
fields = new EObjectContainmentEList<XSDXPathDefinition>(XSDXPathDefinition.class, this, XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS); |
| 354 |
} |
| 355 |
return fields; |
| 356 |
} |
| 357 |
|
| 358 |
/** |
| 359 |
* <!-- begin-user-doc --> |
| 360 |
* <!-- end-user-doc --> |
| 361 |
* @generated |
| 362 |
*/ |
| 363 |
@Override |
| 364 |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| 365 |
{ |
| 366 |
switch (featureID) |
| 367 |
{ |
| 368 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION: |
| 369 |
return basicSetAnnotation(null, msgs); |
| 370 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR: |
| 371 |
return basicSetSelector(null, msgs); |
| 372 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS: |
| 373 |
return ((InternalEList<?>)getFields()).basicRemove(otherEnd, msgs); |
| 374 |
} |
| 375 |
return super.eInverseRemove(otherEnd, featureID, msgs); |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* <!-- begin-user-doc --> |
| 380 |
* <!-- end-user-doc --> |
| 381 |
* @generated |
| 382 |
*/ |
| 383 |
@Override |
| 384 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 385 |
{ |
| 386 |
switch (featureID) |
| 387 |
{ |
| 388 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY: |
| 389 |
return getIdentityConstraintCategory(); |
| 390 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION: |
| 391 |
return getAnnotation(); |
| 392 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY: |
| 393 |
return getReferencedKey(); |
| 394 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR: |
| 395 |
return getSelector(); |
| 396 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS: |
| 397 |
return getFields(); |
| 398 |
} |
| 399 |
return super.eGet(featureID, resolve, coreType); |
| 400 |
} |
| 401 |
|
| 402 |
/** |
| 403 |
* <!-- begin-user-doc --> |
| 404 |
* <!-- end-user-doc --> |
| 405 |
* @generated |
| 406 |
*/ |
| 407 |
@SuppressWarnings("unchecked") |
| 408 |
@Override |
| 409 |
public void eSet(int featureID, Object newValue) |
| 410 |
{ |
| 411 |
switch (featureID) |
| 412 |
{ |
| 413 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY: |
| 414 |
setIdentityConstraintCategory((XSDIdentityConstraintCategory)newValue); |
| 415 |
return; |
| 416 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION: |
| 417 |
setAnnotation((XSDAnnotation)newValue); |
| 418 |
return; |
| 419 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY: |
| 420 |
setReferencedKey((XSDIdentityConstraintDefinition)newValue); |
| 421 |
return; |
| 422 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR: |
| 423 |
setSelector((XSDXPathDefinition)newValue); |
| 424 |
return; |
| 425 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS: |
| 426 |
getFields().clear(); |
| 427 |
getFields().addAll((Collection<? extends XSDXPathDefinition>)newValue); |
| 428 |
return; |
| 429 |
} |
| 430 |
super.eSet(featureID, newValue); |
| 431 |
} |
| 432 |
|
| 433 |
/** |
| 434 |
* <!-- begin-user-doc --> |
| 435 |
* <!-- end-user-doc --> |
| 436 |
* @generated |
| 437 |
*/ |
| 438 |
@Override |
| 439 |
public void eUnset(int featureID) |
| 440 |
{ |
| 441 |
switch (featureID) |
| 442 |
{ |
| 443 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY: |
| 444 |
setIdentityConstraintCategory(IDENTITY_CONSTRAINT_CATEGORY_EDEFAULT); |
| 445 |
return; |
| 446 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION: |
| 447 |
setAnnotation((XSDAnnotation)null); |
| 448 |
return; |
| 449 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY: |
| 450 |
setReferencedKey((XSDIdentityConstraintDefinition)null); |
| 451 |
return; |
| 452 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR: |
| 453 |
setSelector((XSDXPathDefinition)null); |
| 454 |
return; |
| 455 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS: |
| 456 |
getFields().clear(); |
| 457 |
return; |
| 458 |
} |
| 459 |
super.eUnset(featureID); |
| 460 |
} |
| 461 |
|
| 462 |
/** |
| 463 |
* <!-- begin-user-doc --> |
| 464 |
* <!-- end-user-doc --> |
| 465 |
* @generated |
| 466 |
*/ |
| 467 |
@Override |
| 468 |
public boolean eIsSet(int featureID) |
| 469 |
{ |
| 470 |
switch (featureID) |
| 471 |
{ |
| 472 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY: |
| 473 |
return (eFlags & IDENTITY_CONSTRAINT_CATEGORY_EFLAG) != IDENTITY_CONSTRAINT_CATEGORY_EFLAG_DEFAULT; |
| 474 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION: |
| 475 |
return annotation != null; |
| 476 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY: |
| 477 |
return referencedKey != null; |
| 478 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__SELECTOR: |
| 479 |
return selector != null; |
| 480 |
case XSDPackage.XSD_IDENTITY_CONSTRAINT_DEFINITION__FIELDS: |
| 481 |
return fields != null && !fields.isEmpty(); |
| 482 |
} |
| 483 |
return super.eIsSet(featureID); |
| 484 |
} |
| 485 |
|
| 486 |
/** |
| 487 |
* <!-- begin-user-doc --> |
| 488 |
* <!-- end-user-doc --> |
| 489 |
* @generated |
| 490 |
*/ |
| 491 |
@Override |
| 492 |
public String toString() |
| 493 |
{ |
| 494 |
if (eIsProxy()) return super.toString(); |
| 495 |
|
| 496 |
StringBuilder result = new StringBuilder(super.toString()); |
| 497 |
result.append(" (identityConstraintCategory: "); |
| 498 |
result.append(IDENTITY_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & IDENTITY_CONSTRAINT_CATEGORY_EFLAG) >>> IDENTITY_CONSTRAINT_CATEGORY_EFLAG_OFFSET]); |
| 499 |
result.append(')'); |
| 500 |
return result.toString(); |
| 501 |
} |
| 502 |
|
| 503 |
@Override |
| 504 |
public Element createElement() |
| 505 |
{ |
| 506 |
Element newElement = |
| 507 |
createElement |
| 508 |
(XSDIdentityConstraintCategory.UNIQUE_LITERAL == getIdentityConstraintCategory() ? |
| 509 |
XSDConstants.UNIQUE_ELEMENT : |
| 510 |
XSDIdentityConstraintCategory.KEYREF_LITERAL == getIdentityConstraintCategory() ? |
| 511 |
XSDConstants.KEYREF_ELEMENT : |
| 512 |
XSDConstants.KEY_ELEMENT); |
| 513 |
setElement(newElement); |
| 514 |
return newElement; |
| 515 |
} |
| 516 |
|
| 517 |
@Override |
| 518 |
protected void patch() |
| 519 |
{ |
| 520 |
super.patch(); |
| 521 |
XSDIdentityConstraintDefinition theReferencedKey = getReferencedKey(); |
| 522 |
if (theReferencedKey != null) |
| 523 |
{ |
| 524 |
XSDIdentityConstraintDefinition newReferencedKey = |
| 525 |
resolveIdentityConstraintDefinition(theReferencedKey.getTargetNamespace(), theReferencedKey.getName()); |
| 526 |
if (newReferencedKey != theReferencedKey) |
| 527 |
{ |
| 528 |
setReferencedKey(newReferencedKey); |
| 529 |
} |
| 530 |
} |
| 531 |
} |
| 532 |
|
| 533 |
@Override |
| 534 |
public void validate() |
| 535 |
{ |
| 536 |
super.validate(); |
| 537 |
|
| 538 |
String anchor = null; |
| 539 |
String [] attributes = null; |
| 540 |
XSDComplexTypeDefinition xsdComplexTypeDefinition = null; |
| 541 |
switch (getIdentityConstraintCategory().getValue()) |
| 542 |
{ |
| 543 |
case XSDIdentityConstraintCategory.KEY: |
| 544 |
{ |
| 545 |
anchor = "element-key"; |
| 546 |
attributes = |
| 547 |
new String [] |
| 548 |
{ |
| 549 |
XSDConstants.ID_ATTRIBUTE, |
| 550 |
XSDConstants.NAME_ATTRIBUTE |
| 551 |
}; |
| 552 |
|
| 553 |
xsdComplexTypeDefinition = getSchema().getSchemaForSchema().resolveComplexTypeDefinition("keybase"); |
| 554 |
|
| 555 |
break; |
| 556 |
} |
| 557 |
case XSDIdentityConstraintCategory.KEYREF: |
| 558 |
{ |
| 559 |
anchor = "element-keyRef"; |
| 560 |
attributes = |
| 561 |
new String [] |
| 562 |
{ |
| 563 |
XSDConstants.ID_ATTRIBUTE, |
| 564 |
XSDConstants.NAME_ATTRIBUTE, |
| 565 |
XSDConstants.REFER_ATTRIBUTE |
| 566 |
}; |
| 567 |
|
| 568 |
xsdComplexTypeDefinition = |
| 569 |
(XSDComplexTypeDefinition)getSchema().getSchemaForSchema().resolveElementDeclaration("keyref").getTypeDefinition(); |
| 570 |
|
| 571 |
XSDIdentityConstraintDefinition theReferencedKey = getReferencedKey(); |
| 572 |
if (theReferencedKey == null) |
| 573 |
{ |
| 574 |
createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "_UI_UnresolvedIdentityConstraintDefinition_message", ""); |
| 575 |
} |
| 576 |
else if (theReferencedKey.getContainer() == null) |
| 577 |
{ |
| 578 |
createDiagnostic |
| 579 |
(XSDDiagnosticSeverity.ERROR_LITERAL, "_UI_UnresolvedIdentityConstraintDefinition_message", theReferencedKey.getURI()); |
| 580 |
} |
| 581 |
else |
| 582 |
{ |
| 583 |
if (theReferencedKey.getFields().size() != getFields().size()) |
| 584 |
{ |
| 585 |
createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "c-props-correct.2"); |
| 586 |
} |
| 587 |
} |
| 588 |
|
| 589 |
break; |
| 590 |
} |
| 591 |
case XSDIdentityConstraintCategory.UNIQUE: |
| 592 |
{ |
| 593 |
anchor = "element-unique"; |
| 594 |
attributes = |
| 595 |
new String [] |
| 596 |
{ |
| 597 |
XSDConstants.ID_ATTRIBUTE, |
| 598 |
XSDConstants.NAME_ATTRIBUTE |
| 599 |
}; |
| 600 |
|
| 601 |
xsdComplexTypeDefinition = getSchema().getSchemaForSchema().resolveComplexTypeDefinition("keybase"); |
| 602 |
break; |
| 603 |
} |
| 604 |
} |
| 605 |
Element theElement = getElement(); |
| 606 |
if (theElement != null) |
| 607 |
{ |
| 608 |
checkAttributes(XSDConstants.PART1, anchor, theElement, attributes); |
| 609 |
checkComplexContent(xsdComplexTypeDefinition, XSDConstants.PART1, anchor, theElement); |
| 610 |
} |
| 611 |
|
| 612 |
checkBuiltInTypeConstraint |
| 613 |
("ID", |
| 614 |
null, |
| 615 |
XSDConstants.PART1, |
| 616 |
anchor, |
| 617 |
theElement, |
| 618 |
XSDConstants.ID_ATTRIBUTE, |
| 619 |
false); |
| 620 |
|
| 621 |
checkBuiltInTypeConstraint |
| 622 |
("NCName", |
| 623 |
getName(), |
| 624 |
XSDConstants.PART1, |
| 625 |
anchor, |
| 626 |
theElement, |
| 627 |
XSDConstants.NAME_ATTRIBUTE, |
| 628 |
true); |
| 629 |
} |
| 630 |
|
| 631 |
@Override |
| 632 |
protected void reconcileAttributes(Element changedElement) |
| 633 |
{ |
| 634 |
super.reconcileAttributes(changedElement); |
| 635 |
|
| 636 |
if (changedElement == getElement()) |
| 637 |
{ |
| 638 |
XSDIdentityConstraintCategory newIdentityConstraintCategory = XSDIdentityConstraintCategory.get(changedElement.getLocalName()); |
| 639 |
if (newIdentityConstraintCategory != getIdentityConstraintCategory()) |
| 640 |
{ |
| 641 |
setIdentityConstraintCategory(newIdentityConstraintCategory); |
| 642 |
} |
| 643 |
|
| 644 |
if (newIdentityConstraintCategory == XSDIdentityConstraintCategory.KEYREF_LITERAL) |
| 645 |
{ |
| 646 |
XSDIdentityConstraintDefinition newReferencedKey = null; |
| 647 |
if (changedElement.hasAttributeNS(null, XSDConstants.REFER_ATTRIBUTE)) |
| 648 |
{ |
| 649 |
newReferencedKey = |
| 650 |
resolveIdentityConstraintDefinitionURI(XSDConstants.lookupQNameForAttribute(changedElement, XSDConstants.REFER_ATTRIBUTE)); |
| 651 |
} |
| 652 |
|
| 653 |
if (newReferencedKey != getReferencedKey()) |
| 654 |
{ |
| 655 |
setReferencedKey(newReferencedKey); |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
@Override |
| 662 |
protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 663 |
{ |
| 664 |
XSDXPathDefinition xsdXPathDefinition = XSDXPathDefinitionImpl.createXPathDefinition(child); |
| 665 |
if (xsdXPathDefinition != null) |
| 666 |
{ |
| 667 |
newContents.add(xsdXPathDefinition); |
| 668 |
} |
| 669 |
else |
| 670 |
{ |
| 671 |
XSDAnnotation xsdAnnotation = XSDAnnotationImpl.createAnnotation(child); |
| 672 |
if (xsdAnnotation != null && newContents.isEmpty()) |
| 673 |
{ |
| 674 |
newContents.add(xsdAnnotation); |
| 675 |
} |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
@Override |
| 680 |
protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents) |
| 681 |
{ |
| 682 |
handleAnnotationReconciliation(XSDPackage.Literals.XSD_IDENTITY_CONSTRAINT_DEFINITION__ANNOTATION, newContents, remainingContents); |
| 683 |
|
| 684 |
XSDXPathDefinition newSelector = null; |
| 685 |
if (!newContents.isEmpty()) |
| 686 |
{ |
| 687 |
newSelector = (XSDXPathDefinition)newContents.get(0); |
| 688 |
if (XSDXPathVariety.SELECTOR_LITERAL == newSelector.getVariety()) |
| 689 |
{ |
| 690 |
newContents.remove(0); |
| 691 |
} |
| 692 |
else |
| 693 |
{ |
| 694 |
newSelector = null; |
| 695 |
} |
| 696 |
} |
| 697 |
|
| 698 |
if (newSelector != getSelector()) |
| 699 |
{ |
| 700 |
remainingContents.remove(getSelector()); |
| 701 |
setSelector(newSelector); |
| 702 |
} |
| 703 |
|
| 704 |
if (!remainingContents.isEmpty()) |
| 705 |
{ |
| 706 |
getFields().removeAll(remainingContents); |
| 707 |
} |
| 708 |
|
| 709 |
if (!newContents.isEmpty()) |
| 710 |
{ |
| 711 |
@SuppressWarnings("unchecked") List<XSDXPathDefinition> list = (List<XSDXPathDefinition>)(List<?>)newContents; |
| 712 |
setListContentAndOrder(getFields(), list); |
| 713 |
} |
| 714 |
} |
| 715 |
|
| 716 |
@Override |
| 717 |
protected void changeAttribute(EAttribute eAttribute) |
| 718 |
{ |
| 719 |
super.changeAttribute(eAttribute); |
| 720 |
Element theElement = getElement(); |
| 721 |
if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_IDENTITY_CONSTRAINT_DEFINITION__IDENTITY_CONSTRAINT_CATEGORY) |
| 722 |
{ |
| 723 |
if (theElement != null && eAttribute != null && !isReconciling) |
| 724 |
{ |
| 725 |
Element newElement = |
| 726 |
createElement |
| 727 |
(XSDIdentityConstraintCategory.UNIQUE_LITERAL == getIdentityConstraintCategory() ? |
| 728 |
XSDConstants.UNIQUE_ELEMENT : |
| 729 |
XSDIdentityConstraintCategory.KEYREF_LITERAL == getIdentityConstraintCategory() ? |
| 730 |
XSDConstants.KEYREF_ELEMENT : |
| 731 |
XSDConstants.KEY_ELEMENT); |
| 732 |
|
| 733 |
forceReplace(newElement, theElement); |
| 734 |
setElement(newElement); |
| 735 |
} |
| 736 |
} |
| 737 |
} |
| 738 |
|
| 739 |
@Override |
| 740 |
protected void adoptBy(XSDSchema xsdSchema) |
| 741 |
{ |
| 742 |
super.adoptBy(xsdSchema); |
| 743 |
if (!xsdSchema.getIdentityConstraintDefinitions().contains(this)) |
| 744 |
{ |
| 745 |
XSDNamedComponentImpl.addToSortedList(xsdSchema.getIdentityConstraintDefinitions(), this); |
| 746 |
} |
| 747 |
} |
| 748 |
|
| 749 |
@Override |
| 750 |
protected void orphanBy(XSDSchema xsdSchema) |
| 751 |
{ |
| 752 |
xsdSchema.getIdentityConstraintDefinitions().remove(this); |
| 753 |
super.orphanBy(xsdSchema); |
| 754 |
} |
| 755 |
|
| 756 |
@Override |
| 757 |
protected void changeReference(EReference eReference) |
| 758 |
{ |
| 759 |
super.changeReference(eReference); |
| 760 |
Element theElement = getElement(); |
| 761 |
if (XSDIdentityConstraintCategory.KEYREF_LITERAL == getIdentityConstraintCategory()) |
| 762 |
{ |
| 763 |
if (eReference == null || eReference == XSDPackage.Literals.XSD_IDENTITY_CONSTRAINT_DEFINITION__REFERENCED_KEY) |
| 764 |
{ |
| 765 |
XSDIdentityConstraintDefinition theReferencedKey = getReferencedKey(); |
| 766 |
if (theElement != null) |
| 767 |
{ |
| 768 |
niceSetAttributeURIValue(theElement, XSDConstants.REFER_ATTRIBUTE, theReferencedKey == null ? null : theReferencedKey.getURI()); |
| 769 |
} |
| 770 |
} |
| 771 |
} |
| 772 |
} |
| 773 |
|
| 774 |
@Override |
| 775 |
public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM) |
| 776 |
{ |
| 777 |
XSDIdentityConstraintDefinitionImpl clonedIdentityConstraintDefinition = |
| 778 |
(XSDIdentityConstraintDefinitionImpl)getXSDFactory().createXSDIdentityConstraintDefinition(); |
| 779 |
clonedIdentityConstraintDefinition.isReconciling = true; |
| 780 |
|
| 781 |
if (getName() != null) |
| 782 |
{ |
| 783 |
clonedIdentityConstraintDefinition.setName(getName()); |
| 784 |
} |
| 785 |
clonedIdentityConstraintDefinition.setIdentityConstraintCategory(getIdentityConstraintCategory()); |
| 786 |
|
| 787 |
XSDIdentityConstraintDefinition theReferencedKey = getReferencedKey(); |
| 788 |
if (theReferencedKey != null) |
| 789 |
{ |
| 790 |
clonedIdentityConstraintDefinition.setReferencedKey |
| 791 |
(createUnresolvedIdentityConstraintDefinition |
| 792 |
(theReferencedKey.getTargetNamespace(), theReferencedKey.getName())); |
| 793 |
} |
| 794 |
|
| 795 |
if (deep) |
| 796 |
{ |
| 797 |
if (getAnnotation() != null) |
| 798 |
{ |
| 799 |
clonedIdentityConstraintDefinition.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM)); |
| 800 |
} |
| 801 |
if (getSelector() != null) |
| 802 |
{ |
| 803 |
clonedIdentityConstraintDefinition.setSelector((XSDXPathDefinition)getSelector().cloneConcreteComponent(deep, shareDOM)); |
| 804 |
} |
| 805 |
if (!getFields().isEmpty()) |
| 806 |
{ |
| 807 |
clonedIdentityConstraintDefinition.getFields().addAll(cloneConcreteComponents(getFields(), deep, shareDOM)); |
| 808 |
} |
| 809 |
} |
| 810 |
|
| 811 |
if (shareDOM && getElement() != null) |
| 812 |
{ |
| 813 |
clonedIdentityConstraintDefinition.setElement(getElement()); |
| 814 |
} |
| 815 |
|
| 816 |
clonedIdentityConstraintDefinition.isReconciling = shareDOM; |
| 817 |
return clonedIdentityConstraintDefinition; |
| 818 |
} |
| 819 |
} |