001 /* 002 * $Id: Root.java 1188000 2011-10-23 23:10:24Z mcucchiara $ 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 package org.apache.commons.ognl.test.objects; 021 022 import org.apache.commons.ognl.DynamicSubscript; 023 024 import java.util.ArrayList; 025 import java.util.Arrays; 026 import java.util.Date; 027 import java.util.HashMap; 028 import java.util.List; 029 import java.util.Locale; 030 import java.util.Map; 031 032 public class Root 033 { 034 public static final String SIZE_STRING = "size"; 035 036 public static final int STATIC_INT = 23; 037 038 private int[] array = { 1, 2, 3, 4 }; 039 040 private Map map = new HashMap( 23 ); 041 042 private MyMap myMap = new MyMapImpl(); 043 044 private List list = Arrays.asList( new Object[] { null, this, array } ); 045 046 private List settableList = new ArrayList( Arrays.asList( new Object[] { "foo", "bar", "baz" } ) ); 047 048 private int index = 1; 049 050 private int intValue = 0; 051 052 private String stringValue; 053 054 private int yetAnotherIntValue = 46; 055 056 private boolean privateAccessorBooleanValue = true; 057 058 private int privateAccessorIntValue = 67; 059 060 private int privateAccessorIntValue2 = 67; 061 062 private int privateAccessorIntValue3 = 67; 063 064 public String anotherStringValue = "foo"; 065 066 public int anotherIntValue = 123; 067 068 public int six = 6; 069 070 private boolean _disabled; 071 072 private Locale _selected = Locale.getDefault(); 073 074 private List<List<Boolean>> _booleanValues = new ArrayList<List<Boolean>>(); 075 076 private boolean[] _booleanArray = { true, false, true, true }; 077 078 private List _list; 079 080 private int verbosity = 87; 081 082 private BeanProvider _beanProvider = new BeanProviderImpl(); 083 084 private boolean _render; 085 086 private Boolean _readOnly = Boolean.FALSE; 087 088 private Integer _objIndex = new Integer( 1 ); 089 090 private Object _genericObjIndex = new Integer( 2 ); 091 092 private Date _date = new Date(); 093 094 private boolean _openWindow = false; 095 096 private ITreeContentProvider _contentProvider = new TreeContentProvider(); 097 098 private Indexed _indexed = new Indexed(); 099 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 }