Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDWildcardImpl.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.List;
17 import java.util.StringTokenizer;
18
19 import org.w3c.dom.Element;
20 import org.w3c.dom.Node;
21
22 import org.eclipse.emf.common.notify.Notification;
23 import org.eclipse.emf.common.notify.NotificationChain;
24 import org.eclipse.emf.common.util.EList;
25 import org.eclipse.emf.ecore.EAttribute;
26 import org.eclipse.emf.ecore.EClass;
27 import org.eclipse.emf.ecore.EReference;
28 import org.eclipse.emf.ecore.InternalEObject;
29 import org.eclipse.emf.ecore.impl.ENotificationImpl;
30 import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
31 import org.eclipse.emf.ecore.util.EObjectEList;
32 import org.eclipse.emf.ecore.util.InternalEList;
33
34 import org.eclipse.xsd.XSDAnnotation;
35 import org.eclipse.xsd.XSDConcreteComponent;
36 import org.eclipse.xsd.XSDFactory;
37 import org.eclipse.xsd.XSDNamespaceConstraintCategory;
38 import org.eclipse.xsd.XSDPackage;
39 import org.eclipse.xsd.XSDParticle;
40 import org.eclipse.xsd.XSDProcessContents;
41 import org.eclipse.xsd.XSDSchema;
42 import org.eclipse.xsd.XSDWildcard;
43 import org.eclipse.xsd.util.XSDConstants;
44
45
46 /**
47 * <!-- begin-user-doc -->
48 * An implementation of the model object '<em><b>Wildcard</b></em>'.
49 * <!-- end-user-doc -->
50 * <p>
51 * The following features are implemented:
52 * </p>
53 * <ul>
54 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getNamespaceConstraintCategory <em>Namespace Constraint Category</em>}</li>
55 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getNamespaceConstraint <em>Namespace Constraint</em>}</li>
56 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getProcessContents <em>Process Contents</em>}</li>
57 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getLexicalNamespaceConstraint <em>Lexical Namespace Constraint</em>}</li>
58 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getAnnotation <em>Annotation</em>}</li>
59 * <li>{@link org.eclipse.xsd.impl.XSDWildcardImpl#getAnnotations <em>Annotations</em>}</li>
60 * </ul>
61 *
62 * @generated
63 */
64 public class XSDWildcardImpl
65 extends XSDTermImpl
66 implements XSDWildcard
67 {
68 /**
69 * The default value of the '{@link #getNamespaceConstraintCategory() <em>Namespace Constraint Category</em>}' attribute.
70 * <!-- begin-user-doc -->
71 * <!-- end-user-doc -->
72 * @see #getNamespaceConstraintCategory()
73 * @generated
74 * @ordered
75 */
76 protected static final XSDNamespaceConstraintCategory NAMESPACE_CONSTRAINT_CATEGORY_EDEFAULT = XSDNamespaceConstraintCategory.ANY_LITERAL;
77
78 /**
79 * The offset of the flags representing the value of the '{@link #getNamespaceConstraintCategory() <em>Namespace Constraint Category</em>}' attribute.
80 * <!-- begin-user-doc -->
81 * <!-- end-user-doc -->
82 * @generated
83 * @ordered
84 */
85 protected static final int NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET = 8;
86
87 /**
88 * The flags representing the default value of the '{@link #getNamespaceConstraintCategory() <em>Namespace Constraint Category</em>}' attribute.
89 * <!-- begin-user-doc -->
90 * <!-- end-user-doc -->
91 * @generated
92 * @ordered
93 */
94 protected static final int NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_DEFAULT = NAMESPACE_CONSTRAINT_CATEGORY_EDEFAULT.ordinal() << NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET;
95
96 /**
97 * The array of enumeration values for '{@link XSDNamespaceConstraintCategory Namespace Constraint Category}'
98 * <!-- begin-user-doc -->
99 * <!-- end-user-doc -->
100 * @generated
101 * @ordered
102 */
103 private static final XSDNamespaceConstraintCategory[] NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_VALUES = XSDNamespaceConstraintCategory.values();
104
105 /**
106 * The flags representing the value of the '{@link #getNamespaceConstraintCategory() <em>Namespace Constraint Category</em>}' attribute.
107 * <!-- begin-user-doc -->
108 * <!-- end-user-doc -->
109 * @see #getNamespaceConstraintCategory()
110 * @generated
111 * @ordered
112 */
113 protected static final int NAMESPACE_CONSTRAINT_CATEGORY_EFLAG = 0x3 << NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET;
114
115 /**
116 * The cached value of the '{@link #getNamespaceConstraint() <em>Namespace Constraint</em>}' attribute list.
117 * <!-- begin-user-doc -->
118 * <!-- end-user-doc -->
119 * @see #getNamespaceConstraint()
120 * @generated
121 * @ordered
122 */
123 protected EList<String> namespaceConstraint;
124
125 /**
126 * The default value of the '{@link #getProcessContents() <em>Process Contents</em>}' attribute.
127 * <!-- begin-user-doc -->
128 * <!-- end-user-doc -->
129 * @see #getProcessContents()
130 * @generated
131 * @ordered
132 */
133 protected static final XSDProcessContents PROCESS_CONTENTS_EDEFAULT = XSDProcessContents.STRICT_LITERAL;
134
135 /**
136 * The offset of the flags representing the value of the '{@link #getProcessContents() <em>Process Contents</em>}' attribute.
137 * <!-- begin-user-doc -->
138 * <!-- end-user-doc -->
139 * @generated
140 * @ordered
141 */
142 protected static final int PROCESS_CONTENTS_EFLAG_OFFSET = 10;
143
144 /**
145 * The flags representing the default value of the '{@link #getProcessContents() <em>Process Contents</em>}' attribute.
146 * <!-- begin-user-doc -->
147 * <!-- end-user-doc -->
148 * @generated
149 * @ordered
150 */
151 protected static final int PROCESS_CONTENTS_EFLAG_DEFAULT = PROCESS_CONTENTS_EDEFAULT.ordinal() << PROCESS_CONTENTS_EFLAG_OFFSET;
152
153 /**
154 * The array of enumeration values for '{@link XSDProcessContents Process Contents}'
155 * <!-- begin-user-doc -->
156 * <!-- end-user-doc -->
157 * @generated
158 * @ordered
159 */
160 private static final XSDProcessContents[] PROCESS_CONTENTS_EFLAG_VALUES = XSDProcessContents.values();
161
162 /**
163 * The flags representing the value of the '{@link #getProcessContents() <em>Process Contents</em>}' attribute.
164 * <!-- begin-user-doc -->
165 * <!-- end-user-doc -->
166 * @see #getProcessContents()
167 * @generated
168 * @ordered
169 */
170 protected static final int PROCESS_CONTENTS_EFLAG = 0x3 << PROCESS_CONTENTS_EFLAG_OFFSET;
171
172 /**
173 * The flag representing whether the Process Contents attribute has been set.
174 * <!-- begin-user-doc -->
175 * <!-- end-user-doc -->
176 * @generated
177 * @ordered
178 */
179 protected static final int PROCESS_CONTENTS_ESETFLAG = 1 << 12;
180
181 /**
182 * The cached value of the '{@link #getLexicalNamespaceConstraint() <em>Lexical Namespace Constraint</em>}' attribute list.
183 * <!-- begin-user-doc -->
184 * <!-- end-user-doc -->
185 * @see #getLexicalNamespaceConstraint()
186 * @generated
187 * @ordered
188 */
189 protected EList<String> lexicalNamespaceConstraint;
190
191 /**
192 * The cached value of the '{@link #getAnnotation() <em>Annotation</em>}' containment reference.
193 * <!-- begin-user-doc -->
194 * <!-- end-user-doc -->
195 * @see #getAnnotation()
196 * @generated
197 * @ordered
198 */
199 protected XSDAnnotation annotation;
200
201 /**
202 * The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' reference list.
203 * <!-- begin-user-doc -->
204 * <!-- end-user-doc -->
205 * @see #getAnnotations()
206 * @generated
207 * @ordered
208 */
209 protected EList<XSDAnnotation> annotations;
210
211 public static XSDWildcard createWildcard(Node node)
212 {
213 switch (XSDConstants.nodeType(node))
214 {
215 case XSDConstants.ANY_ELEMENT:
216 case XSDConstants.ANYATTRIBUTE_ELEMENT:
217 {
218 XSDWildcard xsdWildcard = XSDFactory.eINSTANCE.createXSDWildcard();
219 xsdWildcard.setElement((Element)node);
220 return xsdWildcard;
221 }
222 }
223
224 return null;
225 }
226
227 /**
228 * <!-- begin-user-doc -->
229 * <!-- end-user-doc -->
230 * @generated
231 */
232 protected XSDWildcardImpl()
233 {
234 super();
235 }
236
237 /**
238 * <!-- begin-user-doc -->
239 * <!-- end-user-doc -->
240 * @generated
241 */
242 @Override
243 protected EClass eStaticClass()
244 {
245 return XSDPackage.Literals.XSD_WILDCARD;
246 }
247
248 /**
249 * <!-- begin-user-doc -->
250 * <!-- end-user-doc -->
251 * @generated
252 */
253 @Override
254 public XSDNamespaceConstraintCategory getNamespaceConstraintCategory()
255 {
256 return NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & NAMESPACE_CONSTRAINT_CATEGORY_EFLAG) >>> NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET];
257 }
258
259 /**
260 * <!-- begin-user-doc -->
261 * <!-- end-user-doc -->
262 * @generated
263 */
264 @Override
265 public void setNamespaceConstraintCategory(XSDNamespaceConstraintCategory newNamespaceConstraintCategory)
266 {
267 XSDNamespaceConstraintCategory oldNamespaceConstraintCategory = NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & NAMESPACE_CONSTRAINT_CATEGORY_EFLAG) >>> NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET];
268 if (newNamespaceConstraintCategory == null) newNamespaceConstraintCategory = NAMESPACE_CONSTRAINT_CATEGORY_EDEFAULT;
269 eFlags = eFlags & ~NAMESPACE_CONSTRAINT_CATEGORY_EFLAG | newNamespaceConstraintCategory.ordinal() << NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET;
270 if (eNotificationRequired())
271 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT_CATEGORY, oldNamespaceConstraintCategory, newNamespaceConstraintCategory));
272 }
273
274 /**
275 * <!-- begin-user-doc -->
276 * <!-- end-user-doc -->
277 * @generated
278 */
279 @Override
280 public EList<String> getNamespaceConstraint()
281 {
282 if (namespaceConstraint == null)
283 {
284 namespaceConstraint = new EDataTypeUniqueEList<String>(String.class, this, XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT);
285 }
286 return namespaceConstraint;
287 }
288
289 /**
290 * <!-- begin-user-doc -->
291 * <!-- end-user-doc -->
292 * @generated
293 */
294 @Override
295 public XSDProcessContents getProcessContents()
296 {
297 return PROCESS_CONTENTS_EFLAG_VALUES[(eFlags & PROCESS_CONTENTS_EFLAG) >>> PROCESS_CONTENTS_EFLAG_OFFSET];
298 }
299
300 /**
301 * <!-- begin-user-doc -->
302 * <!-- end-user-doc -->
303 * @generated
304 */
305 @Override
306 public void setProcessContents(XSDProcessContents newProcessContents)
307 {
308 XSDProcessContents oldProcessContents = PROCESS_CONTENTS_EFLAG_VALUES[(eFlags & PROCESS_CONTENTS_EFLAG) >>> PROCESS_CONTENTS_EFLAG_OFFSET];
309 if (newProcessContents == null) newProcessContents = PROCESS_CONTENTS_EDEFAULT;
310 eFlags = eFlags & ~PROCESS_CONTENTS_EFLAG | newProcessContents.ordinal() << PROCESS_CONTENTS_EFLAG_OFFSET;
311 boolean oldProcessContentsESet = (eFlags & PROCESS_CONTENTS_ESETFLAG) != 0;
312 eFlags |= PROCESS_CONTENTS_ESETFLAG;
313 if (eNotificationRequired())
314 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS, oldProcessContents, newProcessContents, !oldProcessContentsESet));
315 }
316
317 /**
318 * <!-- begin-user-doc -->
319 * <!-- end-user-doc -->
320 * @generated
321 */
322 @Override
323 public void unsetProcessContents()
324 {
325 XSDProcessContents oldProcessContents = PROCESS_CONTENTS_EFLAG_VALUES[(eFlags & PROCESS_CONTENTS_EFLAG) >>> PROCESS_CONTENTS_EFLAG_OFFSET];
326 boolean oldProcessContentsESet = (eFlags & PROCESS_CONTENTS_ESETFLAG) != 0;
327 eFlags = eFlags & ~PROCESS_CONTENTS_EFLAG | PROCESS_CONTENTS_EFLAG_DEFAULT;
328 eFlags &= ~PROCESS_CONTENTS_ESETFLAG;
329 if (eNotificationRequired())
330 eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS, oldProcessContents, PROCESS_CONTENTS_EDEFAULT, oldProcessContentsESet));
331 }
332
333 /**
334 * <!-- begin-user-doc -->
335 * <!-- end-user-doc -->
336 * @generated
337 */
338 @Override
339 public boolean isSetProcessContents()
340 {
341 return (eFlags & PROCESS_CONTENTS_ESETFLAG) != 0;
342 }
343
344 /**
345 * <!-- begin-user-doc -->
346 * <!-- end-user-doc -->
347 * @generated
348 */
349 @Override
350 public EList<String> getLexicalNamespaceConstraint()
351 {
352 if (lexicalNamespaceConstraint == null)
353 {
354 lexicalNamespaceConstraint = new EDataTypeUniqueEList.Unsettable<String>(String.class, this, XSDPackage.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT);
355 }
356 return lexicalNamespaceConstraint;
357 }
358
359 /**
360 * <!-- begin-user-doc -->
361 * <!-- end-user-doc -->
362 * @generated
363 */
364 @Override
365 public void unsetLexicalNamespaceConstraint()
366 {
367 if (lexicalNamespaceConstraint != null) ((InternalEList.Unsettable<?>)lexicalNamespaceConstraint).unset();
368 }
369
370 /**
371 * <!-- begin-user-doc -->
372 * <!-- end-user-doc -->
373 * @generated
374 */
375 @Override
376 public boolean isSetLexicalNamespaceConstraint()
377 {
378 return lexicalNamespaceConstraint != null && ((InternalEList.Unsettable<?>)lexicalNamespaceConstraint).isSet();
379 }
380
381 /**
382 * <!-- begin-user-doc -->
383 * <!-- end-user-doc -->
384 * @generated
385 */
386 @Override
387 public XSDAnnotation getAnnotation()
388 {
389 return annotation;
390 }
391
392 /**
393 * <!-- begin-user-doc -->
394 * <!-- end-user-doc -->
395 * @generated
396 */
397 @Override
398 public void setAnnotation(XSDAnnotation newAnnotation)
399 {
400 if (newAnnotation != annotation)
401 {
402 NotificationChain msgs = null;
403 if (annotation != null)
404 msgs = ((InternalEObject)annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_WILDCARD__ANNOTATION, null, msgs);
405 if (newAnnotation != null)
406 msgs = ((InternalEObject)newAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_WILDCARD__ANNOTATION, null, msgs);
407 msgs = basicSetAnnotation(newAnnotation, msgs);
408 if (msgs != null) msgs.dispatch();
409 }
410 else if (eNotificationRequired())
411 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_WILDCARD__ANNOTATION, newAnnotation, newAnnotation));
412 }
413
414 /**
415 * <!-- begin-user-doc -->
416 * <!-- end-user-doc -->
417 * @generated
418 */
419 public NotificationChain basicSetAnnotation(XSDAnnotation newAnnotation, NotificationChain msgs)
420 {
421 XSDAnnotation oldAnnotation = annotation;
422 annotation = newAnnotation;
423 if (eNotificationRequired())
424 {
425 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_WILDCARD__ANNOTATION, oldAnnotation, newAnnotation);
426 if (msgs == null) msgs = notification; else msgs.add(notification);
427 }
428 return msgs;
429 }
430
431 /**
432 * <!-- begin-user-doc -->
433 * <!-- end-user-doc -->
434 * @generated
435 */
436 @Override
437 public EList<XSDAnnotation> getAnnotations()
438 {
439 if (annotations == null)
440 {
441 annotations = new EObjectEList<XSDAnnotation>(XSDAnnotation.class, this, XSDPackage.XSD_WILDCARD__ANNOTATIONS);
442 }
443 return annotations;
444 }
445
446 /**
447 * <!-- begin-user-doc -->
448 * <!-- end-user-doc -->
449 * @generated
450 */
451 @Override
452 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
453 {
454 switch (featureID)
455 {
456 case XSDPackage.XSD_WILDCARD__ANNOTATION:
457 return basicSetAnnotation(null, msgs);
458 }
459 return super.eInverseRemove(otherEnd, featureID, msgs);
460 }
461
462 /**
463 * <!-- begin-user-doc -->
464 * <!-- end-user-doc -->
465 * @generated
466 */
467 @Override
468 public Object eGet(int featureID, boolean resolve, boolean coreType)
469 {
470 switch (featureID)
471 {
472 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT_CATEGORY:
473 return getNamespaceConstraintCategory();
474 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT:
475 return getNamespaceConstraint();
476 case XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS:
477 return getProcessContents();
478 case XSDPackage.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT:
479 return getLexicalNamespaceConstraint();
480 case XSDPackage.XSD_WILDCARD__ANNOTATION:
481 return getAnnotation();
482 case XSDPackage.XSD_WILDCARD__ANNOTATIONS:
483 return getAnnotations();
484 }
485 return super.eGet(featureID, resolve, coreType);
486 }
487
488 /**
489 * <!-- begin-user-doc -->
490 * <!-- end-user-doc -->
491 * @generated
492 */
493 @SuppressWarnings("unchecked")
494 @Override
495 public void eSet(int featureID, Object newValue)
496 {
497 switch (featureID)
498 {
499 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT_CATEGORY:
500 setNamespaceConstraintCategory((XSDNamespaceConstraintCategory)newValue);
501 return;
502 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT:
503 getNamespaceConstraint().clear();
504 getNamespaceConstraint().addAll((Collection<? extends String>)newValue);
505 return;
506 case XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS:
507 setProcessContents((XSDProcessContents)newValue);
508 return;
509 case XSDPackage.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT:
510 getLexicalNamespaceConstraint().clear();
511 getLexicalNamespaceConstraint().addAll((Collection<? extends String>)newValue);
512 return;
513 case XSDPackage.XSD_WILDCARD__ANNOTATION:
514 setAnnotation((XSDAnnotation)newValue);
515 return;
516 case XSDPackage.XSD_WILDCARD__ANNOTATIONS:
517 getAnnotations().clear();
518 getAnnotations().addAll((Collection<? extends XSDAnnotation>)newValue);
519 return;
520 }
521 super.eSet(featureID, newValue);
522 }
523
524 /**
525 * <!-- begin-user-doc -->
526 * <!-- end-user-doc -->
527 * @generated
528 */
529 @Override
530 public void eUnset(int featureID)
531 {
532 switch (featureID)
533 {
534 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT_CATEGORY:
535 setNamespaceConstraintCategory(NAMESPACE_CONSTRAINT_CATEGORY_EDEFAULT);
536 return;
537 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT:
538 getNamespaceConstraint().clear();
539 return;
540 case XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS:
541 unsetProcessContents();
542 return;
543 case XSDPackage.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT:
544 unsetLexicalNamespaceConstraint();
545 return;
546 case XSDPackage.XSD_WILDCARD__ANNOTATION:
547 setAnnotation((XSDAnnotation)null);
548 return;
549 case XSDPackage.XSD_WILDCARD__ANNOTATIONS:
550 getAnnotations().clear();
551 return;
552 }
553 super.eUnset(featureID);
554 }
555
556 /**
557 * <!-- begin-user-doc -->
558 * <!-- end-user-doc -->
559 * @generated
560 */
561 @Override
562 public boolean eIsSet(int featureID)
563 {
564 switch (featureID)
565 {
566 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT_CATEGORY:
567 return (eFlags & NAMESPACE_CONSTRAINT_CATEGORY_EFLAG) != NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_DEFAULT;
568 case XSDPackage.XSD_WILDCARD__NAMESPACE_CONSTRAINT:
569 return namespaceConstraint != null && !namespaceConstraint.isEmpty();
570 case XSDPackage.XSD_WILDCARD__PROCESS_CONTENTS:
571 return isSetProcessContents();
572 case XSDPackage.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT:
573 return isSetLexicalNamespaceConstraint();
574 case XSDPackage.XSD_WILDCARD__ANNOTATION:
575 return annotation != null;
576 case XSDPackage.XSD_WILDCARD__ANNOTATIONS:
577 return annotations != null && !annotations.isEmpty();
578 }
579 return super.eIsSet(featureID);
580 }
581
582 /**
583 * <!-- begin-user-doc -->
584 * <!-- end-user-doc -->
585 * @generated
586 */
587 @Override
588 public String toString()
589 {
590 if (eIsProxy()) return super.toString();
591
592 StringBuilder result = new StringBuilder(super.toString());
593 result.append(" (namespaceConstraintCategory: ");
594 result.append(NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_VALUES[(eFlags & NAMESPACE_CONSTRAINT_CATEGORY_EFLAG) >>> NAMESPACE_CONSTRAINT_CATEGORY_EFLAG_OFFSET]);
595 result.append(", namespaceConstraint: ");
596 result.append(namespaceConstraint);
597 result.append(", processContents: ");
598 if ((eFlags & PROCESS_CONTENTS_ESETFLAG) != 0) result.append(PROCESS_CONTENTS_EFLAG_VALUES[(eFlags & PROCESS_CONTENTS_EFLAG) >>> PROCESS_CONTENTS_EFLAG_OFFSET]); else result.append("<unset>");
599 result.append(", lexicalNamespaceConstraint: ");
600 result.append(lexicalNamespaceConstraint);
601 result.append(')');
602 return result.toString();
603 }
604
605 @Override
606 public Element createElement()
607 {
608 Element newElement =
609 createElement(getContainer() instanceof XSDParticle ? XSDConstants.ANY_ELEMENT : XSDConstants.ANYATTRIBUTE_ELEMENT);
610 setElement(newElement);
611 return newElement;
612 }
613
614 @Override
615 public void patch()
616 {
617 super.patch();
618 for (String string : getLexicalNamespaceConstraint())
619 {
620 if (!string.startsWith("##"))
621 {
622 ((XSDSchemaImpl)getSchema()).resolveSchema(string);
623 }
624 }
625 }
626
627 @Override
628 protected boolean analyze()
629 {
630 super.analyze();
631
632 XSDSchema xsdSchema = getSchema();
633 XSDNamespaceConstraintCategory newNamespaceConstraintCategory = XSDNamespaceConstraintCategory.ANY_LITERAL;
634 List<String> newNamespaceConstraint = new ArrayList<String>();
635
636 for (String string : getLexicalNamespaceConstraint())
637 {
638 if (string.equals("##any"))
639 {
640 break;
641 }
642 else if (string.equals("##other"))
643 {
644 newNamespaceConstraintCategory = XSDNamespaceConstraintCategory.NOT_LITERAL;
645 String targetNamespace = xsdSchema.getTargetNamespace();
646 newNamespaceConstraint.add(targetNamespace);
647 break;
648 }
649 else if (string.equals("##targetNamespace"))
650 {
651 newNamespaceConstraintCategory = XSDNamespaceConstraintCategory.SET_LITERAL;
652 String targetNamespace = xsdSchema.getTargetNamespace();
653 newNamespaceConstraint.add(targetNamespace);
654 }
655 else if (string.equals("##local"))
656 {
657 newNamespaceConstraintCategory = XSDNamespaceConstraintCategory.SET_LITERAL;
658 newNamespaceConstraint.add(null);
659 }
660 else
661 {
662 newNamespaceConstraintCategory = XSDNamespaceConstraintCategory.SET_LITERAL;
663 newNamespaceConstraint.add(string);
664 }
665 }
666
667 if (getNamespaceConstraintCategory() != newNamespaceConstraintCategory)
668 {
669 setNamespaceConstraintCategory(newNamespaceConstraintCategory);
670 }
671
672 EList<String> theNamespaceConstraint = getNamespaceConstraint();
673 List<String> remainingNamespaceConstraint = new ArrayList<String>(theNamespaceConstraint);
674 remainingNamespaceConstraint.removeAll(newNamespaceConstraint);
675 if (!remainingNamespaceConstraint.isEmpty())
676 {
677 theNamespaceConstraint.removeAll(remainingNamespaceConstraint);
678 }
679 if (!newNamespaceConstraint.isEmpty())
680 {
681 setListContentAndOrder(theNamespaceConstraint, newNamespaceConstraint);
682 }
683
684 return true;
685 }
686
687 @Override
688 public void validate()
689 {
690 super.validate();
691
692 String anchor = null;
693 String contentType = null;
694
695 Element theElement = getElement();
696 if (theElement != null)
697 {
698 String [] attributes = null;
699 if (getContainer() instanceof XSDParticle)
700 {
701 anchor = "element-any";
702 contentType = "wildcard";
703 attributes =
704 new String []
705 {
706 XSDConstants.ID_ATTRIBUTE,
707 XSDConstants.MAXOCCURS_ATTRIBUTE,
708 XSDConstants.MINOCCURS_ATTRIBUTE,
709 XSDConstants.NAMESPACE_ATTRIBUTE,
710 XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
711 };
712
713 checkAttributeTypeConstraint
714 (contentType,
715 "maxOccurs",
716 null,
717 XSDConstants.PART1,
718 anchor,
719 theElement,
720 XSDConstants.MAXOCCURS_ATTRIBUTE,
721 false);
722
723 checkAttributeTypeConstraint
724 (contentType,
725 "minOccurs",
726 null,
727 XSDConstants.PART1,
728 anchor,
729 theElement,
730 XSDConstants.MINOCCURS_ATTRIBUTE,
731 false);
732 }
733 else
734 {
735 anchor = "element-anyAttribute";
736 contentType = "wildcard";
737 attributes =
738 new String []
739 {
740 XSDConstants.ID_ATTRIBUTE,
741 XSDConstants.NAMESPACE_ATTRIBUTE,
742 XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
743 };
744 }
745
746 checkAttributes(XSDConstants.PART1, anchor, theElement, attributes);
747 checkComplexContent(contentType, XSDConstants.PART1, anchor, theElement);
748
749 checkBuiltInTypeConstraint
750 ("ID",
751 null,
752 XSDConstants.PART1,
753 anchor,
754 theElement,
755 XSDConstants.ID_ATTRIBUTE,
756 false);
757
758 checkAttributeTypeConstraint
759 (contentType,
760 "namespace",
761 null,
762 XSDConstants.PART1,
763 anchor,
764 theElement,
765 XSDConstants.NAMESPACE_ATTRIBUTE,
766 false);
767
768 checkAttributeTypeConstraint
769 (contentType,
770 "processContents",
771 null,
772 XSDConstants.PART1,
773 anchor,
774 theElement,
775 XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
776 false);
777 }
778 }
779
780 @Override
781 protected boolean isUpdatingDOM()
782 {
783 // EATM I think this is needed.
784 return
785 super.isUpdatingDOM() ||
786 getContainer() instanceof XSDParticle &&
787 ((XSDConcreteComponentImpl)getContainer()).isUpdatingDOM();
788 }
789
790 @Override
791 protected void reconcileAttributes(Element changedElement)
792 {
793 super.reconcileAttributes(changedElement);
794
795 if (changedElement == getElement())
796 {
797 if (changedElement.hasAttributeNS(null, XSDConstants.PROCESSCONTENTS_ATTRIBUTE))
798 {
799 XSDProcessContents newProcessContents =
800 XSDProcessContents.get(changedElement.getAttributeNS(null, XSDConstants.PROCESSCONTENTS_ATTRIBUTE));
801 if (!isSetProcessContents() || newProcessContents != getProcessContents())
802 {
803 setProcessContents(newProcessContents);
804 }
805 }
806 else if (isSetProcessContents())
807 {
808 unsetProcessContents();
809 }
810
811 if (changedElement.hasAttributeNS(null, XSDConstants.NAMESPACE_ATTRIBUTE))
812 {
813 String newLexicalNamespaceConstraint = changedElement.getAttributeNS(null, XSDConstants.NAMESPACE_ATTRIBUTE);
814 if (!newLexicalNamespaceConstraint.equals(getStringLexicalNamespaceConstraint()))
815 {
816 setStringLexicalNamespaceConstraint(newLexicalNamespaceConstraint);
817 }
818 }
819 else if (isSetLexicalNamespaceConstraint())
820 {
821 unsetLexicalNamespaceConstraint();
822 }
823 }
824 }
825
826 @Override
827 protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
828 {
829 if (XSDConstants.nodeType(child) == XSDConstants.ANNOTATION_ELEMENT)
830 {
831 XSDAnnotation xsdAnnotation = XSDAnnotationImpl.createAnnotation(child);
832 newContents.add(xsdAnnotation);
833 }
834 }
835
836 @Override
837 protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
838 {
839 handleAnnotationReconciliation(XSDPackage.Literals.XSD_WILDCARD__ANNOTATION, newContents, remainingContents);
840 }
841
842 @Override
843 protected void changeAttribute(EAttribute eAttribute)
844 {
845 if (isReconciling)
846 {
847 return;
848 }
849
850 super.changeAttribute(eAttribute);
851 Element theElement = getElement();
852 if (theElement != null)
853 {
854 if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_WILDCARD__LEXICAL_NAMESPACE_CONSTRAINT)
855 {
856 if (!isSetLexicalNamespaceConstraint())
857 {
858 niceSetAttribute(theElement, XSDConstants.NAMESPACE_ATTRIBUTE, null);
859 }
860 else
861 {
862 List<String> theLexicalNamespaceConstraint = getLexicalNamespaceConstraint();
863 StringBuffer result = new StringBuffer();
864 for (String value : theLexicalNamespaceConstraint)
865 {
866 if (result.length() != 0)
867 {
868 result.append(' ');
869 }
870 result.append(value);
871 }
872
873 niceSetAttribute(theElement, XSDConstants.NAMESPACE_ATTRIBUTE, result.toString());
874 }
875 if (eAttribute != null)
876 {
877 traverseToRootForPatching();
878 }
879 }
880 if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_WILDCARD__PROCESS_CONTENTS)
881 {
882 XSDProcessContents theProcessContents = getProcessContents();
883 niceSetAttribute
884 (theElement, XSDConstants.PROCESSCONTENTS_ATTRIBUTE, isSetProcessContents() ? theProcessContents.getName() : null);
885 }
886 }
887 }
888
889 @Override
890 protected void adoptContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
891 {
892 super.adoptContent(eReference, xsdConcreteComponent);
893 if (eReference == XSDPackage.Literals.XSD_WILDCARD__ANNOTATION)
894 {
895 getAnnotations().add((XSDAnnotation)xsdConcreteComponent);
896 }
897 }
898
899 @Override
900 protected void orphanContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
901 {
902 super.orphanContent(eReference, xsdConcreteComponent);
903 if (eReference == XSDPackage.Literals.XSD_WILDCARD__ANNOTATION)
904 {
905 int index = getAnnotations().indexOf(xsdConcreteComponent);
906 if (index >= 0)
907 {
908 getAnnotations().remove(index);
909 }
910 }
911 }
912
913 public String getStringNamespaceConstraint()
914 {
915 StringBuffer result = new StringBuffer();
916 for (String value : getNamespaceConstraint())
917 {
918 if (result.length() != 0)
919 {
920 result.append(' ');
921 }
922 if (value == null || value.length() == 0)
923 {
924 result.append("'absent'");
925 }
926 else
927 {
928 result.append(value);
929 }
930 }
931
932 return result.toString();
933 }
934
935 public String getStringLexicalNamespaceConstraint()
936 {
937 if (isSetLexicalNamespaceConstraint())
938 {
939 StringBuffer result = new StringBuffer();
940 for (String value : getLexicalNamespaceConstraint())
941 {
942 if (result.length() != 0)
943 {
944 result.append(' ');
945 }
946 result.append(value);
947 }
948
949 return result.toString();
950 }
951 else
952 {
953 return null;
954 }
955 }
956
957 public void setStringLexicalNamespaceConstraint(String lexicalNamespaceConstraint)
958 {
959 if (lexicalNamespaceConstraint == null)
960 {
961 unsetLexicalNamespaceConstraint();
962 }
963 else
964 {
965 List<String> newLexicalNamespaceConstraint = new ArrayList<String>();
966 for (StringTokenizer stringTokenizer = new StringTokenizer(lexicalNamespaceConstraint); stringTokenizer.hasMoreTokens(); )
967 {
968 String token = stringTokenizer.nextToken();
969 newLexicalNamespaceConstraint.add(token);
970 }
971 if (!newLexicalNamespaceConstraint.equals(getLexicalNamespaceConstraint()))
972 {
973 Collection<String> oldContents = new ArrayList<String>(getLexicalNamespaceConstraint());
974 oldContents.removeAll(newLexicalNamespaceConstraint);
975 if (!oldContents.isEmpty())
976 {
977 getLexicalNamespaceConstraint().removeAll(oldContents);
978 }
979 setListContentAndOrder(getLexicalNamespaceConstraint(), newLexicalNamespaceConstraint);
980 }
981 else if (newLexicalNamespaceConstraint.isEmpty() && !isSetLexicalNamespaceConstraint())
982 {
983 getLexicalNamespaceConstraint().clear();
984 }
985 }
986 }
987
988 public boolean isWildcardSubset(XSDWildcard superSetWildcard)
989
990 {
991 // Clause 1
992 //
993 if (XSDNamespaceConstraintCategory.ANY_LITERAL == superSetWildcard.getNamespaceConstraintCategory())
994 {
995 return true;
996 }
997 // Clause 2
998 //
999 else if (XSDNamespaceConstraintCategory.NOT_LITERAL == getNamespaceConstraintCategory() &&
1000 XSDNamespaceConstraintCategory.NOT_LITERAL == superSetWildcard.getNamespaceConstraintCategory() &&
1001 getNamespaceConstraint().equals(superSetWildcard.getNamespaceConstraint()))
1002 {
1003 return true;
1004 }
1005 // Clauses 3.1 and 3.2
1006 //
1007 else if (XSDNamespaceConstraintCategory.SET_LITERAL == getNamespaceConstraintCategory() &&
1008 (XSDNamespaceConstraintCategory.SET_LITERAL == superSetWildcard.getNamespaceConstraintCategory() &&
1009 superSetWildcard.getNamespaceConstraint().containsAll(getNamespaceConstraint()) ||
1010 XSDNamespaceConstraintCategory.NOT_LITERAL == superSetWildcard.getNamespaceConstraintCategory() &&
1011 !getNamespaceConstraint().containsAll(superSetWildcard.getNamespaceConstraint())))
1012 {
1013 return true;
1014 }
1015 // Failure
1016 //
1017 else
1018 {
1019 return false;
1020 }
1021 }
1022
1023 public XSDWildcard attributeWildcardUnion(XSDWildcard otherWildcard)
1024 {
1025 // Clause 1
1026 //
1027 if (getNamespaceConstraintCategory() == otherWildcard.getNamespaceConstraintCategory() &&
1028 getNamespaceConstraint().containsAll(otherWildcard.getNamespaceConstraint()) &&
1029 otherWildcard.getNamespaceConstraint().containsAll(getNamespaceConstraint()))
1030 {
1031 return this;
1032 }
1033 // Clause 2
1034 //
1035 else if (XSDNamespaceConstraintCategory.ANY_LITERAL == getNamespaceConstraintCategory())
1036 {
1037 return this;
1038 }
1039 // Clause 2
1040 //
1041 else if (XSDNamespaceConstraintCategory.ANY_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1042 {
1043 return otherWildcard;
1044 }
1045 // Clause 3.
1046 //
1047 else if (XSDNamespaceConstraintCategory.SET_LITERAL == getNamespaceConstraintCategory() &&
1048 XSDNamespaceConstraintCategory.SET_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1049 {
1050 XSDWildcard result = getXSDFactory().createXSDWildcard();
1051 if (isSetProcessContents())
1052 {
1053 result.setProcessContents(getProcessContents());
1054 }
1055 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.SET_LITERAL);
1056 List<String> newNamespaceConstraint = new ArrayList<String>(getNamespaceConstraint());
1057 for (String value : otherWildcard.getNamespaceConstraint())
1058 {
1059 if (!newNamespaceConstraint.contains(value))
1060 {
1061 newNamespaceConstraint.add(value);
1062 }
1063 }
1064 result.getNamespaceConstraint().addAll(newNamespaceConstraint);
1065 return result;
1066 }
1067 // Clause 4
1068 //
1069 else if (XSDNamespaceConstraintCategory.NOT_LITERAL == getNamespaceConstraintCategory() &&
1070 XSDNamespaceConstraintCategory.NOT_LITERAL == otherWildcard.getNamespaceConstraintCategory() &&
1071 !getNamespaceConstraint().equals(otherWildcard.getNamespaceConstraint()))
1072 {
1073 return null;
1074 }
1075 // Clause 5
1076 //
1077 else if (XSDNamespaceConstraintCategory.SET_LITERAL == getNamespaceConstraintCategory() &&
1078 XSDNamespaceConstraintCategory.NOT_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1079
1080 {
1081 // Clause 5.2
1082 //
1083 if (getNamespaceConstraint().containsAll(otherWildcard.getNamespaceConstraint()))
1084 {
1085 XSDWildcard result = getXSDFactory().createXSDWildcard();
1086 if (isSetProcessContents())
1087 {
1088 result.setProcessContents(getProcessContents());
1089 }
1090 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.ANY_LITERAL);
1091 return result;
1092 }
1093 // Clause 5.1
1094 //
1095 else
1096 {
1097 return otherWildcard;
1098 }
1099 }
1100 // Clause 5
1101 //
1102 else if (XSDNamespaceConstraintCategory.SET_LITERAL == otherWildcard.getNamespaceConstraintCategory() &&
1103 XSDNamespaceConstraintCategory.NOT_LITERAL == getNamespaceConstraintCategory())
1104 {
1105 // Clause 5.2
1106 //
1107 if (otherWildcard.getNamespaceConstraint().containsAll(getNamespaceConstraint()))
1108 {
1109 XSDWildcard result = getXSDFactory().createXSDWildcard();
1110 if (isSetProcessContents())
1111 {
1112 result.setProcessContents(getProcessContents());
1113 }
1114 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.ANY_LITERAL);
1115 return result;
1116 }
1117 // Clause 5.1
1118 //
1119 else
1120 {
1121 return this;
1122 }
1123 }
1124 // Failure
1125 //
1126 else
1127 {
1128 // EATM return a bad placeholder.
1129 XSDWildcard result = getXSDFactory().createXSDWildcard();
1130 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.NOT_LITERAL);
1131 return result;
1132 // return null;
1133 }
1134 }
1135
1136 public XSDWildcard attributeWildcardIntersection(XSDWildcard otherWildcard)
1137 {
1138 // Clause 1
1139 //
1140 if (getNamespaceConstraintCategory() == otherWildcard.getNamespaceConstraintCategory() &&
1141 getNamespaceConstraint().containsAll(otherWildcard.getNamespaceConstraint()) &&
1142 otherWildcard.getNamespaceConstraint().containsAll(getNamespaceConstraint()))
1143 {
1144 return this;
1145 }
1146 // Clause 2
1147 //
1148 else if (XSDNamespaceConstraintCategory.ANY_LITERAL == getNamespaceConstraintCategory())
1149 {
1150 return otherWildcard;
1151 }
1152 // Clause 2
1153 //
1154 else if (XSDNamespaceConstraintCategory.ANY_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1155 {
1156 return this;
1157 }
1158 // Clause 3
1159 //
1160 else if (XSDNamespaceConstraintCategory.SET_LITERAL == getNamespaceConstraintCategory() &&
1161 XSDNamespaceConstraintCategory.NOT_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1162
1163 {
1164 // Clause 3 minus
1165 //
1166 if (getNamespaceConstraint().containsAll(otherWildcard.getNamespaceConstraint()) || getNamespaceConstraint().contains(null))
1167 {
1168 XSDWildcard result = getXSDFactory().createXSDWildcard();
1169 if (isSetProcessContents())
1170 {
1171 result.setProcessContents(getProcessContents());
1172 }
1173 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.SET_LITERAL);
1174 List<String> newNamespaceConstraint = new ArrayList<String>(getNamespaceConstraint());
1175 newNamespaceConstraint.removeAll(otherWildcard.getNamespaceConstraint());
1176 newNamespaceConstraint.remove(null);
1177 result.getNamespaceConstraint().addAll(newNamespaceConstraint);
1178 return result;
1179 }
1180 // Clause 3 without minus
1181 //
1182 else
1183 {
1184 return this;
1185 }
1186 }
1187 // Clause 3
1188 //
1189 else if (XSDNamespaceConstraintCategory.SET_LITERAL == otherWildcard.getNamespaceConstraintCategory() &&
1190 XSDNamespaceConstraintCategory.NOT_LITERAL == getNamespaceConstraintCategory())
1191 {
1192 // Clause 3 with minus
1193 //
1194 if (otherWildcard.getNamespaceConstraint().containsAll(getNamespaceConstraint()) || otherWildcard.getNamespaceConstraint().contains(null))
1195 {
1196 XSDWildcard result = getXSDFactory().createXSDWildcard();
1197 if (isSetProcessContents())
1198 {
1199 result.setProcessContents(getProcessContents());
1200 }
1201 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.SET_LITERAL);
1202 List<String> newNamespaceConstraint = new ArrayList<String>(otherWildcard.getNamespaceConstraint());
1203 newNamespaceConstraint.removeAll(getNamespaceConstraint());
1204 newNamespaceConstraint.remove(null);
1205 result.getNamespaceConstraint().addAll(newNamespaceConstraint);
1206 return result;
1207 }
1208 // Clause 3 without minus
1209 //
1210 else
1211 {
1212 return otherWildcard;
1213 }
1214 }
1215 // Clause 4
1216 //
1217 else if (XSDNamespaceConstraintCategory.SET_LITERAL == getNamespaceConstraintCategory() &&
1218 XSDNamespaceConstraintCategory.SET_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1219 {
1220 XSDWildcard result = getXSDFactory().createXSDWildcard();
1221 if (isSetProcessContents())
1222 {
1223 result.setProcessContents(getProcessContents());
1224 }
1225 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.SET_LITERAL);
1226 List<String> newNamespaceConstraint = new ArrayList<String>(getNamespaceConstraint());
1227 newNamespaceConstraint.retainAll(otherWildcard.getNamespaceConstraint());
1228 result.getNamespaceConstraint().addAll(newNamespaceConstraint);
1229 return result;
1230 }
1231 // Clause 5
1232 //
1233 else if (XSDNamespaceConstraintCategory.NOT_LITERAL == getNamespaceConstraintCategory() &&
1234 XSDNamespaceConstraintCategory.NOT_LITERAL == otherWildcard.getNamespaceConstraintCategory())
1235 {
1236 if (getNamespaceConstraint().size() == 1 && getNamespaceConstraint().contains(null))
1237 {
1238 return otherWildcard;
1239 }
1240 else if (otherWildcard.getNamespaceConstraint().size() == 1 && otherWildcard.getNamespaceConstraint().contains(null))
1241 {
1242 return this;
1243 }
1244 else
1245 {
1246 // EATM return a bad placeholder.
1247 XSDWildcard result = getXSDFactory().createXSDWildcard();
1248 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.NOT_LITERAL);
1249 return result;
1250 }
1251 }
1252 // Failure
1253 //
1254 else
1255 {
1256 // EATM return a bad placeholder.
1257 XSDWildcard result = getXSDFactory().createXSDWildcard();
1258 result.setNamespaceConstraintCategory(XSDNamespaceConstraintCategory.NOT_LITERAL);
1259 return result;
1260 // return null;
1261 }
1262 }
1263
1264 public void setLike(XSDWildcard xsdWildcard)
1265 {
1266 if (getNamespaceConstraintCategory() != xsdWildcard.getNamespaceConstraintCategory())
1267 {
1268 setNamespaceConstraintCategory(xsdWildcard.getNamespaceConstraintCategory());
1269 }
1270
1271 EList<String> theNamespaceConstraint = getNamespaceConstraint();
1272 EList<String> newNamespaceConstraint = xsdWildcard.getNamespaceConstraint();
1273 if (!theNamespaceConstraint.containsAll(newNamespaceConstraint) ||
1274 !newNamespaceConstraint.containsAll(theNamespaceConstraint))
1275 {
1276 List<String> remainingNamespaceConstraint = new ArrayList<String>(theNamespaceConstraint);
1277 remainingNamespaceConstraint.removeAll(newNamespaceConstraint);
1278 if (!remainingNamespaceConstraint.isEmpty())
1279 {
1280 theNamespaceConstraint.removeAll(remainingNamespaceConstraint);
1281 }
1282 if (!newNamespaceConstraint.isEmpty())
1283 {
1284 setListContentAndOrder(theNamespaceConstraint, newNamespaceConstraint);
1285 }
1286 }
1287
1288 if (xsdWildcard.isSetProcessContents())
1289 {
1290 if (getProcessContents() != xsdWildcard.getProcessContents())
1291 {
1292 setProcessContents(xsdWildcard.getProcessContents());
1293 }
1294 }
1295 else
1296 {
1297 unsetProcessContents();
1298 }
1299 }
1300
1301 public boolean allows(String namespace)
1302 {
1303 switch (getNamespaceConstraintCategory().getValue())
1304 {
1305 case XSDNamespaceConstraintCategory.ANY:
1306 {
1307 return true;
1308 }
1309 case XSDNamespaceConstraintCategory.NOT:
1310 {
1311 return namespace != null && !getNamespaceConstraint().contains(namespace);
1312 }
1313 case XSDNamespaceConstraintCategory.SET:
1314 {
1315 return getNamespaceConstraint().contains(namespace);
1316 }
1317 default:
1318 {
1319 return false;
1320 }
1321 }
1322 }
1323
1324 @Override
1325 public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM)
1326 {
1327 XSDWildcardImpl clonedWildcard =
1328 (XSDWildcardImpl)getXSDFactory().createXSDWildcard();
1329 clonedWildcard.isReconciling = true;
1330
1331 if (isSetLexicalNamespaceConstraint())
1332 {
1333 if (!getLexicalNamespaceConstraint().isEmpty())
1334 {
1335 clonedWildcard.getLexicalNamespaceConstraint().addAll(getLexicalNamespaceConstraint());
1336 }
1337 else
1338 {
1339 clonedWildcard.getLexicalNamespaceConstraint().clear();
1340 }
1341 }
1342
1343 if (isSetProcessContents())
1344 {
1345 clonedWildcard.setProcessContents(getProcessContents());
1346 }
1347
1348 if (deep)
1349 {
1350 if (getAnnotation() != null)
1351 {
1352 clonedWildcard.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM));
1353 }
1354 }
1355
1356 if (shareDOM && getElement() != null)
1357 {
1358 clonedWildcard.setElement(getElement());
1359 }
1360
1361 clonedWildcard.isReconciling = shareDOM;
1362 return clonedWildcard;
1363 }
1364 }