1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  package org.apache.commons.jxpath;
19  
20  import java.util.ArrayList;
21  import java.util.HashMap;
22  import java.util.HashSet;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Set;
26  
27  import org.apache.commons.jxpath.util.ValueUtils;
28  
29  
30  
31  
32  public class TestBean {
33  
34      
35  
36  
37      private NestedTestBean[] beans;
38      {
39          beans = new NestedTestBean[2];
40          beans[0] = new NestedTestBean("Name 1");
41          beans[1] = new NestedTestBean("Name 2");
42          beans[1].setInt(3);
43      }
44      
45  
46  
47      private boolean bool = false;
48      private int integer = 1;
49      
50  
51  
52      private int[] array = { 1, 2, 3, 4 };
53      
54  
55  
56      private ArrayList list;
57      
58  
59  
60      private HashMap map;
61      {
62          map = new HashMap();
63          map.put("Key1", "Value 1");
64          map.put("Key2", new NestedTestBean("Name 6"));
65      }
66      
67  
68  
69      private NestedTestBean nestedBean = new NestedTestBean("Name 0");
70      private final NestedTestBean object = new NestedTestBean("Name 5");
71      
72  
73  
74      private HashSet set;
75  
76      public NestedTestBean[] getBeans() {
77          return beans;
78      }
79  
80      
81  
82  
83      public int getInt() {
84          return integer;
85      }
86  
87      public int[] getIntegers() {
88          return array;
89      }
90  
91      public int getIntegers(final int index) {
92          return array[index];
93      }
94  
95      public List getList() {
96          if (list == null) {
97              list = new ArrayList();
98              list.add("String 3");
99              list.add(Integer.valueOf(3));
100             list.add(new NestedTestBean("Name 3"));
101         }
102         return list;
103     }
104 
105     public Map getMap() {
106         return map;
107     }
108 
109     public NestedTestBean getNestedBean() {
110         return nestedBean;
111     }
112 
113     
114 
115 
116     public Object getObject() {
117         return object;
118     }
119 
120     
121 
122 
123     public Object getObjects() {
124         return getIntegers();
125     }
126 
127     public Set getSet() {
128         if (set == null) {
129             set = new HashSet();
130             set.add("String 4");
131             set.add(Integer.valueOf(4));
132             set.add(new NestedTestBean("Name 4"));
133         }
134         return set;
135     }
136 
137     public boolean isBoolean() {
138         return bool;
139     }
140 
141     public void setBeans(final NestedTestBean[] beans) {
142         this.beans = beans;
143     }
144 
145     public void setBoolean(final boolean bool) {
146         this.bool = bool;
147     }
148 
149     public void setInt(final int integer) {
150         this.integer = integer;
151     }
152 
153     public void setIntegers(final int index, final int value) {
154         if (index >= array.length) {
155             array = (int[]) ValueUtils.expandCollection(array, index + 1);
156         }
157         array[index] = value;
158     }
159 
160     public void setMap(final Map map) {
161         this.map = (HashMap) map;
162     }
163 
164     public void setNestedBean(final NestedTestBean bean) {
165         this.nestedBean = bean;
166     }
167 
168     @Override
169     public String toString() {
170         return "ROOT";
171     }
172 }