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 3958 2011-11-18 22:32:23Z schulte2005 $
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:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
45   * @version $JOMC: TestModelProvider.java 3958 2011-11-18 22:32:23Z schulte2005 $
46   */
47  public final class TestModelProvider implements ModelProvider
48  {
49  
50      private boolean booleanProperty;
51  
52      private char characterProperty;
53  
54      private byte byteProperty;
55  
56      private short shortProperty;
57  
58      private int intProperty;
59  
60      private long longProperty;
61  
62      private float floatProperty;
63  
64      private double doubleProperty;
65  
66      private String stringProperty;
67  
68      private String stringPropertyWithoutSetter;
69  
70      private String stringPropertyWithoutGetter;
71  
72      private URL urlProperty;
73  
74      private Thread.State enumProperty;
75  
76      private Object objectProperty;
77  
78      public TestModelProvider()
79      {
80          super();
81      }
82  
83      public Model findModel( final ModelContext context, final Model model ) throws ModelException
84      {
85          if ( context == null )
86          {
87              throw new NullPointerException( "context" );
88          }
89          if ( model == null )
90          {
91              throw new NullPointerException( "model" );
92          }
93  
94          context.setAttribute( TestModelProvider.class.getName(), this );
95  
96          final Model created = model.clone();
97          created.getAny().add( new ObjectFactory().createTest( new TestComplexType() ) );
98          return created;
99      }
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 }