1 /*
2 * $Id: Indexed.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 java.util.*;
23
24 public class Indexed
25 extends BaseIndexed
26 {
27 private String[] _values = new String[] { "foo", "bar", "baz" };
28
29 private List _list = new ArrayList();
30
31 private ListSource _source = new ListSourceImpl();
32
33 private Map _props = new HashMap();
34
35 public Indexed()
36 {
37 _list.add( new Integer( 1 ) );
38 _list.add( new Integer( 2 ) );
39 _list.add( new Integer( 3 ) );
40
41 _source.addValue( new Bean2() );
42 }
43
44 public Indexed( String[] values )
45 {
46 _values = values;
47 }
48
49 /* Indexed property "_values" */
50 public String[] getValues()
51 {
52 return _values;
53 }
54
55 public void setValues( String[] value )
56 {
57 _values = value;
58 }
59
60 /**
61 * This method returns the string from the array and appends "xxx" to distinguish the "get" method from the direct
62 * array access.
63 */
64 public String getValues( int index )
65 {
66 return _values[index] + "xxx";
67 }
68
69 public void setValues( int index, String value )
70 {
71 if ( value.endsWith( "xxx" ) )
72 {
73 _values[index] = value.substring( 0, value.length() - 3 );
74 }
75 else
76 {
77 _values[index] = value;
78 }
79 }
80
81 public Collection getList()
82 {
83 return _list;
84 }
85
86 public String getTitle( int count )
87 {
88 return "Title count " + count;
89 }
90
91 public ListSource getSource()
92 {
93 return _source;
94 }
95
96 public void setProperty( String property, Object value )
97 {
98 _props.put( property, value );
99 }
100
101 public Object getProperty( String property )
102 {
103 return _props.get( property );
104 }
105 }