    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.Jira61TestCase;
    23
    24  /***
    25   * Factory which creates beans for {@link Jira61TestCase}.
    26   *
    27   * @version $Revision: 553357 $ $Date: 2007-07-05 02:10:25 +0100 (Thu, 05 Jul 2007) $
    28   */
    29  public class Jira61BeanFactory {
    30
    31      /***
    32       * Factory method which creates a new {@link TestBean}.
    33       *
    34       * @return a new {@link TestBean}.
    35       */
    36      public static TestBean createBean() {
    37          return new TestBean();
    38      }
    39
    40      /***
    41       * Test Bean
    42       */
    43      public static class TestBean {
    44
    45          private String[] indexed = new String[] {"one", "two", "three"};
    46          private String simple = "FOO";
    47          private Map mapped = new HashMap();
    48
    49          /*** Default Constructor */
    50          public TestBean() {
    51              mapped.put("foo-key", "foo-value");
    52              mapped.put("bar-key", "bar-value");
    53          }
    54
    55          /***
    56           * Return simpleReadOnly
    57           *
    58           * @return the simple value
    59           */
    60          public String getSimpleReadOnly() {
    61              return simple;
    62          }
    63
    64          /***
    65           * Set simpleWriteOnly
    66           *
    67           * @param simple simple value
    68           */
    69          public void setSimpleWriteOnly(String simple) {
    70              this.simple = simple;
    71          }
    72
    73          /***
    74           * Return indexed property.
    75           *
    76           * @param index The index
    77           * @return The indexed value
    78           */
    79          public String getIndexedReadOnly(int index) {
    80              return indexed[index];
    81          }
    82
    83          /***
    84           * Set indexed property.
    85           *
    86           * @param index The index
    87           * @param value The indexed value
    88           */
    89          public void setIndexedWriteOnly(int index, String value) {
    90              this.indexed[index] = value;
    91          }
    92
    93          /***
    94           * Return mapped property.
    95           *
    96           * @param key The mapped key
    97           * @return The mapped value
    98           */
    99          public String getMappedReadOnly(String key) {
    100             return (String)mapped.get(key);
    101         }
    102
    103         /***
    104          * Set mapped property.
    105          *
    106          * @param key The mapped key
    107          * @param value The mapped value
    108          */
    109         public void setMappedWriteOnly(String key, String value) {
    110             mapped.put(key, value);
    111         }
    112
    113     }
    114
    115 }