Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDAttributeGroupDefinitionImpl.java

raw
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.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.HashSet;
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.Set;
22
23 import org.w3c.dom.Element;
24 import org.w3c.dom.Node;
25
26 import org.eclipse.emf.common.notify.Notification;
27 import org.eclipse.emf.common.notify.NotificationChain;
28 import org.eclipse.emf.common.util.EList;
29 import org.eclipse.emf.common.util.UniqueEList;
30 import org.eclipse.emf.ecore.EClass;
31 import org.eclipse.emf.ecore.EObject;
32 import org.eclipse.emf.ecore.EReference;
33 import org.eclipse.emf.ecore.InternalEObject;
34 import org.eclipse.emf.ecore.impl.ENotificationImpl;
35 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
36 import org.eclipse.emf.ecore.util.EObjectEList;
37 import org.eclipse.emf.ecore.util.InternalEList;
38
39 import org.eclipse.xsd.XSDAnnotation;
40 import org.eclipse.xsd.XSDAttributeDeclaration;
41 import org.eclipse.xsd.XSDAttributeGroupContent;
42 import org.eclipse.xsd.XSDAttributeGroupDefinition;
43 import org.eclipse.xsd.XSDAttributeUse;
44 import org.eclipse.xsd.XSDAttributeUseCategory;
45 import org.eclipse.xsd.XSDComponent;
46 import org.eclipse.xsd.XSDConcreteComponent;
47 import org.eclipse.xsd.XSDDiagnosticSeverity;
48 import org.eclipse.xsd.XSDFactory;
49 import org.eclipse.xsd.XSDNamedComponent;
50 import org.eclipse.xsd.XSDNamespaceConstraintCategory;
51 import org.eclipse.xsd.XSDPackage;
52 import org.eclipse.xsd.XSDRedefine;
53 import org.eclipse.xsd.XSDSchema;
54 import org.eclipse.xsd.XSDWildcard;
55 import org.eclipse.xsd.util.XSDConstants;
56
57
58 /**
59 * <!-- begin-user-doc -->
60 * An implementation of the model object '<em><b>Attribute Group Definition</b></em>'.
61 * <!-- end-user-doc -->
62 * <p>
63 * The following features are implemented:
64 * </p>
65 * <ul>
66 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#isAttributeGroupDefinitionReference <em>Attribute Group Definition Reference</em>}</li>
67 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getAnnotation <em>Annotation</em>}</li>
68 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getContents <em>Contents</em>}</li>
69 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getAttributeUses <em>Attribute Uses</em>}</li>
70 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getAttributeWildcardContent <em>Attribute Wildcard Content</em>}</li>
71 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getAttributeWildcard <em>Attribute Wildcard</em>}</li>
72 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getResolvedAttributeGroupDefinition <em>Resolved Attribute Group Definition</em>}</li>
73 * <li>{@link org.eclipse.xsd.impl.XSDAttributeGroupDefinitionImpl#getSyntheticWildcard <em>Synthetic Wildcard</em>}</li>
74 * </ul>
75 *
76 * @generated
77 */
78 public class XSDAttributeGroupDefinitionImpl
79 extends XSDRedefinableComponentImpl
80 implements XSDAttributeGroupDefinition
81 {
82 /**
83 * The default value of the '{@link #isAttributeGroupDefinitionReference() <em>Attribute Group Definition Reference</em>}' attribute.
84 * <!-- begin-user-doc -->
85 * <!-- end-user-doc -->
86 * @see #isAttributeGroupDefinitionReference()
87 * @generated
88 * @ordered
89 */
90 protected static final boolean ATTRIBUTE_GROUP_DEFINITION_REFERENCE_EDEFAULT = false;
91
92 /**
93 * The cached value of the '{@link #getAnnotation() <em>Annotation</em>}' containment reference.
94 * <!-- begin-user-doc -->
95 * <!-- end-user-doc -->
96 * @see #getAnnotation()
97 * @generated
98 * @ordered
99 */
100 protected XSDAnnotation annotation;
101
102 /**
103 * The cached value of the '{@link #getContents() <em>Contents</em>}' containment reference list.
104 * <!-- begin-user-doc -->
105 * <!-- end-user-doc -->
106 * @see #getContents()
107 * @generated
108 * @ordered
109 */
110 protected EList<XSDAttributeGroupContent> contents;
111
112 /**
113 * The cached value of the '{@link #getAttributeUses() <em>Attribute Uses</em>}' reference list.
114 * <!-- begin-user-doc -->
115 * <!-- end-user-doc -->
116 * @see #getAttributeUses()
117 * @generated
118 * @ordered
119 */
120 protected EList<XSDAttributeUse> attributeUses;
121
122 /**
123 * The cached value of the '{@link #getAttributeWildcardContent() <em>Attribute Wildcard Content</em>}' containment reference.
124 * <!-- begin-user-doc -->
125 * <!-- end-user-doc -->
126 * @see #getAttributeWildcardContent()
127 * @generated
128 * @ordered
129 */
130 protected XSDWildcard attributeWildcardContent;
131
132 /**
133 * The cached value of the '{@link #getAttributeWildcard() <em>Attribute Wildcard</em>}' reference.
134 * <!-- begin-user-doc -->
135 * <!-- end-user-doc -->
136 * @see #getAttributeWildcard()
137 * @generated
138 * @ordered
139 */
140 protected XSDWildcard attributeWildcard;
141
142 /**
143 * The cached value of the '{@link #getResolvedAttributeGroupDefinition() <em>Resolved Attribute Group Definition</em>}' reference.
144 * <!-- begin-user-doc -->
145 * <!-- end-user-doc -->
146 * @see #getResolvedAttributeGroupDefinition()
147 * @generated
148 * @ordered
149 */
150 protected XSDAttributeGroupDefinition resolvedAttributeGroupDefinition;
151
152 /**
153 * The cached value of the '{@link #getSyntheticWildcard() <em>Synthetic Wildcard</em>}' containment reference.
154 * <!-- begin-user-doc -->
155 * <!-- end-user-doc -->
156 * @see #getSyntheticWildcard()
157 * @generated
158 * @ordered
159 */
160 protected XSDWildcard syntheticWildcard;
161
162 public static XSDAttributeGroupDefinition createAttributeGroupDefinition(Node node)
163 {
164 if (XSDConstants.nodeType(node) == XSDConstants.ATTRIBUTEGROUP_ELEMENT)
165 {
166 XSDAttributeGroupDefinition xsdAttributeGroupDefinition = XSDFactory.eINSTANCE.createXSDAttributeGroupDefinition();
167 xsdAttributeGroupDefinition.setElement((Element)node);
168 return xsdAttributeGroupDefinition;
169 }
170
171 return null;
172 }
173
174 protected int analysisState;
175
176 /**
177 * <!-- begin-user-doc -->
178 * <!-- end-user-doc -->
179 * @generated NOT
180 */
181 protected XSDAttributeGroupDefinitionImpl()
182 {
183 super();
184 this.resolvedAttributeGroupDefinition = this;
185 // this.setResolvedAttributeGroupDefinition = true;
186 }
187
188 /**
189 * <!-- begin-user-doc -->
190 * <!-- end-user-doc -->
191 * @generated
192 */
193 @Override
194 protected EClass eStaticClass()
195 {
196 return XSDPackage.Literals.XSD_ATTRIBUTE_GROUP_DEFINITION;
197 }
198
199 /**
200 * <!-- begin-user-doc -->
201 * <!-- end-user-doc -->
202 * @generated modifiable
203 */
204 public Boolean getAttributeGroupDefinitionReference()
205 {
206 return isAttributeGroupDefinitionReference() ? Boolean.TRUE : Boolean.FALSE;
207 }
208
209 @Override
210 public Element createElement()
211 {
212 Element newElement = createElement(XSDConstants.ATTRIBUTEGROUP_ELEMENT);
213 setElement(newElement);
214
215 for (XSDAttributeGroupContent xsdAttributeGroupContent : getContents())
216 {
217 if (xsdAttributeGroupContent instanceof XSDAttributeGroupDefinition)
218 {
219 XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition)xsdAttributeGroupContent;
220 Element attributeGroupDefinitionElement = ((XSDConcreteComponentImpl)xsdAttributeGroupDefinition).createElement();
221 newElement.appendChild(attributeGroupDefinitionElement);
222 }
223 else
224 {
225 XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdAttributeGroupContent;
226 Element attributeUseElement = ((XSDConcreteComponentImpl)xsdAttributeUse).createElement();
227 newElement.appendChild(attributeUseElement);
228 }
229 }
230
231 return newElement;
232 }
233
234 @Override
235 protected void patch()
236 {
237 analysisState = UNANALYZED;
238 super.patch();
239 XSDAttributeGroupDefinition theResolvedAttributeGroupDefinition = getResolvedAttributeGroupDefinition();
240 if (theResolvedAttributeGroupDefinition != this &&
241 (forceResolve || theResolvedAttributeGroupDefinition.getContainer() == null))
242 {
243 XSDAttributeGroupDefinition newResolvedAttributeGroupDefinition =
244 resolveAttributeGroupDefinition
245 (theResolvedAttributeGroupDefinition.getTargetNamespace(), theResolvedAttributeGroupDefinition.getName());
246 if (forceResolve || newResolvedAttributeGroupDefinition.getContainer() != null)
247 {
248 handleNewResolvedAttributeGroupDefinition(newResolvedAttributeGroupDefinition);
249 }
250 }
251 }
252
253 @Override
254 protected void traverseToRootForAnalysis()
255 {
256 analysisState = UNANALYZED;
257 super.traverseToRootForAnalysis();
258 }
259
260 @Override
261 protected boolean analyze()
262 {
263 switch (analysisState)
264 {
265 case UNANALYZED:
266 {
267 analysisState = ANALYZING;
268 super.analyze();
269 handleAnalysis();
270 if (analysisState == ANALYZING)
271 {
272 analysisState = ANALYZED;
273 return true;
274 }
275 else
276 {
277 return false;
278 }
279 }
280 case ANALYZED:
281 {
282 return true;
283 }
284 case ANALYZING:
285 case CIRCULAR:
286 default:
287 {
288 analysisState = CIRCULAR;
289 return false;
290 }
291 }
292 }
293
294 protected XSDWildcardImpl effectiveWildcard;
295 protected void handleAnalysis()
296 {
297 List<XSDAttributeUse> newAttributeUses = getAttributeUses(getContents(), Collections.<XSDAttributeUse>emptyList());
298 List<XSDAttributeUse> remainingAttributeUses = new ArrayList<XSDAttributeUse>(getAttributeUses());
299 remainingAttributeUses.removeAll(newAttributeUses);
300 if (!remainingAttributeUses.isEmpty())
301 {
302 getAttributeUses().removeAll(remainingAttributeUses);
303 }
304 setListContentAndOrder(getAttributeUses(), newAttributeUses);
305
306 XSDWildcard newAttributeWildcard = getAttributeWildcard(null, getAttributeWildcardContent(), getContents());
307
308 if (newAttributeWildcard != null && newAttributeWildcard.getContainer() == null)
309 {
310 if (effectiveWildcard == null)
311 {
312 effectiveWildcard = (XSDWildcardImpl)getXSDFactory().createXSDWildcard();
313 // effectiveWildcard.setOwner(this);
314 setSyntheticWildcard(effectiveWildcard);
315 }
316 effectiveWildcard.setLike(newAttributeWildcard);
317 newAttributeWildcard = effectiveWildcard;
318 }
319
320 if (newAttributeWildcard != getAttributeWildcard())
321 {
322 setAttributeWildcard(newAttributeWildcard);
323 }
324 }
325
326 @Override
327 public void validate()
328 {
329 super.validate();
330
331 Element theElement = getElement();
332 if (theElement != null)
333 {
334 if (getContainer() instanceof XSDSchema || getContainer() instanceof XSDRedefine)
335 {
336 checkAttributes
337 (XSDConstants.PART1,
338 "element-attributeGroup",
339 theElement,
340 new String []
341 {
342 XSDConstants.ID_ATTRIBUTE,
343 XSDConstants.NAME_ATTRIBUTE
344 });
345
346 checkComplexContent("namedAttributeGroup", XSDConstants.PART1, "element-attributeGroup", theElement);
347 }
348 else
349 {
350 checkAttributes
351 (XSDConstants.PART1,
352 "element-attributeGroup",
353 theElement,
354 new String []
355 {
356 XSDConstants.ID_ATTRIBUTE,
357 XSDConstants.REF_ATTRIBUTE
358 });
359
360 checkComplexContent("attributeGroupRef", XSDConstants.PART1, "element-attributeGroup", theElement);
361 }
362
363 checkBuiltInTypeConstraint
364 ("ID",
365 null,
366 XSDConstants.PART1,
367 "element-attributeGroup",
368 theElement,
369 XSDConstants.ID_ATTRIBUTE,
370 false);
371 }
372
373 if (getContainer() instanceof XSDSchema || getContainer() instanceof XSDRedefine)
374 {
375 if (isAttributeGroupDefinitionReference())
376 {
377 if (theElement == null)
378 {
379 createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "cvc-complex-type.3", "ref");
380 }
381 }
382 else
383 {
384 checkBuiltInTypeConstraint
385 ("NCName",
386 getName(),
387 XSDConstants.PART1,
388 "element-attributeGroup",
389 theElement,
390 XSDConstants.NAME_ATTRIBUTE,
391 true);
392
393 XSDWildcard theAttributeWildcard = getAttributeWildcard();
394 if (theAttributeWildcard != null &&
395 theAttributeWildcard.getNamespaceConstraint().isEmpty() &&
396 theAttributeWildcard.getNamespaceConstraintCategory() == XSDNamespaceConstraintCategory.NOT_LITERAL)
397 {
398 createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "src-attribute_group.2");
399 }
400
401 if (isCircular())
402 {
403 createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "src-attribute_group.3");
404 }
405
406 XSDAttributeDeclaration idAttribute = null;
407 Set<String> uris = new HashSet<String>();
408 for (XSDAttributeUse xsdAttributeUse : getAttributeUses())
409 {
410 XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration();
411 if (!uris.add(xsdAttributeDeclaration.getURI()))
412 {
413 getDiagnosticTarget(xsdAttributeUse).createDiagnostic
414 (XSDDiagnosticSeverity.ERROR_LITERAL, "coss-attrGroup.2", xsdAttributeDeclaration.getURI());
415 }
416 if (XSDConstants.isOrIsDerivedFromID(xsdAttributeDeclaration.getTypeDefinition()))
417 {
418 if (idAttribute != null)
419 {
420 getDiagnosticTarget(xsdAttributeUse).createDiagnostic
421 (XSDDiagnosticSeverity.ERROR_LITERAL, "coss-attrGroup.3", xsdAttributeDeclaration.getURI(), idAttribute.getURI());
422 }
423 else
424 {
425 idAttribute = xsdAttributeDeclaration;
426 }
427 }
428 }
429 }
430 }
431 else
432 {
433 if (isAttributeGroupDefinitionReference())
434 {
435 XSDAttributeGroupDefinition theResolvedAttributeGroupDefinition = getResolvedAttributeGroupDefinition();
436 if (theResolvedAttributeGroupDefinition.getContainer() == null)
437 {
438 createDiagnostic
439 (XSDDiagnosticSeverity.ERROR_LITERAL,
440 "_UI_UnresolvedAttributeGroupDefinition_message",
441 theResolvedAttributeGroupDefinition.getURI());
442 }
443 }
444 else
445 {
446 if (theElement == null)
447 {
448 createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "cvc-complex-type.3", "name");
449 }
450 }
451 }
452 }
453
454 public static List<XSDAttributeUse> getAttributeUses
455 (Collection<XSDAttributeGroupContent> xsdAttributeGroupContents, Collection<XSDAttributeUse> xsdAttributeUses)
456 {
457 List<XSDAttributeUse> result = new UniqueEList<XSDAttributeUse>();
458 Set<String> localAttributeUses = new HashSet<String>();
459
460 for (XSDAttributeGroupContent xsdAttributeGroupContent : xsdAttributeGroupContents)
461 {
462 ((XSDConcreteComponentImpl)xsdAttributeGroupContent).analyze();
463 if (xsdAttributeGroupContent instanceof XSDAttributeUse)
464 {
465 XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdAttributeGroupContent;
466 if (xsdAttributeUse.getUse() != XSDAttributeUseCategory.PROHIBITED_LITERAL)
467 {
468 result.add(xsdAttributeUse);
469 }
470 localAttributeUses.add(xsdAttributeUse.getAttributeDeclaration().getURI());
471 }
472 else
473 {
474 XSDAttributeGroupDefinition xsdAttributeGroupDefinition =
475 ((XSDAttributeGroupDefinition)xsdAttributeGroupContent).getResolvedAttributeGroupDefinition();
476 ((XSDConcreteComponentImpl)xsdAttributeGroupDefinition).analyze();
477 result.addAll(xsdAttributeGroupDefinition.getAttributeUses());
478 }
479 }
480
481 for (XSDAttributeUse xsdAttributeUse : xsdAttributeUses)
482 {
483 if (!localAttributeUses.contains(xsdAttributeUse.getAttributeDeclaration().getURI()))
484 {
485 result.add(xsdAttributeUse);
486 }
487 }
488
489 return XSDAttributeUseImpl.sortAttributeUses(result);
490 }
491
492 public static XSDWildcard getAttributeWildcard
493 (XSDWildcard baseWildcard, XSDWildcard localWildcard, Collection<XSDAttributeGroupContent> xsdAttributeGroupContents)
494 {
495 for (XSDAttributeGroupContent xsdAttributeGroupContent : xsdAttributeGroupContents)
496 {
497 ((XSDConcreteComponentImpl)xsdAttributeGroupContent).analyze();
498 if (xsdAttributeGroupContent instanceof XSDAttributeGroupDefinition)
499 {
500 XSDAttributeGroupDefinition xsdAttributeGroupDefinition =
501 ((XSDAttributeGroupDefinition)xsdAttributeGroupContent).getResolvedAttributeGroupDefinition();
502 ((XSDConcreteComponentImpl)xsdAttributeGroupDefinition).analyze();
503 XSDWildcard attributeGroupWildcard = xsdAttributeGroupDefinition.getAttributeWildcard();
504 if (attributeGroupWildcard != null)
505 {
506 if (localWildcard == null)
507 {
508 localWildcard = attributeGroupWildcard;
509 }
510 else
511 {
512 localWildcard = localWildcard.attributeWildcardIntersection(attributeGroupWildcard);
513 if (localWildcard == null)
514 {
515 return null;
516 }
517 else if (localWildcard.getNamespaceConstraint().isEmpty() &&
518 localWildcard.getNamespaceConstraintCategory() == XSDNamespaceConstraintCategory.NOT_LITERAL)
519 {
520 // Failure
521 //
522 return localWildcard;
523 }
524 }
525 }
526 }
527 }
528
529 if (localWildcard == null)
530 {
531 localWildcard = baseWildcard;
532 }
533 else if (baseWildcard != null)
534 {
535 localWildcard = localWildcard.attributeWildcardUnion(baseWildcard);
536 }
537 return localWildcard;
538 }
539
540 @Override
541 protected void patchTargetNamespaceAttribute(XSDSchema xsdSchema)
542 {
543 if (!isAttributeGroupDefinitionReference())
544 {
545 super.patchTargetNamespaceAttribute(xsdSchema);
546 }
547 }
548
549 @Override
550 protected void reconcileAttributes(Element changedElement)
551 {
552 super.reconcileAttributes(changedElement);
553
554 XSDAttributeGroupDefinition newResolvedAttributeGroupDefinition = this;
555 if (changedElement.hasAttributeNS(null, XSDConstants.REF_ATTRIBUTE))
556 {
557 newResolvedAttributeGroupDefinition =
558 resolveAttributeGroupDefinitionURI(XSDConstants.lookupQNameForAttribute(changedElement, XSDConstants.REF_ATTRIBUTE));
559 }
560
561 handleNewResolvedAttributeGroupDefinition(newResolvedAttributeGroupDefinition);
562 }
563
564 protected void handleNewResolvedAttributeGroupDefinition(XSDAttributeGroupDefinition newResolvedAttributeGroupDefinition)
565 {
566 if (eContainer != null)
567 {
568 EObject parent = eContainer.eContainer();
569 if (parent instanceof XSDRedefine)
570 {
571 XSDSchema redefinedSchema = ((XSDRedefine)parent).getIncorporatedSchema();
572 if (redefinedSchema != null)
573 {
574 Map<XSDComponent, XSDComponent> redefinitionMap = ((XSDSchemaImpl)redefinedSchema).getRedefinitionMap();
575 if (redefinitionMap.containsKey(newResolvedAttributeGroupDefinition))
576 {
577 XSDComponent replacement = redefinitionMap.get(newResolvedAttributeGroupDefinition);
578 if (replacement != null)
579 {
580 newResolvedAttributeGroupDefinition = (XSDAttributeGroupDefinition)replacement;
581 }
582 }
583 }
584 }
585 }
586 if (newResolvedAttributeGroupDefinition != getResolvedAttributeGroupDefinition())
587 {
588 setResolvedAttributeGroupDefinition(newResolvedAttributeGroupDefinition);
589 }
590 }
591
592 @Override
593 protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
594 {
595 XSDAnnotation xsdAnnotation = XSDAnnotationImpl.createAnnotation(child);
596 if (xsdAnnotation != null)
597 {
598 newContents.add(xsdAnnotation);
599 }
600 else
601 {
602 XSDAttributeGroupContent xsdAttributeGroupContent = XSDAttributeGroupContentImpl.createAttributeGroupContent(child);
603 if (xsdAttributeGroupContent != null)
604 {
605 newContents.add(xsdAttributeGroupContent);
606 }
607 else
608 {
609 XSDWildcard xsdWildcard = XSDWildcardImpl.createWildcard(child);
610 if (xsdWildcard != null)
611 {
612 newContents.add(xsdWildcard);
613 }
614 }
615 }
616 }
617
618 @Override
619 protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
620 {
621 handleAnnotationReconciliation(XSDPackage.Literals.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION, newContents, remainingContents);
622
623 XSDWildcard newAttributeWildcard = null;
624 if (!newContents.isEmpty())
625 {
626 int lastIndex = newContents.size() - 1;
627 Object last = newContents.get(lastIndex);
628 if (last instanceof XSDWildcard)
629 {
630 newAttributeWildcard = (XSDWildcard)last;
631 if (XSDConstants.nodeType(newAttributeWildcard.getElement()) == XSDConstants.ANYATTRIBUTE_ELEMENT)
632 {
633 newContents.remove(lastIndex);
634 }
635 else
636 {
637 newAttributeWildcard = null;
638 }
639 }
640 }
641
642 if (newAttributeWildcard != getAttributeWildcardContent())
643 {
644 remainingContents.remove(getAttributeWildcardContent());
645 setAttributeWildcardContent(newAttributeWildcard);
646 }
647
648
649 if (!remainingContents.isEmpty())
650 {
651 getContents().removeAll(remainingContents);
652 }
653
654 if (!newContents.isEmpty())
655 {
656 for (Iterator<XSDConcreteComponent> i = newContents.iterator(); i.hasNext(); )
657 {
658 if (!(i.next() instanceof XSDAttributeGroupContent))
659 {
660 i.remove();
661 }
662 }
663 @SuppressWarnings("unchecked") List<XSDAttributeGroupContent> list = (List<XSDAttributeGroupContent>)(List<?>)newContents;
664 setListContentAndOrder(getContents(), list);
665 }
666 }
667
668 @Override
669 protected void changeReference(EReference eReference)
670 {
671 if (isReconciling)
672 {
673 return;
674 }
675
676 super.changeReference(eReference);
677 Element theElement = getElement();
678 if (theElement != null)
679 {
680 if (eReference == null || eReference == XSDPackage.Literals.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION)
681 {
682 XSDAttributeGroupDefinition theResolvedAttributeGroupDefinition = getResolvedAttributeGroupDefinition();
683 if (theResolvedAttributeGroupDefinition != this)
684 {
685 niceSetAttributeURIValue(theElement, XSDConstants.REF_ATTRIBUTE, theResolvedAttributeGroupDefinition.getURI());
686 }
687 }
688 }
689 }
690
691 @Override
692 protected void adoptContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
693 {
694 super.adoptContent(eReference, xsdConcreteComponent);
695 if (eReference == XSDPackage.Literals.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS)
696 {
697 traverseToRootForPatching();
698 }
699 }
700
701 @Override
702 protected void orphanContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
703 {
704 super.orphanContent(eReference, xsdConcreteComponent);
705 if (eReference == XSDPackage.Literals.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS)
706 {
707 traverseToRootForPatching();
708 }
709 }
710
711 public boolean isAttributeGroupDefinitionReference()
712 {
713 return this != getResolvedAttributeGroupDefinition();
714 }
715
716 /**
717 * <!-- begin-user-doc -->
718 * <!-- end-user-doc -->
719 * @generated
720 */
721 @Override
722 public XSDAnnotation getAnnotation()
723 {
724 return annotation;
725 }
726
727 /**
728 * <!-- begin-user-doc -->
729 * <!-- end-user-doc -->
730 * @generated
731 */
732 @Override
733 public void setAnnotation(XSDAnnotation newAnnotation)
734 {
735 if (newAnnotation != annotation)
736 {
737 NotificationChain msgs = null;
738 if (annotation != null)
739 msgs = ((InternalEObject)annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION, null, msgs);
740 if (newAnnotation != null)
741 msgs = ((InternalEObject)newAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION, null, msgs);
742 msgs = basicSetAnnotation(newAnnotation, msgs);
743 if (msgs != null) msgs.dispatch();
744 }
745 else if (eNotificationRequired())
746 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION, newAnnotation, newAnnotation));
747 }
748
749 /**
750 * <!-- begin-user-doc -->
751 * <!-- end-user-doc -->
752 * @generated
753 */
754 public NotificationChain basicSetAnnotation(XSDAnnotation newAnnotation, NotificationChain msgs)
755 {
756 XSDAnnotation oldAnnotation = annotation;
757 annotation = newAnnotation;
758 if (eNotificationRequired())
759 {
760 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION, oldAnnotation, newAnnotation);
761 if (msgs == null) msgs = notification; else msgs.add(notification);
762 }
763 return msgs;
764 }
765
766 /**
767 * <!-- begin-user-doc -->
768 * <!-- end-user-doc -->
769 * @generated
770 */
771 @Override
772 public EList<XSDAttributeGroupContent> getContents()
773 {
774 if (contents == null)
775 {
776 contents = new EObjectContainmentEList<XSDAttributeGroupContent>(XSDAttributeGroupContent.class, this, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS);
777 }
778 return contents;
779 }
780
781 /**
782 * <!-- begin-user-doc -->
783 * <!-- end-user-doc -->
784 * @generated
785 */
786 @Override
787 public EList<XSDAttributeUse> getAttributeUses()
788 {
789 if (attributeUses == null)
790 {
791 attributeUses = new EObjectEList<XSDAttributeUse>(XSDAttributeUse.class, this, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_USES);
792 }
793 return attributeUses;
794 }
795
796 /**
797 * <!-- begin-user-doc -->
798 * <!-- end-user-doc -->
799 * @generated
800 */
801 @Override
802 public XSDWildcard getAttributeWildcardContent()
803 {
804 return attributeWildcardContent;
805 }
806
807 /**
808 * <!-- begin-user-doc -->
809 * <!-- end-user-doc -->
810 * @generated
811 */
812 @Override
813 public void setAttributeWildcardContent(XSDWildcard newAttributeWildcardContent)
814 {
815 if (newAttributeWildcardContent != attributeWildcardContent)
816 {
817 NotificationChain msgs = null;
818 if (attributeWildcardContent != null)
819 msgs = ((InternalEObject)attributeWildcardContent).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT, null, msgs);
820 if (newAttributeWildcardContent != null)
821 msgs = ((InternalEObject)newAttributeWildcardContent).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT, null, msgs);
822 msgs = basicSetAttributeWildcardContent(newAttributeWildcardContent, msgs);
823 if (msgs != null) msgs.dispatch();
824 }
825 else if (eNotificationRequired())
826 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT, newAttributeWildcardContent, newAttributeWildcardContent));
827 }
828
829 /**
830 * <!-- begin-user-doc -->
831 * <!-- end-user-doc -->
832 * @generated
833 */
834 public NotificationChain basicSetAttributeWildcardContent(XSDWildcard newAttributeWildcardContent, NotificationChain msgs)
835 {
836 XSDWildcard oldAttributeWildcardContent = attributeWildcardContent;
837 attributeWildcardContent = newAttributeWildcardContent;
838 if (eNotificationRequired())
839 {
840 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT, oldAttributeWildcardContent, newAttributeWildcardContent);
841 if (msgs == null) msgs = notification; else msgs.add(notification);
842 }
843 return msgs;
844 }
845
846 /**
847 * <!-- begin-user-doc -->
848 * <!-- end-user-doc -->
849 * @generated
850 */
851 @Override
852 public XSDWildcard getAttributeWildcard()
853 {
854 return attributeWildcard;
855 }
856
857 /**
858 * <!-- begin-user-doc -->
859 * <!-- end-user-doc -->
860 * @generated
861 */
862 @Override
863 public void setAttributeWildcard(XSDWildcard newAttributeWildcard)
864 {
865 XSDWildcard oldAttributeWildcard = attributeWildcard;
866 attributeWildcard = newAttributeWildcard;
867 if (eNotificationRequired())
868 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD, oldAttributeWildcard, attributeWildcard));
869 }
870
871 /**
872 * <!-- begin-user-doc -->
873 * <!-- end-user-doc -->
874 * @generated
875 */
876 @Override
877 public XSDAttributeGroupDefinition getResolvedAttributeGroupDefinition()
878 {
879 return resolvedAttributeGroupDefinition;
880 }
881
882 /**
883 * <!-- begin-user-doc -->
884 * <!-- end-user-doc -->
885 * @generated
886 */
887 @Override
888 public void setResolvedAttributeGroupDefinition(XSDAttributeGroupDefinition newResolvedAttributeGroupDefinition)
889 {
890 XSDAttributeGroupDefinition oldResolvedAttributeGroupDefinition = resolvedAttributeGroupDefinition;
891 resolvedAttributeGroupDefinition = newResolvedAttributeGroupDefinition;
892 if (eNotificationRequired())
893 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION, oldResolvedAttributeGroupDefinition, resolvedAttributeGroupDefinition));
894 }
895
896 /**
897 * <!-- begin-user-doc -->
898 * <!-- end-user-doc -->
899 * @generated
900 */
901 @Override
902 public XSDWildcard getSyntheticWildcard()
903 {
904 return syntheticWildcard;
905 }
906
907 /**
908 * <!-- begin-user-doc -->
909 * <!-- end-user-doc -->
910 * @generated
911 */
912 public NotificationChain basicSetSyntheticWildcard(XSDWildcard newSyntheticWildcard, NotificationChain msgs)
913 {
914 XSDWildcard oldSyntheticWildcard = syntheticWildcard;
915 syntheticWildcard = newSyntheticWildcard;
916 if (eNotificationRequired())
917 {
918 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD, oldSyntheticWildcard, newSyntheticWildcard);
919 if (msgs == null) msgs = notification; else msgs.add(notification);
920 }
921 return msgs;
922 }
923
924 /**
925 * <!-- begin-user-doc -->
926 * <!-- end-user-doc -->
927 * @generated
928 */
929 @Override
930 public void setSyntheticWildcard(XSDWildcard newSyntheticWildcard)
931 {
932 if (newSyntheticWildcard != syntheticWildcard)
933 {
934 NotificationChain msgs = null;
935 if (syntheticWildcard != null)
936 msgs = ((InternalEObject)syntheticWildcard).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD, null, msgs);
937 if (newSyntheticWildcard != null)
938 msgs = ((InternalEObject)newSyntheticWildcard).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD, null, msgs);
939 msgs = basicSetSyntheticWildcard(newSyntheticWildcard, msgs);
940 if (msgs != null) msgs.dispatch();
941 }
942 else if (eNotificationRequired())
943 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD, newSyntheticWildcard, newSyntheticWildcard));
944 }
945
946 /**
947 * <!-- begin-user-doc -->
948 * <!-- end-user-doc -->
949 * @generated
950 */
951 @Override
952 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
953 {
954 switch (featureID)
955 {
956 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION:
957 return basicSetAnnotation(null, msgs);
958 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS:
959 return ((InternalEList<?>)getContents()).basicRemove(otherEnd, msgs);
960 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT:
961 return basicSetAttributeWildcardContent(null, msgs);
962 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD:
963 return basicSetSyntheticWildcard(null, msgs);
964 }
965 return super.eInverseRemove(otherEnd, featureID, msgs);
966 }
967
968 /**
969 * <!-- begin-user-doc -->
970 * <!-- end-user-doc -->
971 * @generated
972 */
973 @Override
974 public Object eGet(int featureID, boolean resolve, boolean coreType)
975 {
976 switch (featureID)
977 {
978 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_GROUP_DEFINITION_REFERENCE:
979 return isAttributeGroupDefinitionReference();
980 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION:
981 return getAnnotation();
982 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS:
983 return getContents();
984 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_USES:
985 return getAttributeUses();
986 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT:
987 return getAttributeWildcardContent();
988 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD:
989 return getAttributeWildcard();
990 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION:
991 return getResolvedAttributeGroupDefinition();
992 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD:
993 return getSyntheticWildcard();
994 }
995 return super.eGet(featureID, resolve, coreType);
996 }
997
998 /**
999 * <!-- begin-user-doc -->
1000 * <!-- end-user-doc -->
1001 * @generated
1002 */
1003 @SuppressWarnings("unchecked")
1004 @Override
1005 public void eSet(int featureID, Object newValue)
1006 {
1007 switch (featureID)
1008 {
1009 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION:
1010 setAnnotation((XSDAnnotation)newValue);
1011 return;
1012 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS:
1013 getContents().clear();
1014 getContents().addAll((Collection<? extends XSDAttributeGroupContent>)newValue);
1015 return;
1016 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_USES:
1017 getAttributeUses().clear();
1018 getAttributeUses().addAll((Collection<? extends XSDAttributeUse>)newValue);
1019 return;
1020 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT:
1021 setAttributeWildcardContent((XSDWildcard)newValue);
1022 return;
1023 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD:
1024 setAttributeWildcard((XSDWildcard)newValue);
1025 return;
1026 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION:
1027 setResolvedAttributeGroupDefinition((XSDAttributeGroupDefinition)newValue);
1028 return;
1029 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD:
1030 setSyntheticWildcard((XSDWildcard)newValue);
1031 return;
1032 }
1033 super.eSet(featureID, newValue);
1034 }
1035
1036 /**
1037 * <!-- begin-user-doc -->
1038 * <!-- end-user-doc -->
1039 * @generated
1040 */
1041 @Override
1042 public void eUnset(int featureID)
1043 {
1044 switch (featureID)
1045 {
1046 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION:
1047 setAnnotation((XSDAnnotation)null);
1048 return;
1049 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS:
1050 getContents().clear();
1051 return;
1052 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_USES:
1053 getAttributeUses().clear();
1054 return;
1055 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT:
1056 setAttributeWildcardContent((XSDWildcard)null);
1057 return;
1058 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD:
1059 setAttributeWildcard((XSDWildcard)null);
1060 return;
1061 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION:
1062 setResolvedAttributeGroupDefinition((XSDAttributeGroupDefinition)null);
1063 return;
1064 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD:
1065 setSyntheticWildcard((XSDWildcard)null);
1066 return;
1067 }
1068 super.eUnset(featureID);
1069 }
1070
1071 /**
1072 * <!-- begin-user-doc -->
1073 * <!-- end-user-doc -->
1074 * @generated
1075 */
1076 @Override
1077 public boolean eIsSet(int featureID)
1078 {
1079 switch (featureID)
1080 {
1081 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_GROUP_DEFINITION_REFERENCE:
1082 return isAttributeGroupDefinitionReference() != ATTRIBUTE_GROUP_DEFINITION_REFERENCE_EDEFAULT;
1083 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ANNOTATION:
1084 return annotation != null;
1085 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__CONTENTS:
1086 return contents != null && !contents.isEmpty();
1087 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_USES:
1088 return attributeUses != null && !attributeUses.isEmpty();
1089 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD_CONTENT:
1090 return attributeWildcardContent != null;
1091 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__ATTRIBUTE_WILDCARD:
1092 return attributeWildcard != null;
1093 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__RESOLVED_ATTRIBUTE_GROUP_DEFINITION:
1094 return resolvedAttributeGroupDefinition != null;
1095 case XSDPackage.XSD_ATTRIBUTE_GROUP_DEFINITION__SYNTHETIC_WILDCARD:
1096 return syntheticWildcard != null;
1097 }
1098 return super.eIsSet(featureID);
1099 }
1100
1101 @Override
1102 public String getQName()
1103 {
1104 XSDAttributeGroupDefinition resolvedAttributeGroupDefinition = getResolvedAttributeGroupDefinition();
1105 if (resolvedAttributeGroupDefinition == this)
1106 {
1107 return super.getQName();
1108 }
1109 else
1110 {
1111 return resolvedAttributeGroupDefinition.getQName(this);
1112 }
1113 }
1114
1115 @Override
1116 public boolean isNamedComponentReference()
1117 {
1118 return isAttributeGroupDefinitionReference();
1119 }
1120
1121 @Override
1122 public XSDNamedComponent getResolvedNamedComponent()
1123 {
1124 return getResolvedAttributeGroupDefinition();
1125 }
1126
1127 @Override
1128 public boolean isCircular()
1129 {
1130 return analysisState == CIRCULAR;
1131 }
1132
1133 @Override
1134 public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM)
1135 {
1136 XSDAttributeGroupDefinitionImpl clonedAttributeGroupDefinition =
1137 (XSDAttributeGroupDefinitionImpl)getXSDFactory().createXSDAttributeGroupDefinition();
1138 clonedAttributeGroupDefinition.isReconciling = true;
1139
1140 if (isAttributeGroupDefinitionReference())
1141 {
1142 XSDAttributeGroupDefinition theResolvedAttributeGroupDefinition = getResolvedAttributeGroupDefinition();
1143 clonedAttributeGroupDefinition.setResolvedAttributeGroupDefinition
1144 (createUnresolvedAttributeGroupDefinition
1145 (theResolvedAttributeGroupDefinition.getTargetNamespace(), theResolvedAttributeGroupDefinition.getName()));
1146 }
1147 else
1148 {
1149 if (getName() != null)
1150 {
1151 clonedAttributeGroupDefinition.setName(getName());
1152 }
1153 }
1154
1155 if (deep)
1156 {
1157 if (getAnnotation() != null)
1158 {
1159 clonedAttributeGroupDefinition.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(true, shareDOM));
1160 }
1161
1162 if (!getContents().isEmpty())
1163 {
1164 clonedAttributeGroupDefinition.getContents().addAll(cloneConcreteComponents(getContents(), true, shareDOM));
1165 }
1166
1167 if (getAttributeWildcardContent() != null)
1168 {
1169 clonedAttributeGroupDefinition.setAttributeWildcardContent
1170 ((XSDWildcard)getAttributeWildcardContent().cloneConcreteComponent(true, shareDOM));
1171 }
1172 }
1173
1174 if (shareDOM && getElement() != null)
1175 {
1176 clonedAttributeGroupDefinition.setElement(getElement());
1177 }
1178
1179 clonedAttributeGroupDefinition.isReconciling = shareDOM;
1180 return clonedAttributeGroupDefinition;
1181 }
1182 }