001: //--------------------------------------------------------------------------
002: // Copyright (c) 2004, Drew Davidson and Luke Blanshard
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 are
007: // met:
008: //
009: // Redistributions of source code must retain the above copyright notice,
010: // this list of conditions and the following disclaimer.
011: // Redistributions in binary form must reproduce the above copyright
012: // notice, this list of conditions and the following disclaimer in the
013: // documentation and/or other materials provided with the distribution.
014: // Neither the name of the Drew Davidson nor the names of its contributors
015: // may be used to endorse or promote products derived from this software
016: // without specific prior written permission.
017: //
018: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
019: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
020: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
021: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
022: // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
023: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
024: // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
025: // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
027: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
028: // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
029: // DAMAGE.
030: //--------------------------------------------------------------------------
031: package org.ognl.test.objects;
032:
033: import java.util.*;
034: import ognl.DynamicSubscript;
035:
036: public class Root extends Object {
037: public static final String SIZE_STRING = "size";
038: public static final int STATIC_INT = 23;
039:
040: private int[] array = { 1, 2, 3, 4 };
041: private Map map = new HashMap(23);
042: private MyMap myMap = new MyMapImpl();
043: private List list = Arrays
044: .asList(new Object[] { null, this , array });
045: private List settableList = new ArrayList(Arrays
046: .asList(new Object[] { "foo", "bar", "baz" }));
047: private int index = 1;
048: private int intValue = 0;
049: private String stringValue;
050: private int yetAnotherIntValue = 46;
051: private boolean privateAccessorBooleanValue = true;
052: private int privateAccessorIntValue = 67;
053: private int privateAccessorIntValue2 = 67;
054: private int privateAccessorIntValue3 = 67;
055: public String anotherStringValue = "foo";
056: public int anotherIntValue = 123;
057: public int six = 6;
058:
059: /*===================================================================
060: Public static methods
061: ===================================================================*/
062: public static int getStaticInt() {
063: return STATIC_INT;
064: }
065:
066: /*===================================================================
067: Constructors
068: ===================================================================*/
069: public Root() {
070: super ();
071: }
072:
073: /*===================================================================
074: Private methods
075: ===================================================================*/
076: {
077: map.put("test", this );
078: map.put("array", array);
079: map.put("list", list);
080: map.put("size", new Integer(5000));
081: map.put(DynamicSubscript.first, new Integer(99));
082:
083: /* make myMap identical */
084: myMap.putAll(map);
085: }
086:
087: private boolean isPrivateAccessorBooleanValue() {
088: return privateAccessorBooleanValue;
089: }
090:
091: private void setPrivateAccessorBooleanValue(boolean value) {
092: privateAccessorBooleanValue = value;
093: }
094:
095: private int getPrivateAccessorIntValue() {
096: return privateAccessorIntValue;
097: }
098:
099: private void setPrivateAccessorIntValue(int value) {
100: privateAccessorIntValue = value;
101: }
102:
103: /*===================================================================
104: Protected methods
105: ===================================================================*/
106: protected int getPrivateAccessorIntValue2() {
107: return privateAccessorIntValue2;
108: }
109:
110: protected void setPrivateAccessorIntValue2(int value) {
111: privateAccessorIntValue2 = value;
112: }
113:
114: /*===================================================================
115: Package protected methods
116: ===================================================================*/
117: int getPrivateAccessorIntValue3() {
118: return privateAccessorIntValue3;
119: }
120:
121: void setPrivateAccessorIntValue3(int value) {
122: privateAccessorIntValue3 = value;
123: }
124:
125: /*===================================================================
126: Public methods
127: ===================================================================*/
128: public int[] getArray() {
129: return array;
130: }
131:
132: public void setArray(int[] value) {
133: array = value;
134: }
135:
136: public Map getMap() {
137: return map;
138: }
139:
140: public MyMap getMyMap() {
141: return myMap;
142: }
143:
144: public List getList() {
145: return list;
146: }
147:
148: public List getSettableList() {
149: return settableList;
150: }
151:
152: public int getIndex() {
153: return index;
154: }
155:
156: public int getIntValue() {
157: return intValue;
158: }
159:
160: public void setIntValue(int value) {
161: intValue = value;
162: }
163:
164: public String getStringValue() {
165: return stringValue;
166: }
167:
168: public void setStringValue(String value) {
169: stringValue = value;
170: }
171:
172: public Object getNullObject() {
173: return null;
174: }
175: }
|