Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDMinInclusiveFacetImpl.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.w3c.dom.Element;
15 import org.w3c.dom.Node;
16
17 import org.eclipse.emf.ecore.EAttribute;
18 import org.eclipse.emf.ecore.EClass;
19
20 import org.eclipse.xsd.XSDAnnotation;
21 import org.eclipse.xsd.XSDConcreteComponent;
22 import org.eclipse.xsd.XSDFactory;
23 import org.eclipse.xsd.XSDMinInclusiveFacet;
24 import org.eclipse.xsd.XSDPackage;
25 import org.eclipse.xsd.XSDSimpleTypeDefinition;
26 import org.eclipse.xsd.util.XSDConstants;
27
28
29 /**
30 * <!-- begin-user-doc -->
31 * An implementation of the model object '<em><b>Min Inclusive Facet</b></em>'.
32 * <!-- end-user-doc -->
33 *
34 * @generated
35 */
36 public class XSDMinInclusiveFacetImpl
37 extends XSDMinFacetImpl
38 implements XSDMinInclusiveFacet
39 {
40 public static XSDMinInclusiveFacet createMinInclusiveFacet(Node node)
41 {
42 if (XSDConstants.nodeType(node) == XSDConstants.MININCLUSIVE_ELEMENT)
43 {
44 XSDMinInclusiveFacet xsdMinInclusiveFacet = XSDFactory.eINSTANCE.createXSDMinInclusiveFacet();
45 xsdMinInclusiveFacet.setElement((Element)node);
46 return xsdMinInclusiveFacet;
47 }
48
49 return null;
50 }
51
52 /**
53 * <!-- begin-user-doc -->
54 * <!-- end-user-doc -->
55 * @generated
56 */
57 protected XSDMinInclusiveFacetImpl()
58 {
59 super();
60 }
61
62 /**
63 * <!-- begin-user-doc -->
64 * <!-- end-user-doc -->
65 * @generated
66 */
67 @Override
68 protected EClass eStaticClass()
69 {
70 return XSDPackage.Literals.XSD_MIN_INCLUSIVE_FACET;
71 }
72
73 @Override
74 public Element createElement()
75 {
76 Element newElement = createElement(XSDConstants.MININCLUSIVE_ELEMENT);
77 setElement(newElement);
78 return newElement;
79 }
80
81 @Override
82 protected boolean analyze()
83 {
84 super.analyze();
85 String theLexicalValue = getLexicalValue();
86 Object newValue = null;
87 if (theLexicalValue != null)
88 {
89 XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)getContainer();
90 if (xsdSimpleTypeDefinition != null)
91 {
92 try
93 {
94 newValue = xsdSimpleTypeDefinition.getValue(getElement(), theLexicalValue);
95 }
96 catch (RuntimeException exception)
97 {
98 // Ignore
99 }
100 }
101 }
102
103 if (newValue == null ? getValue() != null : !newValue.equals(getValue()))
104 {
105 setValue(newValue);
106 }
107 return true;
108 }
109
110 @Override
111 protected void changeAttribute(EAttribute eAttribute)
112 {
113 super.changeAttribute(eAttribute);
114 if (eAttribute == XSDPackage.Literals.XSD_FACET__LEXICAL_VALUE)
115 {
116 traverseToRootForAnalysis();
117 }
118 }
119
120 @Override
121 public boolean isConstraintSatisfied(Object value)
122 {
123 XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)getContainer();
124 if (xsdSimpleTypeDefinition != null)
125 {
126 return xsdSimpleTypeDefinition.compareValues(value, getValue()) >= 0;
127 }
128
129 return false;
130 }
131
132 @Override
133 public Object getEffectiveValue()
134 {
135 return getValue();
136 }
137
138 @Override
139 public boolean isInclusive()
140 {
141 return true;
142 }
143
144 @Override
145 public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM)
146 {
147 XSDMinInclusiveFacetImpl clonedMinInclusiveFacet =
148 (XSDMinInclusiveFacetImpl)getXSDFactory().createXSDMinInclusiveFacet();
149 clonedMinInclusiveFacet.isReconciling = true;
150
151 if (getLexicalValue() != null)
152 {
153 clonedMinInclusiveFacet.setLexicalValue(getLexicalValue());
154 }
155 if (isSetFixed())
156 {
157 clonedMinInclusiveFacet.setFixed(isFixed());
158 }
159
160 if (deep)
161 {
162 if (getAnnotation() != null)
163 {
164 clonedMinInclusiveFacet.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM));
165 }
166 }
167
168 if (shareDOM && getElement() != null)
169 {
170 clonedMinInclusiveFacet.setElement(getElement());
171 }
172
173 clonedMinInclusiveFacet.isReconciling = shareDOM;
174 return clonedMinInclusiveFacet;
175 }
176 }