| 1 |
/** |
| 2 |
* Copyright (c) 2002-2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v20.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM - Initial API and implementation |
| 10 |
*/ |
| 11 |
package org.eclipse.xsd.impl; |
| 12 |
|
| 13 |
|
| 14 |
import org.eclipse.emf.common.notify.Notification; |
| 15 |
import org.eclipse.emf.ecore.EClass; |
| 16 |
import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 17 |
|
| 18 |
import org.eclipse.xsd.XSDNumericFacet; |
| 19 |
import org.eclipse.xsd.XSDPackage; |
| 20 |
|
| 21 |
|
| 22 |
/** |
| 23 |
* <!-- begin-user-doc --> |
| 24 |
* An implementation of the model object '<em><b>Numeric Facet</b></em>'. |
| 25 |
* <!-- end-user-doc --> |
| 26 |
* <p> |
| 27 |
* The following features are implemented: |
| 28 |
* </p> |
| 29 |
* <ul> |
| 30 |
* <li>{@link org.eclipse.xsd.impl.XSDNumericFacetImpl#isValue <em>Value</em>}</li> |
| 31 |
* </ul> |
| 32 |
* |
| 33 |
* @generated |
| 34 |
*/ |
| 35 |
public class XSDNumericFacetImpl |
| 36 |
extends XSDFundamentalFacetImpl |
| 37 |
implements XSDNumericFacet |
| 38 |
{ |
| 39 |
/** |
| 40 |
* The default value of the '{@link #isValue() <em>Value</em>}' attribute. |
| 41 |
* <!-- begin-user-doc --> |
| 42 |
* <!-- end-user-doc --> |
| 43 |
* @see #isValue() |
| 44 |
* @generated |
| 45 |
* @ordered |
| 46 |
*/ |
| 47 |
protected static final boolean VALUE_EDEFAULT = false; |
| 48 |
|
| 49 |
/** |
| 50 |
* The flag representing the value of the '{@link #isValue() <em>Value</em>}' attribute. |
| 51 |
* <!-- begin-user-doc --> |
| 52 |
* <!-- end-user-doc --> |
| 53 |
* @see #isValue() |
| 54 |
* @generated |
| 55 |
* @ordered |
| 56 |
*/ |
| 57 |
protected static final int VALUE_EFLAG = 1 << 8; |
| 58 |
|
| 59 |
/** |
| 60 |
* <!-- begin-user-doc --> |
| 61 |
* <!-- end-user-doc --> |
| 62 |
* @generated |
| 63 |
*/ |
| 64 |
protected XSDNumericFacetImpl() |
| 65 |
{ |
| 66 |
super(); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* <!-- begin-user-doc --> |
| 71 |
* <!-- end-user-doc --> |
| 72 |
* @generated |
| 73 |
*/ |
| 74 |
@Override |
| 75 |
protected EClass eStaticClass() |
| 76 |
{ |
| 77 |
return XSDPackage.Literals.XSD_NUMERIC_FACET; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* <!-- begin-user-doc --> |
| 82 |
* <!-- end-user-doc --> |
| 83 |
* @generated |
| 84 |
*/ |
| 85 |
@Override |
| 86 |
public boolean isValue() |
| 87 |
{ |
| 88 |
return (eFlags & VALUE_EFLAG) != 0; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* <!-- begin-user-doc --> |
| 93 |
* <!-- end-user-doc --> |
| 94 |
* @generated |
| 95 |
*/ |
| 96 |
@Override |
| 97 |
public void setValue(boolean newValue) |
| 98 |
{ |
| 99 |
boolean oldValue = (eFlags & VALUE_EFLAG) != 0; |
| 100 |
if (newValue) eFlags |= VALUE_EFLAG; else eFlags &= ~VALUE_EFLAG; |
| 101 |
if (eNotificationRequired()) |
| 102 |
eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_NUMERIC_FACET__VALUE, oldValue, newValue)); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* <!-- begin-user-doc --> |
| 107 |
* <!-- end-user-doc --> |
| 108 |
* @generated |
| 109 |
*/ |
| 110 |
@Override |
| 111 |
public Object eGet(int featureID, boolean resolve, boolean coreType) |
| 112 |
{ |
| 113 |
switch (featureID) |
| 114 |
{ |
| 115 |
case XSDPackage.XSD_NUMERIC_FACET__VALUE: |
| 116 |
return isValue(); |
| 117 |
} |
| 118 |
return super.eGet(featureID, resolve, coreType); |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* <!-- begin-user-doc --> |
| 123 |
* <!-- end-user-doc --> |
| 124 |
* @generated |
| 125 |
*/ |
| 126 |
@Override |
| 127 |
public void eSet(int featureID, Object newValue) |
| 128 |
{ |
| 129 |
switch (featureID) |
| 130 |
{ |
| 131 |
case XSDPackage.XSD_NUMERIC_FACET__VALUE: |
| 132 |
setValue((Boolean)newValue); |
| 133 |
return; |
| 134 |
} |
| 135 |
super.eSet(featureID, newValue); |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* <!-- begin-user-doc --> |
| 140 |
* <!-- end-user-doc --> |
| 141 |
* @generated |
| 142 |
*/ |
| 143 |
@Override |
| 144 |
public void eUnset(int featureID) |
| 145 |
{ |
| 146 |
switch (featureID) |
| 147 |
{ |
| 148 |
case XSDPackage.XSD_NUMERIC_FACET__VALUE: |
| 149 |
setValue(VALUE_EDEFAULT); |
| 150 |
return; |
| 151 |
} |
| 152 |
super.eUnset(featureID); |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* <!-- begin-user-doc --> |
| 157 |
* <!-- end-user-doc --> |
| 158 |
* @generated |
| 159 |
*/ |
| 160 |
@Override |
| 161 |
public boolean eIsSet(int featureID) |
| 162 |
{ |
| 163 |
switch (featureID) |
| 164 |
{ |
| 165 |
case XSDPackage.XSD_NUMERIC_FACET__VALUE: |
| 166 |
return ((eFlags & VALUE_EFLAG) != 0) != VALUE_EDEFAULT; |
| 167 |
} |
| 168 |
return super.eIsSet(featureID); |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* <!-- begin-user-doc --> |
| 173 |
* <!-- end-user-doc --> |
| 174 |
* @generated |
| 175 |
*/ |
| 176 |
@Override |
| 177 |
public String toString() |
| 178 |
{ |
| 179 |
if (eIsProxy()) return super.toString(); |
| 180 |
|
| 181 |
StringBuilder result = new StringBuilder(super.toString()); |
| 182 |
result.append(" (value: "); |
| 183 |
result.append((eFlags & VALUE_EFLAG) != 0); |
| 184 |
result.append(')'); |
| 185 |
return result.toString(); |
| 186 |
} |
| 187 |
|
| 188 |
@Override |
| 189 |
public Object getEffectiveValue() |
| 190 |
{ |
| 191 |
return isValue() ? Boolean.TRUE : Boolean.FALSE; |
| 192 |
} |
| 193 |
} |