Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDCardinalityFacetImpl.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 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.XSDCardinality;
19 import org.eclipse.xsd.XSDCardinalityFacet;
20 import org.eclipse.xsd.XSDPackage;
21
22
23 /**
24 * <!-- begin-user-doc -->
25 * An implementation of the model object '<em><b>Cardinality Facet</b></em>'.
26 * <!-- end-user-doc -->
27 * <p>
28 * The following features are implemented:
29 * </p>
30 * <ul>
31 * <li>{@link org.eclipse.xsd.impl.XSDCardinalityFacetImpl#getValue <em>Value</em>}</li>
32 * </ul>
33 *
34 * @generated
35 */
36 public class XSDCardinalityFacetImpl
37 extends XSDFundamentalFacetImpl
38 implements XSDCardinalityFacet
39 {
40 /**
41 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
42 * <!-- begin-user-doc -->
43 * <!-- end-user-doc -->
44 * @see #getValue()
45 * @generated
46 * @ordered
47 */
48 protected static final XSDCardinality VALUE_EDEFAULT = XSDCardinality.FINITE_LITERAL;
49
50 /**
51 * The offset of the flags representing the value of the '{@link #getValue() <em>Value</em>}' attribute.
52 * <!-- begin-user-doc -->
53 * <!-- end-user-doc -->
54 * @generated
55 * @ordered
56 */
57 protected static final int VALUE_EFLAG_OFFSET = 8;
58
59 /**
60 * The flags representing the default value of the '{@link #getValue() <em>Value</em>}' attribute.
61 * <!-- begin-user-doc -->
62 * <!-- end-user-doc -->
63 * @generated
64 * @ordered
65 */
66 protected static final int VALUE_EFLAG_DEFAULT = VALUE_EDEFAULT.ordinal() << VALUE_EFLAG_OFFSET;
67
68 /**
69 * The array of enumeration values for '{@link XSDCardinality Cardinality}'
70 * <!-- begin-user-doc -->
71 * <!-- end-user-doc -->
72 * @generated
73 * @ordered
74 */
75 private static final XSDCardinality[] VALUE_EFLAG_VALUES = XSDCardinality.values();
76
77 /**
78 * The flag representing the value of the '{@link #getValue() <em>Value</em>}' attribute.
79 * <!-- begin-user-doc -->
80 * <!-- end-user-doc -->
81 * @see #getValue()
82 * @generated
83 * @ordered
84 */
85 protected static final int VALUE_EFLAG = 1 << VALUE_EFLAG_OFFSET;
86
87 /**
88 * <!-- begin-user-doc -->
89 * <!-- end-user-doc -->
90 * @generated
91 */
92 protected XSDCardinalityFacetImpl()
93 {
94 super();
95 }
96
97 /**
98 * <!-- begin-user-doc -->
99 * <!-- end-user-doc -->
100 * @generated
101 */
102 @Override
103 protected EClass eStaticClass()
104 {
105 return XSDPackage.Literals.XSD_CARDINALITY_FACET;
106 }
107
108 /**
109 * <!-- begin-user-doc -->
110 * <!-- end-user-doc -->
111 * @generated
112 */
113 @Override
114 public XSDCardinality getValue()
115 {
116 return VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET];
117 }
118
119 /**
120 * <!-- begin-user-doc -->
121 * <!-- end-user-doc -->
122 * @generated
123 */
124 @Override
125 public void setValue(XSDCardinality newValue)
126 {
127 XSDCardinality oldValue = VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET];
128 if (newValue == null) newValue = VALUE_EDEFAULT;
129 eFlags = eFlags & ~VALUE_EFLAG | newValue.ordinal() << VALUE_EFLAG_OFFSET;
130 if (eNotificationRequired())
131 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_CARDINALITY_FACET__VALUE, oldValue, newValue));
132 }
133
134 /**
135 * <!-- begin-user-doc -->
136 * <!-- end-user-doc -->
137 * @generated
138 */
139 @Override
140 public Object eGet(int featureID, boolean resolve, boolean coreType)
141 {
142 switch (featureID)
143 {
144 case XSDPackage.XSD_CARDINALITY_FACET__VALUE:
145 return getValue();
146 }
147 return super.eGet(featureID, resolve, coreType);
148 }
149
150 /**
151 * <!-- begin-user-doc -->
152 * <!-- end-user-doc -->
153 * @generated
154 */
155 @Override
156 public void eSet(int featureID, Object newValue)
157 {
158 switch (featureID)
159 {
160 case XSDPackage.XSD_CARDINALITY_FACET__VALUE:
161 setValue((XSDCardinality)newValue);
162 return;
163 }
164 super.eSet(featureID, newValue);
165 }
166
167 /**
168 * <!-- begin-user-doc -->
169 * <!-- end-user-doc -->
170 * @generated
171 */
172 @Override
173 public void eUnset(int featureID)
174 {
175 switch (featureID)
176 {
177 case XSDPackage.XSD_CARDINALITY_FACET__VALUE:
178 setValue(VALUE_EDEFAULT);
179 return;
180 }
181 super.eUnset(featureID);
182 }
183
184 /**
185 * <!-- begin-user-doc -->
186 * <!-- end-user-doc -->
187 * @generated
188 */
189 @Override
190 public boolean eIsSet(int featureID)
191 {
192 switch (featureID)
193 {
194 case XSDPackage.XSD_CARDINALITY_FACET__VALUE:
195 return (eFlags & VALUE_EFLAG) != VALUE_EFLAG_DEFAULT;
196 }
197 return super.eIsSet(featureID);
198 }
199
200 /**
201 * <!-- begin-user-doc -->
202 * <!-- end-user-doc -->
203 * @generated
204 */
205 @Override
206 public String toString()
207 {
208 if (eIsProxy()) return super.toString();
209
210 StringBuilder result = new StringBuilder(super.toString());
211 result.append(" (value: ");
212 result.append(VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET]);
213 result.append(')');
214 return result.toString();
215 }
216
217 @Override
218 public Object getEffectiveValue()
219 {
220 return getValue();
221 }
222 }