View Javadoc

1   /*
2    *   Copyright (C) Christian Schulte, 2005-206
3    *   All rights reserved.
4    *
5    *   Redistribution and use in source and binary forms, with or without
6    *   modification, are permitted provided that the following conditions
7    *   are met:
8    *
9    *     o Redistributions of source code must retain the above copyright
10   *       notice, this list of conditions and the following disclaimer.
11   *
12   *     o Redistributions in binary form must reproduce the above copyright
13   *       notice, this list of conditions and the following disclaimer in
14   *       the documentation and/or other materials provided with the
15   *       distribution.
16   *
17   *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18   *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19   *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20   *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21   *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22   *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23   *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24   *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26   *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27   *
28   *   $JOMC: TestModelProvider.java 4654 2012-11-15 22:28:26Z schulte $
29   *
30   */
31  package org.jomc.modlet.test.support;
32  
33  import java.net.URL;
34  import org.jomc.modlet.Model;
35  import org.jomc.modlet.ModelContext;
36  import org.jomc.modlet.ModelException;
37  import org.jomc.modlet.ModelProvider;
38  import org.jomc.modlet.test.ObjectFactory;
39  import org.jomc.modlet.test.TestComplexType;
40  
41  /**
42   * {@code ModelProvider} test implementation.
43   *
44   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
45   * @version $JOMC: TestModelProvider.java 4654 2012-11-15 22:28:26Z schulte $
46   */
47  public final class TestModelProvider implements ModelProvider
48  {
49  
50      private boolean booleanProperty;
51  
52      private boolean boxedBooleanProperty;
53  
54      private Boolean unboxedBooleanProperty;
55  
56      private char characterProperty;
57  
58      private char boxedCharacterProperty;
59  
60      private Character unboxedCharacterProperty;
61  
62      private byte byteProperty;
63  
64      private byte boxedByteProperty;
65  
66      private Byte unboxedByteProperty;
67  
68      private short shortProperty;
69  
70      private short boxedShortProperty;
71  
72      private Short unboxedShortProperty;
73  
74      private int intProperty;
75  
76      private int boxedIntProperty;
77  
78      private Integer unboxedIntProperty;
79  
80      private long longProperty;
81  
82      private long boxedLongProperty;
83  
84      private Long unboxedLongProperty;
85  
86      private float floatProperty;
87  
88      private float boxedFloatProperty;
89  
90      private Float unboxedFloatProperty;
91  
92      private double doubleProperty;
93  
94      private double boxedDoubleProperty;
95  
96      private Double unboxedDoubleProperty;
97  
98      private String stringProperty;
99  
100     private URL urlProperty;
101 
102     private Thread.State enumProperty;
103 
104     private Object objectProperty;
105 
106     private String stringPropertyWithoutSetter;
107 
108     private String stringPropertyWithoutGetter;
109 
110     private Math unsupportedPropertyType;
111 
112     private InstantiationExceptionPropertyType instantiationExceptionProperty;
113 
114     private InvocationTargetExceptionPropertyType invocationTargetExceptionProperty;
115 
116     public TestModelProvider()
117     {
118         super();
119     }
120 
121     public Model findModel( final ModelContext context, final Model model ) throws ModelException
122     {
123         if ( context == null )
124         {
125             throw new NullPointerException( "context" );
126         }
127         if ( model == null )
128         {
129             throw new NullPointerException( "model" );
130         }
131 
132         context.setAttribute( TestModelProvider.class.getName(), this );
133 
134         final Model created = model.clone();
135         created.getAny().add( new ObjectFactory().createTest( new TestComplexType() ) );
136         return created;
137     }
138 
139     public boolean isBooleanProperty()
140     {
141         return this.booleanProperty;
142     }
143 
144     public void setBooleanProperty( final boolean value )
145     {
146         this.booleanProperty = value;
147     }
148 
149     public Boolean isBoxedBooleanProperty()
150     {
151         return this.boxedBooleanProperty;
152     }
153 
154     public void setBoxedBooleanProperty( final boolean value )
155     {
156         this.boxedBooleanProperty = value;
157     }
158 
159     public boolean isUnboxedBooleanProperty()
160     {
161         return this.unboxedBooleanProperty ? true : false;
162     }
163 
164     public void setUnboxedBooleanProperty( final Boolean value )
165     {
166         this.unboxedBooleanProperty = value;
167     }
168 
169     public char getCharacterProperty()
170     {
171         return this.characterProperty;
172     }
173 
174     public void setCharacterProperty( final char value )
175     {
176         this.characterProperty = value;
177     }
178 
179     public Character getBoxedCharacterProperty()
180     {
181         return this.boxedCharacterProperty;
182     }
183 
184     public void setBoxedCharacterProperty( final char value )
185     {
186         this.boxedCharacterProperty = value;
187     }
188 
189     public char getUnboxedCharacterProperty()
190     {
191         return this.unboxedCharacterProperty;
192     }
193 
194     public void setUnboxedCharacterProperty( final Character value )
195     {
196         this.unboxedCharacterProperty = value;
197     }
198 
199     public byte getByteProperty()
200     {
201         return this.byteProperty;
202     }
203 
204     public void setByteProperty( final byte value )
205     {
206         this.byteProperty = value;
207     }
208 
209     public Byte getBoxedByteProperty()
210     {
211         return this.boxedByteProperty;
212     }
213 
214     public void setBoxedByteProperty( final byte value )
215     {
216         this.boxedByteProperty = value;
217     }
218 
219     public byte getUnboxedByteProperty()
220     {
221         return this.unboxedByteProperty;
222     }
223 
224     public void setUnboxedByteProperty( final Byte value )
225     {
226         this.unboxedByteProperty = value;
227     }
228 
229     public short getShortProperty()
230     {
231         return this.shortProperty;
232     }
233 
234     public void setShortProperty( final short value )
235     {
236         this.shortProperty = value;
237     }
238 
239     public Short getBoxedShortProperty()
240     {
241         return this.boxedShortProperty;
242     }
243 
244     public void setBoxedShortProperty( final short value )
245     {
246         this.boxedShortProperty = value;
247     }
248 
249     public short getUnboxedShortProperty()
250     {
251         return this.unboxedShortProperty;
252     }
253 
254     public void setUnboxedShortProperty( final Short value )
255     {
256         this.unboxedShortProperty = value;
257     }
258 
259     public int getIntProperty()
260     {
261         return this.intProperty;
262     }
263 
264     public void setIntProperty( final int value )
265     {
266         this.intProperty = value;
267     }
268 
269     public Integer getBoxedIntProperty()
270     {
271         return this.boxedIntProperty;
272     }
273 
274     public void setBoxedIntProperty( final int value )
275     {
276         this.boxedIntProperty = value;
277     }
278 
279     public int getUnboxedIntProperty()
280     {
281         return this.unboxedIntProperty;
282     }
283 
284     public void setUnboxedIntProperty( final Integer value )
285     {
286         this.unboxedIntProperty = value;
287     }
288 
289     public long getLongProperty()
290     {
291         return this.longProperty;
292     }
293 
294     public void setLongProperty( final long value )
295     {
296         this.longProperty = value;
297     }
298 
299     public Long getBoxedLongProperty()
300     {
301         return this.boxedLongProperty;
302     }
303 
304     public void setBoxedLongProperty( final long value )
305     {
306         this.boxedLongProperty = value;
307     }
308 
309     public long getUnboxedLongProperty()
310     {
311         return this.unboxedLongProperty;
312     }
313 
314     public void setUnboxedLongProperty( final Long value )
315     {
316         this.unboxedLongProperty = value;
317     }
318 
319     public float getFloatProperty()
320     {
321         return this.floatProperty;
322     }
323 
324     public void setFloatProperty( final float value )
325     {
326         this.floatProperty = value;
327     }
328 
329     public Float getBoxedFloatProperty()
330     {
331         return this.boxedFloatProperty;
332     }
333 
334     public void setBoxedFloatProperty( final float value )
335     {
336         this.boxedFloatProperty = value;
337     }
338 
339     public float getUnboxedFloatProperty()
340     {
341         return this.unboxedFloatProperty;
342     }
343 
344     public void setUnboxedFloatProperty( final Float value )
345     {
346         this.unboxedFloatProperty = value;
347     }
348 
349     public double getDoubleProperty()
350     {
351         return this.doubleProperty;
352     }
353 
354     public void setDoubleProperty( final double value )
355     {
356         this.doubleProperty = value;
357     }
358 
359     public Double getBoxedDoubleProperty()
360     {
361         return this.boxedDoubleProperty;
362     }
363 
364     public void setBoxedDoubleProperty( final double value )
365     {
366         this.boxedDoubleProperty = value;
367     }
368 
369     public double getUnboxedDoubleProperty()
370     {
371         return this.unboxedDoubleProperty;
372     }
373 
374     public void setUnboxedDoubleProperty( final Double value )
375     {
376         this.unboxedDoubleProperty = value;
377     }
378 
379     public String getStringProperty()
380     {
381         return this.stringProperty;
382     }
383 
384     public void setStringProperty( final String value )
385     {
386         this.stringProperty = value;
387     }
388 
389     public String getStringPropertyWithoutSetter()
390     {
391         return this.stringPropertyWithoutSetter;
392     }
393 
394     public void setStringPropertyWithoutGetter( final String value )
395     {
396         this.stringPropertyWithoutGetter = value;
397     }
398 
399     public URL getUrlProperty()
400     {
401         return this.urlProperty;
402     }
403 
404     public void setUrlProperty( final URL value )
405     {
406         this.urlProperty = value;
407     }
408 
409     public Thread.State getEnumProperty()
410     {
411         return this.enumProperty;
412     }
413 
414     public void setEnumProperty( final Thread.State value )
415     {
416         this.enumProperty = value;
417     }
418 
419     public Object getObjectProperty()
420     {
421         return this.objectProperty;
422     }
423 
424     public void setObjectProperty( final Object value )
425     {
426         this.objectProperty = value;
427     }
428 
429     public Math getUnsupportedPropertyType()
430     {
431         return this.unsupportedPropertyType;
432     }
433 
434     public void setUnsupportedPropertyType( final Math value )
435     {
436         this.unsupportedPropertyType = value;
437     }
438 
439     public InstantiationExceptionPropertyType getInstantiationExceptionProperty()
440     {
441         return this.instantiationExceptionProperty;
442     }
443 
444     public void setInstantiationExceptionProperty( final InstantiationExceptionPropertyType value )
445     {
446         this.instantiationExceptionProperty = value;
447     }
448 
449     public InvocationTargetExceptionPropertyType getInvocationTargetExceptionProperty()
450     {
451         return this.invocationTargetExceptionProperty;
452     }
453 
454     public void setInvocationTargetExceptionProperty( final InvocationTargetExceptionPropertyType value )
455     {
456         this.invocationTargetExceptionProperty = value;
457     }
458 
459 }