1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.exolab.castor.builder.types;
15
16 import org.exolab.castor.xml.schema.Facet;
17 import org.exolab.javasource.JSourceCode;
18
19
20
21
22
23
24
25
26 public abstract class AbstractRangeFacet extends AbstractWhiteSpaceFacet {
27
28
29 private String _maxExclusive;
30
31
32 private String _maxInclusive;
33
34
35 private String _minExclusive;
36
37
38 private String _minInclusive;
39
40 private String _positiveInfinity;
41
42 private String _negativeInfinity;
43
44
45
46
47
48
49 public final boolean hasMaximum() {
50 return (_maxInclusive != null) || (_maxExclusive != null);
51 }
52
53
54
55
56
57
58
59 public final String getMaxExclusive() {
60 return _maxExclusive;
61 }
62
63
64
65
66
67
68 public final void setMaxExclusive(final String max) {
69 _maxExclusive = max;
70 _maxInclusive = null;
71 }
72
73
74
75
76
77
78
79 public final String getMaxInclusive() {
80 return _maxInclusive;
81 }
82
83
84
85
86
87
88 public final void setMaxInclusive(final String max) {
89 _maxInclusive = max;
90 _maxExclusive = null;
91 }
92
93
94
95
96
97
98 public final boolean hasMinimum() {
99 return (_minInclusive != null) || (_minExclusive != null);
100 }
101
102
103
104
105
106
107
108 public final String getMinExclusive() {
109 return _minExclusive;
110 }
111
112
113
114
115
116
117 public final void setMinExclusive(final String min) {
118 _minExclusive = min;
119 _minInclusive = null;
120 }
121
122
123
124
125
126
127 public final String getMinInclusive() {
128 return _minInclusive;
129 }
130
131
132
133
134
135
136 public final void setMinInclusive(final String min) {
137 _minInclusive = min;
138 _minExclusive = null;
139 }
140
141 public final void setPositiveInfinity(final String positiveInfity) {
142 _positiveInfinity = positiveInfity;
143 }
144
145 public final void setNegativeInfinity(final String negativeInfity) {
146 _negativeInfinity = negativeInfity;
147 }
148
149 public final boolean hasPositiveInfinity() {
150 return _positiveInfinity != null;
151 }
152
153 public final boolean hasNegavtiveInfinity() {
154 return _negativeInfinity != null;
155 }
156
157 public final String getPositiveInfinity() {
158 return _positiveInfinity;
159 }
160
161 public final String getNegativeInfinity() {
162 return _negativeInfinity;
163 }
164
165
166
167
168 protected void setFacet(final Facet facet) {
169 super.setFacet(facet);
170 setRangeFacet(facet);
171 }
172
173
174
175
176
177
178 protected final void setRangeFacet(final Facet facet) {
179 String name = facet.getName();
180 if (Facet.MAX_EXCLUSIVE.equals(name)) {
181 setMaxExclusive(facet.getValue());
182 } else if (Facet.MAX_INCLUSIVE.equals(name)) {
183 setMaxInclusive(facet.getValue());
184 } else if (Facet.MIN_EXCLUSIVE.equals(name)) {
185 setMinExclusive(facet.getValue());
186 } else if (Facet.MIN_INCLUSIVE.equals(name)) {
187 setMinInclusive(facet.getValue());
188 }
189 }
190
191
192
193
194
195
196
197 protected final void codeRangeFacet(final JSourceCode jsc, final String validatorName) {
198
199 if (_maxInclusive != null) {
200 jsc.add("{0}.setMaxInclusive(\"{1}\");", validatorName, getMaxInclusive());
201 } else if (_maxExclusive != null) {
202 jsc.add("{0}.setMaxExclusive(\"{1}\");", validatorName, getMaxExclusive());
203 }
204
205
206 if (_minInclusive != null) {
207 jsc.add("{0}.setMinInclusive(\"{1}\");", validatorName, getMinInclusive());
208 } else if (_minExclusive != null) {
209 jsc.add("{0}.setMinExclusive(\"{1}\");", validatorName, getMinExclusive());
210 }
211
212
213
214
215
216
217
218
219 }
220
221 }