Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDMaxInclusiveFacetImpl.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.XSDMaxInclusiveFacet;
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>Max Inclusive Facet</b></em>'.
32 * <!-- end-user-doc -->
33 *
34 * @generated
35 */
36 public class XSDMaxInclusiveFacetImpl
37 extends XSDMaxFacetImpl
38 implements XSDMaxInclusiveFacet
39 {
40 public static XSDMaxInclusiveFacet createMaxInclusiveFacet(Node node)
41 {
42 if (XSDConstants.nodeType(node) == XSDConstants.MAXINCLUSIVE_ELEMENT)
43 {
44 XSDMaxInclusiveFacet xsdMaxInclusiveFacet = XSDFactory.eINSTANCE.createXSDMaxInclusiveFacet();
45 xsdMaxInclusiveFacet.setElement((Element)node);
46 return xsdMaxInclusiveFacet;
47 }
48
49 return null;
50 }
51
52 /**
53 * <!-- begin-user-doc -->
54 * <!-- end-user-doc -->
55 * @generated
56 */
57 protected XSDMaxInclusiveFacetImpl()
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_MAX_INCLUSIVE_FACET;
71 }
72
73 @Override
74 public Element createElement()
75 {
76 Element newElement = createElement(XSDConstants.MAXINCLUSIVE_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
108 return true;
109 }
110
111 @Override
112 protected void changeAttribute(EAttribute eAttribute)
113 {
114 super.changeAttribute(eAttribute);
115 if (eAttribute == XSDPackage.Literals.XSD_FACET__LEXICAL_VALUE)
116 {
117 traverseToRootForAnalysis();
118 }
119 }
120
121 @Override
122 public boolean isConstraintSatisfied(Object value)
123 {
124 XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)getContainer();
125 if (xsdSimpleTypeDefinition != null)
126 {
127 return xsdSimpleTypeDefinition.compareValues(value, getValue()) <= 0;
128 }
129
130 return false;
131 }
132
133 @Override
134 public Object getEffectiveValue()
135 {
136 return getValue();
137 }
138
139 @Override
140 public boolean isInclusive()
141 {
142 return true;
143 }
144
145 @Override
146 public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM)
147 {
148 XSDMaxInclusiveFacetImpl clonedMaxInclusiveFacet =
149 (XSDMaxInclusiveFacetImpl)getXSDFactory().createXSDMaxInclusiveFacet();
150 clonedMaxInclusiveFacet.isReconciling = true;
151
152 if (getLexicalValue() != null)
153 {
154 clonedMaxInclusiveFacet.setLexicalValue(getLexicalValue());
155 }
156 if (isSetFixed())
157 {
158 clonedMaxInclusiveFacet.setFixed(isFixed());
159 }
160
161 if (deep)
162 {
163 if (getAnnotation() != null)
164 {
165 clonedMaxInclusiveFacet.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM));
166 }
167 }
168
169 if (shareDOM && getElement() != null)
170 {
171 clonedMaxInclusiveFacet.setElement(getElement());
172 }
173
174 clonedMaxInclusiveFacet.isReconciling = shareDOM;
175 return clonedMaxInclusiveFacet;
176 }
177 }