View Javadoc

1   /*
2    * $Id: Root.java 1188000 2011-10-23 23:10:24Z mcucchiara $
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.DynamicSubscript;
23  
24  import java.util.ArrayList;
25  import java.util.Arrays;
26  import java.util.Date;
27  import java.util.HashMap;
28  import java.util.List;
29  import java.util.Locale;
30  import java.util.Map;
31  
32  public class Root
33  {
34      public static final String SIZE_STRING = "size";
35  
36      public static final int STATIC_INT = 23;
37  
38      private int[] array = { 1, 2, 3, 4 };
39  
40      private Map map = new HashMap( 23 );
41  
42      private MyMap myMap = new MyMapImpl();
43  
44      private List list = Arrays.asList( new Object[] { null, this, array } );
45  
46      private List settableList = new ArrayList( Arrays.asList( new Object[] { "foo", "bar", "baz" } ) );
47  
48      private int index = 1;
49  
50      private int intValue = 0;
51  
52      private String stringValue;
53  
54      private int yetAnotherIntValue = 46;
55  
56      private boolean privateAccessorBooleanValue = true;
57  
58      private int privateAccessorIntValue = 67;
59  
60      private int privateAccessorIntValue2 = 67;
61  
62      private int privateAccessorIntValue3 = 67;
63  
64      public String anotherStringValue = "foo";
65  
66      public int anotherIntValue = 123;
67  
68      public int six = 6;
69  
70      private boolean _disabled;
71  
72      private Locale _selected = Locale.getDefault();
73  
74      private List<List<Boolean>> _booleanValues = new ArrayList<List<Boolean>>();
75  
76      private boolean[] _booleanArray = { true, false, true, true };
77  
78      private List _list;
79  
80      private int verbosity = 87;
81  
82      private BeanProvider _beanProvider = new BeanProviderImpl();
83  
84      private boolean _render;
85  
86      private Boolean _readOnly = Boolean.FALSE;
87  
88      private Integer _objIndex = new Integer( 1 );
89  
90      private Object _genericObjIndex = new Integer( 2 );
91  
92      private Date _date = new Date();
93  
94      private boolean _openWindow = false;
95  
96      private ITreeContentProvider _contentProvider = new TreeContentProvider();
97  
98      private Indexed _indexed = new Indexed();
99  
100     private SearchTab _tab = new SearchTab();
101 
102     /*
103      * =================================================================== Public static methods
104      * ===================================================================
105      */
106     public static int getStaticInt()
107     {
108         return STATIC_INT;
109     }
110 
111     /*
112      * =================================================================== Constructors
113      * ===================================================================
114      */
115     public Root()
116     {
117         super();
118     }
119 
120     /*
121      * =================================================================== Private methods
122      * ===================================================================
123      */
124     {
125         map.put( "test", this );
126         map.put( "array", array );
127         map.put( "list", list );
128         map.put( "size", new Integer( 5000 ) );
129         map.put( DynamicSubscript.first, new Integer( 99 ) );
130         map.put( "baz", array );
131         map.put( "value", new Bean2() );
132         map.put( "bar", new Bean3() );
133         map.put( new Long( 82 ), "StringStuff=someValue" );
134 
135         IFormComponent comp = new FormComponentImpl();
136         comp.setClientId( "formComponent" );
137 
138         IForm form = new FormImpl();
139         form.setClientId( "form1" );
140         comp.setForm( form );
141 
142         map.put( "comp", comp );
143 
144         Map newMap = new HashMap();
145         Map chain = new HashMap();
146         newMap.put( "deep", chain );
147 
148         chain.put( "last", Boolean.TRUE );
149 
150         map.put( "nested", newMap );
151 
152         /* make myMap identical */
153         myMap.putAll( map );
154 
155         List<Boolean> bool1 = new ArrayList<Boolean>();
156         bool1.add( Boolean.TRUE );
157         bool1.add( Boolean.FALSE );
158         bool1.add( Boolean.TRUE );
159 
160         _booleanValues.add( bool1 );
161 
162         List<Boolean> bool2 = new ArrayList<Boolean>();
163         bool2.add( Boolean.TRUE );
164         bool2.add( Boolean.FALSE );
165         bool2.add( Boolean.TRUE );
166 
167         _booleanValues.add( bool2 );
168     }
169 
170     private boolean isPrivateAccessorBooleanValue()
171     {
172         return privateAccessorBooleanValue;
173     }
174 
175     private void setPrivateAccessorBooleanValue( boolean value )
176     {
177         privateAccessorBooleanValue = value;
178     }
179 
180     private int getPrivateAccessorIntValue()
181     {
182         return privateAccessorIntValue;
183     }
184 
185     private void setPrivateAccessorIntValue( int value )
186     {
187         privateAccessorIntValue = value;
188     }
189 
190     /*
191      * =================================================================== Protected methods
192      * ===================================================================
193      */
194     protected int getPrivateAccessorIntValue2()
195     {
196         return privateAccessorIntValue2;
197     }
198 
199     protected void setPrivateAccessorIntValue2( int value )
200     {
201         privateAccessorIntValue2 = value;
202     }
203 
204     /*
205      * =================================================================== Package protected methods
206      * ===================================================================
207      */
208     int getPrivateAccessorIntValue3()
209     {
210         return privateAccessorIntValue3;
211     }
212 
213     void setPrivateAccessorIntValue3( int value )
214     {
215         privateAccessorIntValue3 = value;
216     }
217 
218     /*
219      * =================================================================== Public methods
220      * ===================================================================
221      */
222     public int[] getArray()
223     {
224         return array;
225     }
226 
227     public boolean[] getBooleanArray()
228     {
229         return _booleanArray;
230     }
231 
232     public void setArray( int[] value )
233     {
234         array = value;
235     }
236 
237     public String format( String key, Object value )
238     {
239         return format( key, new Object[] { value } );
240     }
241 
242     public String format( String key, Object[] value )
243     {
244         return "formatted";
245     }
246 
247     public String getCurrentClass( String value )
248     {
249         return value + " stop";
250     }
251 
252     public Messages getMessages()
253     {
254         return new Messages( map );
255     }
256 
257     public Map getMap()
258     {
259         return map;
260     }
261 
262     public MyMap getMyMap()
263     {
264         return myMap;
265     }
266 
267     public List getList()
268     {
269         return list;
270     }
271 
272     public Object getAsset( String key )
273     {
274         return key;
275     }
276 
277     public List getSettableList()
278     {
279         return settableList;
280     }
281 
282     public int getIndex()
283     {
284         return index;
285     }
286 
287     public Integer getObjectIndex()
288     {
289         return _objIndex;
290     }
291 
292     public Integer getNullIndex()
293     {
294         return null;
295     }
296 
297     public Object getGenericIndex()
298     {
299         return _genericObjIndex;
300     }
301 
302     public int getIntValue()
303     {
304         return intValue;
305     }
306 
307     public void setIntValue( int value )
308     {
309         intValue = value;
310     }
311 
312     public int getTheInt()
313     {
314         return six;
315     }
316 
317     public String getStringValue()
318     {
319         return stringValue;
320     }
321 
322     public void setStringValue( String value )
323     {
324         stringValue = value;
325     }
326 
327     public String getIndexedStringValue()
328     {
329         return "array";
330     }
331 
332     public Object getNullObject()
333     {
334         return null;
335     }
336 
337     public String getTestString()
338     {
339         return "wiggle";
340     }
341 
342     public Object getProperty()
343     {
344         return new Bean2();
345     }
346 
347     public Bean2 getBean2()
348     {
349         return new Bean2();
350     }
351 
352     public Object getIndexedProperty( String name )
353     {
354         return myMap.get( name );
355     }
356 
357     public Indexed getIndexer()
358     {
359         return _indexed;
360     }
361 
362     public BeanProvider getBeans()
363     {
364         return _beanProvider;
365     }
366 
367     public boolean getBooleanValue()
368     {
369         return _disabled;
370     }
371 
372     public void setBooleanValue( boolean value )
373     {
374         _disabled = value;
375     }
376 
377     public boolean getDisabled()
378     {
379         return _disabled;
380     }
381 
382     public void setDisabled( boolean disabled )
383     {
384         _disabled = disabled;
385     }
386 
387     public Locale getSelected()
388     {
389         return _selected;
390     }
391 
392     public void setSelected( Locale locale )
393     {
394         _selected = locale;
395     }
396 
397     public Locale getCurrLocale()
398     {
399         return Locale.getDefault();
400     }
401 
402     public int getCurrentLocaleVerbosity()
403     {
404         return verbosity;
405     }
406 
407     public boolean getRenderNavigation()
408     {
409         return _render;
410     }
411 
412     public void setSelectedList( List selected )
413     {
414         _list = selected;
415     }
416 
417     public List getSelectedList()
418     {
419         return _list;
420     }
421 
422     public Boolean getReadonly()
423     {
424         return _readOnly;
425     }
426 
427     public void setReadonly( Boolean value )
428     {
429         _readOnly = value;
430     }
431 
432     public Object getSelf()
433     {
434         return this;
435     }
436 
437     public Date getTestDate()
438     {
439         return _date;
440     }
441 
442     public String getWidth()
443     {
444         return "238px";
445     }
446 
447     public Long getTheLong()
448     {
449         return new Long( 4 );
450     }
451 
452     public boolean isSorted()
453     {
454         return true;
455     }
456 
457     public TestClass getMyTest()
458     {
459         return new TestImpl();
460     }
461 
462     public ITreeContentProvider getContentProvider()
463     {
464         return _contentProvider;
465     }
466 
467     public boolean isPrintDelivery()
468     {
469         return true;
470     }
471 
472     public Long getCurrentDeliveryId()
473     {
474         return 1l;
475     }
476 
477     public Boolean isFlyingMonkey()
478     {
479         return Boolean.TRUE;
480     }
481 
482     public Boolean isDumb()
483     {
484         return Boolean.FALSE;
485     }
486 
487     public Date getExpiration()
488     {
489         return null;
490     }
491 
492     public Long getMapKey()
493     {
494         return new Long( 82 );
495     }
496 
497     public Object getArrayValue()
498     {
499         return new Object[] { new Integer( "2" ), new Integer( "2" ) };
500     }
501 
502     public List getResult()
503     {
504         List list = new ArrayList();
505         list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
506         list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
507         list.add( new Object[] { new Integer( "2" ), new Integer( "2" ) } );
508 
509         return list;
510     }
511 
512     public boolean isEditorDisabled()
513     {
514         return false;
515     }
516 
517     public boolean isDisabled()
518     {
519         return true;
520     }
521 
522     public boolean isOpenTransitionWin()
523     {
524         return _openWindow;
525     }
526 
527     public void setOpenTransitionWin( boolean value )
528     {
529         _openWindow = value;
530     }
531 
532     public boolean isOk( SimpleEnum value, String otherValue )
533     {
534         return true;
535     }
536 
537     public List<List<Boolean>> getBooleanValues()
538     {
539         return _booleanValues;
540     }
541 
542     public int getIndex1()
543     {
544         return 1;
545     }
546 
547     public int getIndex2()
548     {
549         return 1;
550     }
551 
552     public SearchTab getTab()
553     {
554         return _tab;
555     }
556 
557     public void setTab( SearchTab tab )
558     {
559         _tab = tab;
560     }
561 
562     public static class A
563     {
564         public int methodOfA( B b )
565         {
566             return 0;
567         }
568 
569         public int getIntValue()
570         {
571             return 1;
572         }
573     }
574 
575     public static class B
576     {
577         public int methodOfB( int i )
578         {
579             return 0;
580         }
581     }
582 
583     public A getA()
584     {
585         return new A();
586     }
587 
588     public B getB()
589     {
590         return new B();
591     }
592 }