View Javadoc
1   package org.apache.commons.beanutils2.testbeans;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * 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, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  /**
24   * Just a java bean (JAJB) to try to replicate a reported bug
25   * Extracted from BeanUtils1
26   *
27   * @author Robert Burrell Donkin
28   * @version $Revision: 658830 $ $Date: 2008-05-21 21:56:21 +0200 (Wed, 21 May 2008) $
29   */
30  public class MappedPropertyTestBean
31  {
32  
33      // TODO generics
34      private final Map map = new HashMap();
35  
36      private final Map myMap = new HashMap();
37  
38      // -------------------------------------------------------------- Properties
39  
40      public String getMapproperty( String key )
41      {
42          return (String) map.get( key );
43      }
44  
45      public void setMapproperty( String key, String value )
46      {
47          map.put( key, value );
48      }
49  
50      public boolean isMappedBoolean( String key )
51      {
52          return ( (Boolean) map.get( key ) ).booleanValue();
53      }
54  
55      public void setMappedBoolean( String key, boolean value )
56      {
57          map.put( key, ( value ? Boolean.TRUE : Boolean.FALSE ) );
58      }
59  
60      protected String getProtectedMapped( String key )
61      {
62          return (String) map.get( key );
63      }
64  
65      protected void setProtectedMapped( String key, String value )
66      {
67          map.put( key, value );
68      }
69  
70      public void setMappedPrimitive( int key, int value )
71      {
72          map.put( new Integer( key ), new Integer( value ) );
73      }
74  
75      public void setAnyMapped( MappedPropertyTestBean key, MappedPropertyTestBean value )
76      {
77          map.put( key, value );
78      }
79  
80      public void setMappedSetterOnly( String key, String value )
81      {
82          map.put( key, value );
83      }
84  
85      public String getMappedGetterOnly( String key )
86      {
87          return (String) map.get( key );
88      }
89  
90      public String getInvalidGetter( String key, String other )
91      {
92          return (String) map.get( key );
93      }
94  
95      public Map getMyMap()
96      {
97          return myMap;
98      }
99  
100     public void setInvalidGetter( String key, String value )
101     {
102         map.put( key, value );
103     }
104 
105     public String getInvalidSetter( String key )
106     {
107         return (String) map.get( key );
108     }
109 
110     public void setInvalidSetter( String key, String value, String other )
111     {
112     }
113 
114     public Long getDifferentTypes( String key )
115     {
116         return new Long( ( (Number) map.get( key ) ).longValue() );
117     }
118 
119     public void setDifferentTypes( String key, Integer value )
120     {
121         map.put( key, value );
122     }
123 
124 }