| 1 |
/** |
| 2 |
* Copyright (c) 2002-2007 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v20.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM - Initial API and implementation |
| 10 |
*/ |
| 11 |
package org.eclipse.xsd.impl; |
| 12 |
|
| 13 |
|
| 14 |
import org.w3c.dom.Element; |
| 15 |
|
| 16 |
import org.eclipse.emf.common.notify.Notification; |
| 17 |
import org.eclipse.emf.ecore.EAttribute; |
| 18 |
import org.eclipse.emf.ecore.EClass; |
| 19 |
import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 |
|
| 21 |
import org.eclipse.xsd.XSDAttributeGroupDefinition; |
| 22 |
import org.eclipse.xsd.XSDAttributeUse; |
| 23 |
import org.eclipse.xsd.XSDConcreteComponent; |
| 24 |
import org.eclipse.xsd.XSDConstraint; |
| 25 |
import org.eclipse.xsd.XSDFeature; |
| 26 |
import org.eclipse.xsd.XSDForm; |
| 27 |
import org.eclipse.xsd.XSDModelGroupDefinition; |
| 28 |
import org.eclipse.xsd.XSDPackage; |
| 29 |
import org.eclipse.xsd.XSDSchema; |
| 30 |
import org.eclipse.xsd.XSDScope; |
| 31 |
import org.eclipse.xsd.XSDSimpleTypeDefinition; |
| 32 |
import org.eclipse.xsd.XSDTypeDefinition; |
| 33 |
import org.eclipse.xsd.util.XSDConstants; |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* <!-- begin-user-doc --> |
| 38 |
* An implementation of the model object '<em><b>Feature</b></em>'. |
| 39 |
* <!-- end-user-doc --> |
| 40 |
* <p> |
| 41 |
* The following features are implemented: |
| 42 |
* </p> |
| 43 |
* <ul> |
| 44 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getValue <em>Value</em>}</li> |
| 45 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getConstraint <em>Constraint</em>}</li> |
| 46 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getForm <em>Form</em>}</li> |
| 47 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getLexicalValue <em>Lexical Value</em>}</li> |
| 48 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#isGlobal <em>Global</em>}</li> |
| 49 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#isFeatureReference <em>Feature Reference</em>}</li> |
| 50 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getScope <em>Scope</em>}</li> |
| 51 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getResolvedFeature <em>Resolved Feature</em>}</li> |
| 52 |
* <li>{@link org.eclipse.xsd.impl.XSDFeatureImpl#getType <em>Type</em>}</li> |
| 53 |
* </ul> |
| 54 |
* |
| 55 |
* @generated |
| 56 |
*/ |
| 57 |
public abstract class XSDFeatureImpl |
| 58 |
extends XSDNamedComponentImpl |
| 59 |
implements XSDFeature |
| 60 |
{ |
| 61 |
/** |
| 62 |
* The default value of the '{@link #getValue() <em>Value</em>}' attribute. |
| 63 |
* <!-- begin-user-doc --> |
| 64 |
* <!-- end-user-doc --> |
| 65 |
* @see #getValue() |
| 66 |
* @generated |
| 67 |
* @ordered |
| 68 |
*/ |
| 69 |
protected static final Object VALUE_EDEFAULT = null; |
| 70 |
|
| 71 |
/** |
| 72 |
* The cached value of the '{@link #getValue() <em>Value</em>}' attribute. |
| 73 |
* <!-- begin-user-doc --> |
| 74 |
* <!-- end-user-doc --> |
| 75 |
* @see #getValue() |
| 76 |
* @generated |
| 77 |
* @ordered |
| 78 |
*/ |
| 79 |
protected Object value = VALUE_EDEFAULT; |
| 80 |
|
| 81 |
/** |
| 82 |
* The default value of the '{@link #getConstraint() <em>Constraint</em>}' attribute. |
| 83 |
* <!-- begin-user-doc --> |
| 84 |
* <!-- end-user-doc --> |
| 85 |
* @see #getConstraint() |
| 86 |
* @generated |
| 87 |
* @ordered |
| 88 |
*/ |
| 89 |
protected static final XSDConstraint CONSTRAINT_EDEFAULT = XSDConstraint.DEFAULT_LITERAL; |
| 90 |
|
| 91 |
/** |
| 92 |
* The offset of the flags representing the value of the '{@link #getConstraint() <em>Constraint</em>}' attribute. |
| 93 |
* <!-- begin-user-doc --> |
| 94 |
* <!-- end-user-doc --> |
| 95 |
* @generated |
| 96 |
* @ordered |
| 97 |
*/ |
| 98 |
protected static final int CONSTRAINT_EFLAG_OFFSET = 8; |
| 99 |
|
| 100 |
/** |
| 101 |
* The flags representing the default value of the '{@link #getConstraint() <em>Constraint</em>}' attribute. |
| 102 |
* <!-- begin-user-doc --> |
| 103 |
* <!-- end-user-doc --> |
| 104 |
* @generated |
| 105 |
* @ordered |
| 106 |
*/ |
| 107 |
protected static final int CONSTRAINT_EFLAG_DEFAULT = CONSTRAINT_EDEFAULT.ordinal() << CONSTRAINT_EFLAG_OFFSET; |
| 108 |
|
| 109 |
/** |
| 110 |
* The array of enumeration values for '{@link XSDConstraint Constraint}' |
| 111 |
* <!-- begin-user-doc --> |
| 112 |
* <!-- end-user-doc --> |
| 113 |
* @generated |
| 114 |
* @ordered |
| 115 |
*/ |
| 116 |
private static final XSDConstraint[] CONSTRAINT_EFLAG_VALUES = XSDConstraint.values(); |
| 117 |
|
| 118 |
/** |
| 119 |
* The flag representing the value of the '{@link #getConstraint() <em>Constraint</em>}' attribute. |
| 120 |
* <!-- begin-user-doc --> |
| 121 |
* <!-- end-user-doc --> |
| 122 |
* @see #getConstraint() |
| 123 |
* @generated |
| 124 |
* @ordered |
| 125 |
*/ |
| 126 |
protected static final int CONSTRAINT_EFLAG = 1 << CONSTRAINT_EFLAG_OFFSET; |
| 127 |
|
| 128 |
/** |
| 129 |
* The flag representing whether the Constraint attribute has been set. |
| 130 |
* <!-- begin-user-doc --> |
| 131 |
* <!-- end-user-doc --> |
| 132 |
* @generated |
| 133 |
* @ordered |
| 134 |
*/ |
| 135 |
protected static final int CONSTRAINT_ESETFLAG = 1 << 9; |
| 136 |
|
| 137 |
/** |
| 138 |
* The default value of the '{@link #getForm() <em>Form</em>}' attribute. |
| 139 |
* <!-- begin-user-doc --> |
| 140 |
* <!-- end-user-doc --> |
| 141 |
* @see #getForm() |
| 142 |
* @generated |
| 143 |
* @ordered |
| 144 |
*/ |
| 145 |
protected static final XSDForm FORM_EDEFAULT = XSDForm.QUALIFIED_LITERAL; |
| 146 |
|
| 147 |
/** |
| 148 |
* The offset of the flags representing the value of the '{@link #getForm() <em>Form</em>}' attribute. |
| 149 |
* <!-- begin-user-doc --> |
| 150 |
* <!-- end-user-doc --> |
| 151 |
* @generated |
| 152 |
* @ordered |
| 153 |
*/ |
| 154 |
protected static final int FORM_EFLAG_OFFSET = 10; |
| 155 |
|
| 156 |
/** |
| 157 |
* The flags representing the default value of the '{@link #getForm() <em>Form</em>}' attribute. |
| 158 |
* <!-- begin-user-doc --> |
| 159 |
* <!-- end-user-doc --> |
| 160 |
* @generated |
| 161 |
* @ordered |
| 162 |
*/ |
| 163 |
protected static final int FORM_EFLAG_DEFAULT = FORM_EDEFAULT.ordinal() << FORM_EFLAG_OFFSET; |
| 164 |
|
| 165 |
/** |
| 166 |
* The array of enumeration values for '{@link XSDForm Form}' |
| 167 |
* <!-- begin-user-doc --> |
| 168 |
* <!-- end-user-doc --> |
| 169 |
* @generated |
| 170 |
* @ordered |
| 171 |
*/ |
| 172 |
private static final XSDForm[] FORM_EFLAG_VALUES = XSDForm.values(); |
| 173 |
|
| 174 |
/** |
| 175 |
* The flag representing the value of the '{@link #getForm() <em>Form</em>}' attribute. |
| 176 |
* <!-- begin-user-doc --> |
| 177 |
* <!-- end-user-doc --> |
| 178 |
* @see #getForm() |
| 179 |
* @generated |
| 180 |
* @ordered |
| 181 |
*/ |
| 182 |
protected static final int FORM_EFLAG = 1 << FORM_EFLAG_OFFSET; |
| 183 |
|
| 184 |
/** |
| 185 |
* The flag representing whether the Form attribute has been set. |
| 186 |
* <!-- begin-user-doc --> |
| 187 |
* <!-- end-user-doc --> |
| 188 |
* @generated |
| 189 |
* @ordered |
| 190 |
*/ |
| 191 |
protected static final int FORM_ESETFLAG = 1 << 11; |
| 192 |
|
| 193 |
/** |
| 194 |
* The default value of the '{@link #getLexicalValue() <em>Lexical Value</em>}' attribute. |
| 195 |
* <!-- begin-user-doc --> |
| 196 |
* <!-- end-user-doc --> |
| 197 |
* @see #getLexicalValue() |
| 198 |
* @generated |
| 199 |
* @ordered |
| 200 |
*/ |
| 201 |
protected static final String LEXICAL_VALUE_EDEFAULT = null; |
| 202 |
|
| 203 |
/** |
| 204 |
* The cached value of the '{@link #getLexicalValue() <em>Lexical Value</em>}' attribute. |
| 205 |
* <!-- begin-user-doc --> |
| 206 |
* <!-- end-user-doc --> |
| 207 |
* @see #getLexicalValue() |
| 208 |
* @generated |
| 209 |
* @ordered |
| 210 |
*/ |
| 211 |
protected String lexicalValue = LEXICAL_VALUE_EDEFAULT; |
| 212 |
|
| 213 |
/** |
| 214 |
* The default value of the '{@link #isGlobal() <em>Global</em>}' attribute. |
| 215 |
* <!-- begin-user-doc --> |
| 216 |
* <!-- end-user-doc --> |
| 217 |
* @see #isGlobal() |
| 218 |
* @generated |
| 219 |
* @ordered |
| 220 |
*/ |
| 221 |
protected static final boolean GLOBAL_EDEFAULT = false; |
| 222 |
|
| 223 |
/** |
| 224 |
* The default value of the '{@link #isFeatureReference() <em>Feature Reference</em>}' attribute. |
| 225 |
* <!-- begin-user-doc --> |
| 226 |
* <!-- end-user-doc --> |
| 227 |
* @see #isFeatureReference() |
| 228 |
* @generated |
| 229 |
* @ordered |
| 230 |
*/ |
| 231 |
protected static final boolean FEATURE_REFERENCE_EDEFAULT = false; |
| 232 |
|
| 233 |
/** |
| 234 |
* <!-- begin-user-doc --> |
| 235 |
* <!-- end-user-doc --> |
| 236 |
* @generated |
| 237 |
*/ |
| 238 |
protected XSDFeatureImpl() |
| 239 |
{ |
| 240 |
super(); |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* <!-- begin-user-doc --> |
| 245 |
* <!-- end-user-doc --> |
| 246 |
* @generated |
| 247 |
*/ |
| 248 |
@Override |
| 249 |
protected EClass eStaticClass() |
| 250 |
{ |
| 251 |
return XSDPackage.Literals.XSD_FEATURE; |
| 252 |
} |
| 253 |
|
| 254 |
/** |
| 255 |
* <!-- begin-user-doc --> |
| 256 |
* <!-- end-user-doc --> |
| 257 |
* @generated |
| 258 |
*/ |
| 259 |
@Override |
| 260 |
public Object getValue() |
| 261 |
{ |
| 262 |
return value; |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* <!-- begin-user-doc --> |
| 267 |
* <!-- end-user-doc --> |
| 268 |
* @generated |
| 269 |
*/ |
| 270 |
@Override |
| 271 |
public void setValue(Object newValue) |
| 272 |
{ |
| 273 |
Object oldValue = value; |
| 274 |
value = newValue; |
| 275 |
if (eNotificationRequired()) |
| 276 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_FEATURE__VALUE, oldValue, value)); |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* <!-- begin-user-doc --> |
| 281 |
* <!-- end-user-doc --> |
| 282 |
* @generated |
| 283 |
*/ |
| 284 |
@Override |
| 285 |
public XSDConstraint getConstraint() |
| 286 |
{ |
| 287 |
return CONSTRAINT_EFLAG_VALUES[(eFlags & CONSTRAINT_EFLAG) >>> CONSTRAINT_EFLAG_OFFSET]; |
| 288 |
} |
| 289 |
|
| 290 |
/** |
| 291 |
* <!-- begin-user-doc --> |
| 292 |
* <!-- end-user-doc --> |
| 293 |
* @generated |
| 294 |
*/ |
| 295 |
@Override |
| 296 |
public void setConstraint(XSDConstraint newConstraint) |
| 297 |
{ |
| 298 |
XSDConstraint oldConstraint = CONSTRAINT_EFLAG_VALUES[(eFlags & CONSTRAINT_EFLAG) >>> CONSTRAINT_EFLAG_OFFSET]; |
| 299 |
if (newConstraint == null) newConstraint = CONSTRAINT_EDEFAULT; |
| 300 |
eFlags = eFlags & ~CONSTRAINT_EFLAG | newConstraint.ordinal() << CONSTRAINT_EFLAG_OFFSET; |
| 301 |
boolean oldConstraintESet = (eFlags & CONSTRAINT_ESETFLAG) != 0; |
| 302 |
eFlags |= CONSTRAINT_ESETFLAG; |
| 303 |
if (eNotificationRequired()) |
| 304 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_FEATURE__CONSTRAINT, oldConstraint, newConstraint, !oldConstraintESet)); |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* <!-- begin-user-doc --> |
| 309 |
* <!-- end-user-doc --> |
| 310 |
* @generated |
| 311 |
*/ |
| 312 |
@Override |
| 313 |
public void unsetConstraint() |
| 314 |
{ |
| 315 |
XSDConstraint oldConstraint = CONSTRAINT_EFLAG_VALUES[(eFlags & CONSTRAINT_EFLAG) >>> CONSTRAINT_EFLAG_OFFSET]; |
| 316 |
boolean oldConstraintESet = (eFlags & CONSTRAINT_ESETFLAG) != 0; |
| 317 |
eFlags = eFlags & ~CONSTRAINT_EFLAG | CONSTRAINT_EFLAG_DEFAULT; |
| 318 |
eFlags &= ~CONSTRAINT_ESETFLAG; |
| 319 |
if (eNotificationRequired()) |
| 320 |
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_FEATURE__CONSTRAINT, oldConstraint, CONSTRAINT_EDEFAULT, oldConstraintESet)); |
| 321 |
} |
| 322 |
|
| 323 |
/** |
| 324 |
* <!-- begin-user-doc --> |
| 325 |
* <!-- end-user-doc --> |
| 326 |
* @generated |
| 327 |
*/ |
| 328 |
@Override |
| 329 |
public boolean isSetConstraint() |
| 330 |
{ |
| 331 |
return (eFlags & CONSTRAINT_ESETFLAG) != 0; |
| 332 |
} |
| 333 |
|
| 334 |
/** |
| 335 |
* <!-- begin-user-doc --> |
| 336 |
* <!-- end-user-doc --> |
| 337 |
* @generated |
| 338 |
*/ |
| 339 |
@Override |
| 340 |
public XSDForm getForm() |
| 341 |
{ |
| 342 |
return FORM_EFLAG_VALUES[(eFlags & FORM_EFLAG) >>> FORM_EFLAG_OFFSET]; |
| 343 |
} |
| 344 |
|
| 345 |
/** |
| 346 |
* <!-- begin-user-doc --> |
| 347 |
* <!-- end-user-doc --> |
| 348 |
* @generated |
| 349 |
*/ |
| 350 |
@Override |
| 351 |
public void setForm(XSDForm newForm) |
| 352 |
{ |
| 353 |
XSDForm oldForm = FORM_EFLAG_VALUES[(eFlags & FORM_EFLAG) >>> FORM_EFLAG_OFFSET]; |
| 354 |
if (newForm == null) newForm = FORM_EDEFAULT; |
| 355 |
eFlags = eFlags & ~FORM_EFLAG | newForm.ordinal() << FORM_EFLAG_OFFSET; |
| 356 |
boolean oldFormESet = (eFlags & FORM_ESETFLAG) != 0; |
| 357 |
eFlags |= FORM_ESETFLAG; |
| 358 |
if (eNotificationRequired()) |
| 359 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_FEATURE__FORM, oldForm, newForm, !oldFormESet)); |
| 360 |
} |
| 361 |
|
| 362 |
/** |
| 363 |
* <!-- begin-user-doc --> |
| 364 |
* <!-- end-user-doc --> |
| 365 |
* @generated |
| 366 |
*/ |
| 367 |
@Override |
| 368 |
public void unsetForm() |
| 369 |
{ |
| 370 |
XSDForm oldForm = FORM_EFLAG_VALUES[(eFlags & FORM_EFLAG) >>> FORM_EFLAG_OFFSET]; |
| 371 |
boolean oldFormESet = (eFlags & FORM_ESETFLAG) != 0; |
| 372 |
eFlags = eFlags & ~FORM_EFLAG | FORM_EFLAG_DEFAULT; |
| 373 |
eFlags &= ~FORM_ESETFLAG; |
| 374 |
if (eNotificationRequired()) |
| 375 |
eNotify(new ENotificationImpl(this, Notification.UNSET, XSDPackage.XSD_FEATURE__FORM, oldForm, FORM_EDEFAULT, oldFormESet)); |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* <!-- begin-user-doc --> |
| 380 |
* <!-- end-user-doc --> |
| 381 |
* @generated |
| 382 |
*/ |
| 383 |
@Override |
| 384 |
public boolean isSetForm() |
| 385 |
{ |
| 386 |
return (eFlags & FORM_ESETFLAG) != 0; |
| 387 |
} |
| 388 |
|
| 389 |
/** |
| 390 |
* <!-- begin-user-doc --> |
| 391 |
* <!-- end-user-doc --> |
| 392 |
* @generated |
| 393 |
*/ |
| 394 |
@Override |
| 395 |
public String getLexicalValue() |
| 396 |
{ |
| 397 |
return lexicalValue; |
| 398 |
} |
| 399 |
|
| 400 |
/** |
| 401 |
* <!-- begin-user-doc --> |
| 402 |
* <!-- end-user-doc --> |
| 403 |
* @generated |
| 404 |
*/ |
| 405 |
@Override |
| 406 |
public void setLexicalValue(String newLexicalValue) |
| 407 |
{ |
| 408 |
String oldLexicalValue = lexicalValue; |
| 409 |
lexicalValue = newLexicalValue; |
| 410 |
if (eNotificationRequired()) |
| 411 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_FEATURE__LEXICAL_VALUE, oldLexicalValue, lexicalValue)); |
| 412 |
} |
| 413 |
|
| 414 |
/** |
| 415 |
* <!-- begin-user-doc --> |
| 416 |
* <!-- end-user-doc --> |
| 417 |
* @generated modifiable |
| 418 |
*/ |
| 419 |
public Boolean getGlobal() |
| 420 |
{ |
| 421 |
return isGlobal() ? Boolean.TRUE : Boolean.FALSE; |
| 422 |
} |
| 423 |
|
| 424 |
@Override |
| 425 |
protected boolean analyze() |
| 426 |
{ |
| 427 |
super.analyze(); |
| 428 |
Object newValue = null; |
| 429 |
if (!isFeatureReference()) |
| 430 |
{ |
| 431 |
XSDSimpleTypeDefinition xsdSimpleTypeDefinition = getType().getSimpleType(); |
| 432 |
if (xsdSimpleTypeDefinition != null) |
| 433 |
{ |
| 434 |
String theLexicalValue = getLexicalValue(); |
| 435 |
if (theLexicalValue != null) |
| 436 |
{ |
| 437 |
try |
| 438 |
{ |
| 439 |
newValue = xsdSimpleTypeDefinition.getValue(getElement(), theLexicalValue); |
| 440 |
} |
| 441 |
catch (RuntimeException exception) |
| 442 |
{ |
| 443 |
// Ignore |
| 444 |
} |
| 445 |
} |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
if (newValue == null ? getValue() != null : !newValue.equals(getValue())) |
| 450 |
{ |
| 451 |
setValue(newValue); |
| 452 |
} |
| 453 |
|
| 454 |
return true; |
| 455 |
} |
| 456 |
|
| 457 |
@Override |
| 458 |
protected boolean isUpdatingDOM() |
| 459 |
{ |
| 460 |
return |
| 461 |
super.isUpdatingDOM() || |
| 462 |
getContainer() instanceof XSDConcreteComponentImpl && |
| 463 |
((XSDConcreteComponentImpl)getContainer()).isUpdatingDOM(); |
| 464 |
} |
| 465 |
|
| 466 |
@Override |
| 467 |
protected void reconcileAttributes(Element changedElement) |
| 468 |
{ |
| 469 |
super.reconcileAttributes(changedElement); |
| 470 |
|
| 471 |
if (changedElement == getElement()) |
| 472 |
{ |
| 473 |
if (XSDConstants.nodeType(changedElement) != XSDConstants.ATTRIBUTE_ELEMENT || |
| 474 |
changedElement.getParentNode() == null || |
| 475 |
XSDConstants.nodeType(changedElement.getParentNode()) == XSDConstants.SCHEMA_ELEMENT) |
| 476 |
{ |
| 477 |
if (changedElement.hasAttributeNS(null, XSDConstants.FIXED_ATTRIBUTE)) |
| 478 |
{ |
| 479 |
String newLexicalValue = changedElement.getAttributeNS(null, XSDConstants.FIXED_ATTRIBUTE); |
| 480 |
if (newLexicalValue == null || !newLexicalValue.equals(getLexicalValue())) |
| 481 |
{ |
| 482 |
setLexicalValue(newLexicalValue); |
| 483 |
} |
| 484 |
if (!isSetConstraint() || XSDConstraint.FIXED_LITERAL != getConstraint()) |
| 485 |
{ |
| 486 |
setConstraint(XSDConstraint.FIXED_LITERAL); |
| 487 |
} |
| 488 |
} |
| 489 |
else if (changedElement.hasAttributeNS(null, XSDConstants.DEFAULT_ATTRIBUTE)) |
| 490 |
{ |
| 491 |
String newLexicalValue = changedElement.getAttributeNS(null, XSDConstants.DEFAULT_ATTRIBUTE); |
| 492 |
if (newLexicalValue == null || !newLexicalValue.equals(getLexicalValue())) |
| 493 |
{ |
| 494 |
setLexicalValue(newLexicalValue); |
| 495 |
} |
| 496 |
if (!isSetConstraint() || XSDConstraint.DEFAULT_LITERAL != getConstraint()) |
| 497 |
{ |
| 498 |
setConstraint(XSDConstraint.DEFAULT_LITERAL); |
| 499 |
} |
| 500 |
} |
| 501 |
else if (getLexicalValue() != null) |
| 502 |
{ |
| 503 |
unsetConstraint(); |
| 504 |
setLexicalValue(null); |
| 505 |
} |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
@Override |
| 511 |
protected void changeAttribute(EAttribute eAttribute) |
| 512 |
{ |
| 513 |
super.changeAttribute(eAttribute); |
| 514 |
if (!isFeatureReference() && !isReconciling) |
| 515 |
{ |
| 516 |
if (eAttribute == null || |
| 517 |
eAttribute == XSDPackage.Literals.XSD_FEATURE__LEXICAL_VALUE || |
| 518 |
eAttribute == XSDPackage.Literals.XSD_FEATURE__CONSTRAINT) |
| 519 |
{ |
| 520 |
Element theElement = getElement(); |
| 521 |
if (theElement != null) |
| 522 |
{ |
| 523 |
if (getLexicalValue() != null) |
| 524 |
{ |
| 525 |
switch (getConstraint().getValue()) |
| 526 |
{ |
| 527 |
case XSDConstraint.FIXED: |
| 528 |
{ |
| 529 |
niceSetAttribute(theElement, XSDConstants.FIXED_ATTRIBUTE, getLexicalValue()); |
| 530 |
if (theElement.hasAttributeNS(null, XSDConstants.DEFAULT_ATTRIBUTE)) |
| 531 |
{ |
| 532 |
niceSetAttribute(theElement, XSDConstants.DEFAULT_ATTRIBUTE, null); |
| 533 |
} |
| 534 |
break; |
| 535 |
} |
| 536 |
case XSDConstraint.DEFAULT: |
| 537 |
{ |
| 538 |
niceSetAttribute(theElement, XSDConstants.DEFAULT_ATTRIBUTE, getLexicalValue()); |
| 539 |
if (theElement.hasAttributeNS(null, XSDConstants.FIXED_ATTRIBUTE)) |
| 540 |
{ |
| 541 |
niceSetAttribute(theElement, XSDConstants.FIXED_ATTRIBUTE, null); |
| 542 |
} |
| 543 |
break; |
| 544 |
} |
| 545 |
} |
| 546 |
} |
| 547 |
else if (!(getContainer() instanceof XSDAttributeUse)) |
| 548 |
{ |
| 549 |
if (theElement.hasAttributeNS(null, XSDConstants.FIXED_ATTRIBUTE)) |
| 550 |
{ |
| 551 |
niceSetAttribute(theElement, XSDConstants.FIXED_ATTRIBUTE, null); |
| 552 |
} |
| 553 |
if (theElement.hasAttributeNS(null, XSDConstants.DEFAULT_ATTRIBUTE)) |
| 554 |
{ |
| 555 |
niceSetAttribute(theElement, XSDConstants.DEFAULT_ATTRIBUTE, null); |
| 556 |
} |
| 557 |
} |
| 558 |
} |
| 559 |
} |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
public XSDScope getScope() |
| 564 |
{ |
| 565 |
for (XSDConcreteComponent container = getContainer(); container != null; container = container.getContainer()) |
| 566 |
{ |
| 567 |
if (container instanceof XSDScope) |
| 568 |
{ |
| 569 |
return (XSDScope)container; |
| 570 |
} |
| 571 |
else if (container instanceof XSDModelGroupDefinition || container instanceof XSDAttributeGroupDefinition) |
| 572 |
{ |
| 573 |
return null; |
| 574 |
} |
| 575 |
} |
| 576 |
|
| 577 |
return null; |
| 578 |
} |
| 579 |
|
| 580 |
public boolean isFeatureReference() |
| 581 |
{ |
| 582 |
return isNamedComponentReference(); |
| 583 |
} |
| 584 |
|
| 585 |
public XSDFeature getResolvedFeature() |
| 586 |
{ |
| 587 |
return (XSDFeature)getResolvedNamedComponent(); |
| 588 |
} |
| 589 |
|
| 590 |
/** |
| 591 |
* <!-- begin-user-doc --> |
| 592 |
* <!-- end-user-doc --> |
| 593 |
* @generated |
| 594 |
*/ |
| 595 |
@Override |
| 596 |
public String toString() |
| 597 |
{ |
| 598 |
if (eIsProxy()) return super.toString(); |
| 599 |
|
| 600 |
StringBuilder result = new StringBuilder(super.toString()); |
| 601 |
result.append(" (value: "); |
| 602 |
result.append(value); |
| 603 |
result.append(", constraint: "); |
| 604 |
if ((eFlags & CONSTRAINT_ESETFLAG) != 0) result.append(CONSTRAINT_EFLAG_VALUES[(eFlags & CONSTRAINT_EFLAG) >>> CONSTRAINT_EFLAG_OFFSET]); else result.append("<unset>"); |
| 605 |
result.append(", form: "); |
| 606 |
if ((eFlags & FORM_ESETFLAG) != 0) result.append(FORM_EFLAG_VALUES[(eFlags & FORM_EFLAG) >>> FORM_EFLAG_OFFSET]); else result.append("<unset>"); |
| 607 |
result.append(", lexicalValue: "); |
| 608 |
result.append(lexicalValue); |
| 609 |
result.append(')'); |
| 610 |
return result.toString(); |
| 611 |
} |
| 612 |
|
| 613 |
public boolean isGlobal() |
| 614 |
{ |
| 615 |
for (XSDConcreteComponent container = getContainer(); container != null; container = container.getContainer()) |
| 616 |
{ |
| 617 |
if (container instanceof XSDScope) |
| 618 |
{ |
| 619 |
return container instanceof XSDSchema; |
| 620 |
} |
| 621 |
else if (container instanceof XSDModelGroupDefinition || container instanceof XSDAttributeGroupDefinition) |
| 622 |
{ |
| 623 |
return false; |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
return true; |
| 628 |
} |
| 629 |
|
| 630 |
/** |
| 631 |
* <!-- begin-user-doc --> |
| 632 |
* <!-- end-user-doc --> |
| 633 |
* @generated modifiable |
| 634 |
*/ |
| 635 |
public Boolean getFeatureReference() |
| 636 |
{ |
| 637 |
return isFeatureReference() ? Boolean.TRUE : Boolean.FALSE; |
| 638 |
} |
| 639 |
|
| 640 |
public XSDTypeDefinition getType() |
| 641 |
{ |
| 642 |
return null; |
| 643 |
} |
| 644 |
|
| 645 |
/** |
| 646 |
* <!-- begin-user-doc --> |
| 647 |
* <!-- end-user-doc --> |
| 648 |
* @generated |
| 649 |
*/ |
| 650 |
@Override |
| 651 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 652 |
{ |
| 653 |
switch (featureID) |
| 654 |
{ |
| 655 |
case XSDPackage.XSD_FEATURE__VALUE: |
| 656 |
return getValue(); |
| 657 |
case XSDPackage.XSD_FEATURE__CONSTRAINT: |
| 658 |
return getConstraint(); |
| 659 |
case XSDPackage.XSD_FEATURE__FORM: |
| 660 |
return getForm(); |
| 661 |
case XSDPackage.XSD_FEATURE__LEXICAL_VALUE: |
| 662 |
return getLexicalValue(); |
| 663 |
case XSDPackage.XSD_FEATURE__GLOBAL: |
| 664 |
return isGlobal(); |
| 665 |
case XSDPackage.XSD_FEATURE__FEATURE_REFERENCE: |
| 666 |
return isFeatureReference(); |
| 667 |
case XSDPackage.XSD_FEATURE__SCOPE: |
| 668 |
return getScope(); |
| 669 |
case XSDPackage.XSD_FEATURE__RESOLVED_FEATURE: |
| 670 |
return getResolvedFeature(); |
| 671 |
case XSDPackage.XSD_FEATURE__TYPE: |
| 672 |
return getType(); |
| 673 |
} |
| 674 |
return super.eGet(featureID, resolve, coreType); |
| 675 |
} |
| 676 |
|
| 677 |
/** |
| 678 |
* <!-- begin-user-doc --> |
| 679 |
* <!-- end-user-doc --> |
| 680 |
* @generated |
| 681 |
*/ |
| 682 |
@Override |
| 683 |
public void eSet(int featureID, Object newValue) |
| 684 |
{ |
| 685 |
switch (featureID) |
| 686 |
{ |
| 687 |
case XSDPackage.XSD_FEATURE__VALUE: |
| 688 |
setValue(newValue); |
| 689 |
return; |
| 690 |
case XSDPackage.XSD_FEATURE__CONSTRAINT: |
| 691 |
setConstraint((XSDConstraint)newValue); |
| 692 |
return; |
| 693 |
case XSDPackage.XSD_FEATURE__FORM: |
| 694 |
setForm((XSDForm)newValue); |
| 695 |
return; |
| 696 |
case XSDPackage.XSD_FEATURE__LEXICAL_VALUE: |
| 697 |
setLexicalValue((String)newValue); |
| 698 |
return; |
| 699 |
} |
| 700 |
super.eSet(featureID, newValue); |
| 701 |
} |
| 702 |
|
| 703 |
/** |
| 704 |
* <!-- begin-user-doc --> |
| 705 |
* <!-- end-user-doc --> |
| 706 |
* @generated |
| 707 |
*/ |
| 708 |
@Override |
| 709 |
public void eUnset(int featureID) |
| 710 |
{ |
| 711 |
switch (featureID) |
| 712 |
{ |
| 713 |
case XSDPackage.XSD_FEATURE__VALUE: |
| 714 |
setValue(VALUE_EDEFAULT); |
| 715 |
return; |
| 716 |
case XSDPackage.XSD_FEATURE__CONSTRAINT: |
| 717 |
unsetConstraint(); |
| 718 |
return; |
| 719 |
case XSDPackage.XSD_FEATURE__FORM: |
| 720 |
unsetForm(); |
| 721 |
return; |
| 722 |
case XSDPackage.XSD_FEATURE__LEXICAL_VALUE: |
| 723 |
setLexicalValue(LEXICAL_VALUE_EDEFAULT); |
| 724 |
return; |
| 725 |
} |
| 726 |
super.eUnset(featureID); |
| 727 |
} |
| 728 |
|
| 729 |
/** |
| 730 |
* <!-- begin-user-doc --> |
| 731 |
* <!-- end-user-doc --> |
| 732 |
* @generated |
| 733 |
*/ |
| 734 |
@Override |
| 735 |
public boolean eIsSet(int featureID) |
| 736 |
{ |
| 737 |
switch (featureID) |
| 738 |
{ |
| 739 |
case XSDPackage.XSD_FEATURE__VALUE: |
| 740 |
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); |
| 741 |
case XSDPackage.XSD_FEATURE__CONSTRAINT: |
| 742 |
return isSetConstraint(); |
| 743 |
case XSDPackage.XSD_FEATURE__FORM: |
| 744 |
return isSetForm(); |
| 745 |
case XSDPackage.XSD_FEATURE__LEXICAL_VALUE: |
| 746 |
return LEXICAL_VALUE_EDEFAULT == null ? lexicalValue != null : !LEXICAL_VALUE_EDEFAULT.equals(lexicalValue); |
| 747 |
case XSDPackage.XSD_FEATURE__GLOBAL: |
| 748 |
return isGlobal() != GLOBAL_EDEFAULT; |
| 749 |
case XSDPackage.XSD_FEATURE__FEATURE_REFERENCE: |
| 750 |
return isFeatureReference() != FEATURE_REFERENCE_EDEFAULT; |
| 751 |
case XSDPackage.XSD_FEATURE__SCOPE: |
| 752 |
return getScope() != null; |
| 753 |
case XSDPackage.XSD_FEATURE__RESOLVED_FEATURE: |
| 754 |
return getResolvedFeature() != null; |
| 755 |
case XSDPackage.XSD_FEATURE__TYPE: |
| 756 |
return getType() != null; |
| 757 |
} |
| 758 |
return super.eIsSet(featureID); |
| 759 |
} |
| 760 |
|
| 761 |
} |