001/*
002 *   Copyright (C) Christian Schulte, 2005-206
003 *   All rights reserved.
004 *
005 *   Redistribution and use in source and binary forms, with or without
006 *   modification, are permitted provided that the following conditions
007 *   are met:
008 *
009 *     o Redistributions of source code must retain the above copyright
010 *       notice, this list of conditions and the following disclaimer.
011 *
012 *     o Redistributions in binary form must reproduce the above copyright
013 *       notice, this list of conditions and the following disclaimer in
014 *       the documentation and/or other materials provided with the
015 *       distribution.
016 *
017 *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
018 *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
019 *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
020 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
021 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
022 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
023 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
024 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
026 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027 *
028 *   $JOMC: TestModelProvider.java 4654 2012-11-15 22:28:26Z schulte $
029 *
030 */
031package org.jomc.modlet.test.support;
032
033import java.net.URL;
034import org.jomc.modlet.Model;
035import org.jomc.modlet.ModelContext;
036import org.jomc.modlet.ModelException;
037import org.jomc.modlet.ModelProvider;
038import org.jomc.modlet.test.ObjectFactory;
039import org.jomc.modlet.test.TestComplexType;
040
041/**
042 * {@code ModelProvider} test implementation.
043 *
044 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
045 * @version $JOMC: TestModelProvider.java 4654 2012-11-15 22:28:26Z schulte $
046 */
047public final class TestModelProvider implements ModelProvider
048{
049
050    private boolean booleanProperty;
051
052    private boolean boxedBooleanProperty;
053
054    private Boolean unboxedBooleanProperty;
055
056    private char characterProperty;
057
058    private char boxedCharacterProperty;
059
060    private Character unboxedCharacterProperty;
061
062    private byte byteProperty;
063
064    private byte boxedByteProperty;
065
066    private Byte unboxedByteProperty;
067
068    private short shortProperty;
069
070    private short boxedShortProperty;
071
072    private Short unboxedShortProperty;
073
074    private int intProperty;
075
076    private int boxedIntProperty;
077
078    private Integer unboxedIntProperty;
079
080    private long longProperty;
081
082    private long boxedLongProperty;
083
084    private Long unboxedLongProperty;
085
086    private float floatProperty;
087
088    private float boxedFloatProperty;
089
090    private Float unboxedFloatProperty;
091
092    private double doubleProperty;
093
094    private double boxedDoubleProperty;
095
096    private Double unboxedDoubleProperty;
097
098    private String stringProperty;
099
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}