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 3958 2011-11-18 22:32:23Z schulte2005 $
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:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
045 * @version $JOMC: TestModelProvider.java 3958 2011-11-18 22:32:23Z schulte2005 $
046 */
047public final class TestModelProvider implements ModelProvider
048{
049
050    private boolean booleanProperty;
051
052    private char characterProperty;
053
054    private byte byteProperty;
055
056    private short shortProperty;
057
058    private int intProperty;
059
060    private long longProperty;
061
062    private float floatProperty;
063
064    private double doubleProperty;
065
066    private String stringProperty;
067
068    private String stringPropertyWithoutSetter;
069
070    private String stringPropertyWithoutGetter;
071
072    private URL urlProperty;
073
074    private Thread.State enumProperty;
075
076    private Object objectProperty;
077
078    public TestModelProvider()
079    {
080        super();
081    }
082
083    public Model findModel( final ModelContext context, final Model model ) throws ModelException
084    {
085        if ( context == null )
086        {
087            throw new NullPointerException( "context" );
088        }
089        if ( model == null )
090        {
091            throw new NullPointerException( "model" );
092        }
093
094        context.setAttribute( TestModelProvider.class.getName(), this );
095
096        final Model created = model.clone();
097        created.getAny().add( new ObjectFactory().createTest( new TestComplexType() ) );
098        return created;
099    }
100
101    public boolean isBooleanProperty()
102    {
103        return this.booleanProperty;
104    }
105
106    public void setBooleanProperty( final boolean value )
107    {
108        this.booleanProperty = value;
109    }
110
111    public char getCharacterProperty()
112    {
113        return this.characterProperty;
114    }
115
116    public void setCharacterProperty( final char value )
117    {
118        this.characterProperty = value;
119    }
120
121    public byte getByteProperty()
122    {
123        return this.byteProperty;
124    }
125
126    public void setByteProperty( final byte value )
127    {
128        this.byteProperty = value;
129    }
130
131    public short getShortProperty()
132    {
133        return this.shortProperty;
134    }
135
136    public void setShortProperty( final short value )
137    {
138        this.shortProperty = value;
139    }
140
141    public int getIntProperty()
142    {
143        return this.intProperty;
144    }
145
146    public void setIntProperty( final int value )
147    {
148        this.intProperty = value;
149    }
150
151    public long getLongProperty()
152    {
153        return this.longProperty;
154    }
155
156    public void setLongProperty( final long value )
157    {
158        this.longProperty = value;
159    }
160
161    public float getFloatProperty()
162    {
163        return this.floatProperty;
164    }
165
166    public void setFloatProperty( final float value )
167    {
168        this.floatProperty = value;
169    }
170
171    public double getDoubleProperty()
172    {
173        return this.doubleProperty;
174    }
175
176    public void setDoubleProperty( final double value )
177    {
178        this.doubleProperty = value;
179    }
180
181    public String getStringProperty()
182    {
183        return this.stringProperty;
184    }
185
186    public void setStringProperty( final String value )
187    {
188        this.stringProperty = value;
189    }
190
191    public String getStringPropertyWithoutSetter()
192    {
193        return this.stringPropertyWithoutSetter;
194    }
195
196    public void setStringPropertyWithoutGetter( final String value )
197    {
198        this.stringPropertyWithoutGetter = value;
199    }
200
201    public URL getUrlProperty()
202    {
203        return this.urlProperty;
204    }
205
206    public void setUrlProperty( final URL value )
207    {
208        this.urlProperty = value;
209    }
210
211    public Thread.State getEnumProperty()
212    {
213        return this.enumProperty;
214    }
215
216    public void setEnumProperty( final Thread.State value )
217    {
218        this.enumProperty = value;
219    }
220
221    public Object getObjectProperty()
222    {
223        return this.objectProperty;
224    }
225
226    public void setObjectProperty( final Object value )
227    {
228        this.objectProperty = value;
229    }
230
231}