View Javadoc

1   /*
2    * $Id: Simple.java 1103095 2011-05-14 13:18:29Z simonetripodi $
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  package org.apache.commons.ognl.test.objects;
21  
22  import org.apache.commons.ognl.test.OgnlTestCase;
23  
24  import java.math.BigDecimal;
25  import java.math.BigInteger;
26  import java.util.HashMap;
27  import java.util.Map;
28  
29  public class Simple
30      extends Object
31  {
32      private String stringValue = "test";
33  
34      private float floatValue;
35  
36      private int intValue;
37  
38      private boolean booleanValue;
39  
40      private BigInteger bigIntValue = BigInteger.valueOf( 0 );
41  
42      private BigDecimal bigDecValue = new BigDecimal( 0.0 );
43  
44      private Root root = new Root();
45  
46      private Bean3 _bean;
47  
48      private Bean2 _bean2;
49  
50      private Object[] _array;
51  
52      private Messages _messages;
53  
54      public Simple()
55      {
56          Map src = new HashMap();
57          src.put( "test", "This is a test" );
58  
59          _messages = new Messages( src );
60      }
61  
62      public Simple( Bean3 bean )
63      {
64          _bean = bean;
65      }
66  
67      public Simple( Bean2 bean )
68      {
69          _bean2 = bean;
70      }
71  
72      public Simple( Object[] values )
73      {
74          super();
75      }
76  
77      public Simple( String stringValue, float floatValue, int intValue )
78      {
79          super();
80          this.stringValue = stringValue;
81          this.floatValue = floatValue;
82          this.intValue = intValue;
83      }
84  
85      public void setValues( String stringValue, float floatValue, int intValue )
86      {
87          this.stringValue = stringValue;
88          this.floatValue = floatValue;
89          this.intValue = intValue;
90      }
91  
92      public String getStringValue()
93      {
94          return stringValue;
95      }
96  
97      public void setStringValue( String value )
98      {
99          stringValue = value;
100     }
101 
102     public float getFloatValue()
103     {
104         return floatValue;
105     }
106 
107     public void setFloatValue( float value )
108     {
109         floatValue = value;
110     }
111 
112     public int getIntValue()
113     {
114         return intValue;
115     }
116 
117     public void setIntValue( int value )
118     {
119         intValue = value;
120     }
121 
122     public boolean getValueIsTrue( Object currValue )
123     {
124         return true;
125     }
126 
127     public boolean getBooleanValue()
128     {
129         return booleanValue;
130     }
131 
132     public void setBooleanValue( boolean value )
133     {
134         booleanValue = value;
135     }
136 
137     public BigInteger getBigIntValue()
138     {
139         return bigIntValue;
140     }
141 
142     public void setArray( Object[] values )
143     {
144         _array = values;
145     }
146 
147     public Object[] getArray()
148     {
149         return _array;
150     }
151 
152     public void setBigIntValue( BigInteger value )
153     {
154         bigIntValue = value;
155     }
156 
157     public BigDecimal getBigDecValue()
158     {
159         return bigDecValue;
160     }
161 
162     public void setBigDecValue( BigDecimal value )
163     {
164         bigDecValue = value;
165     }
166 
167     public Root getRootValue()
168     {
169         return root;
170     }
171 
172     public Messages getMessages()
173     {
174         return _messages;
175     }
176 
177     public int getOne()
178     {
179         return 1;
180     }
181 
182     public int getTwo()
183     {
184         return 2;
185     }
186 
187     public int getThree()
188     {
189         return 3;
190     }
191 
192     public int getTestValue( int val )
193     {
194         return val + 1;
195     }
196 
197     public boolean isEditorDisabled()
198     {
199         return false;
200     }
201 
202     public boolean isDisabled()
203     {
204         return true;
205     }
206 
207     public GetterMethods getMethodsTest()
208     {
209         return new GetterMethods();
210     }
211 
212     public String getDisplayValue( int val )
213     {
214         return "test";
215     }
216 
217     public boolean equals( Object other )
218     {
219         boolean result = false;
220 
221         if ( other instanceof Simple )
222         {
223             Simple os = (Simple) other;
224 
225             result =
226                 OgnlTestCase.isEqual( os.getStringValue(), getStringValue() ) && ( os.getIntValue() == getIntValue() );
227         }
228         return result;
229     }
230 
231     public boolean isThisVarArgsWorking( Object... arguments )
232     {
233         return true;
234     }
235 }