1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.beanutils.bugs.other;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.apache.commons.beanutils.bugs.Jira18TestCase;
23  
24  /***
25   * Factory whcih creates <i>package</i> scope beans with
26   * public methods for {@link Jira18TestCase}.
27   * 
28   * @version $Revision: 556237 $ $Date: 2007-07-14 08:27:18 +0100 (Sat, 14 Jul 2007) $
29   */
30  public class Jira18BeanFactory {
31  
32      /***
33       * Factory method which creates package friendly beans.
34       *
35       * @return The a package friendly bean with public methods
36       */
37      public static Object createBean() {
38          return new PackageFriendlyBean();
39      }
40  
41      /* =============== Package Friendly Bean =============== */
42      static class PackageFriendlyBean {
43  
44          private String[] indexed = new String[] {"one", "two", "three"};
45          private String simple = "FOO";
46          private Map mapped = new HashMap();
47  
48          /*** Default Constructor */
49          public PackageFriendlyBean() {
50              mapped.put("foo-key", "foo-value");
51              mapped.put("bar-key", "bar-value");
52          }
53          /***
54           * Return simple property.
55           * 
56           * @return The simple value
57           */
58          public String getSimple() {
59              return simple;
60          }
61  
62          /***
63           * Set simple property.
64           * 
65           * @param simple The simple value
66           */
67          public void setSimple(String simple) {
68              this.simple = simple;
69          }
70  
71          /***
72           * Return indexed property.
73           * 
74           * @param index The index
75           * @return The indexed value
76           */
77          public String getIndexed(int index) {
78              return indexed[index];
79          }
80  
81          /***
82           * Set indexed property.
83           * 
84           * @param index The index
85           * @param value The indexed value
86           */
87          public void setIndexed(int index, String value) {
88              this.indexed[index] = value;
89          }
90  
91          /***
92           * Return mapped property.
93           * 
94           * @param key The mapped key
95           * @return The mapped value
96           */
97          public String getMapped(String key) {
98              return (String)mapped.get(key);
99          }
100 
101         /***
102          * Set mapped property.
103          * 
104          * @param key The mapped key
105          * @param value The mapped value
106          */
107         public void setMapped(String key, String value) {
108             mapped.put(key, value);
109         }
110 
111     }
112 
113 }