001package org.apache.commons.beanutils2.testbeans;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one or more
005 * contributor license agreements.  See the NOTICE file distributed with
006 * this work for additional information regarding copyright ownership.
007 * The ASF licenses this file to You under the Apache License, Version 2.0
008 * (the "License"); you may not use this file except in compliance with
009 * the License.  You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020import java.util.HashMap;
021import java.util.Map;
022
023/**
024 * Just a java bean (JAJB) to try to replicate a reported bug
025 * Extracted from BeanUtils1
026 *
027 * @author Robert Burrell Donkin
028 * @version $Revision: 658830 $ $Date: 2008-05-21 21:56:21 +0200 (Wed, 21 May 2008) $
029 */
030public class MappedPropertyTestBean
031{
032
033    // TODO generics
034    private final Map map = new HashMap();
035
036    private final Map myMap = new HashMap();
037
038    // -------------------------------------------------------------- Properties
039
040    public String getMapproperty( String key )
041    {
042        return (String) map.get( key );
043    }
044
045    public void setMapproperty( String key, String value )
046    {
047        map.put( key, value );
048    }
049
050    public boolean isMappedBoolean( String key )
051    {
052        return ( (Boolean) map.get( key ) ).booleanValue();
053    }
054
055    public void setMappedBoolean( String key, boolean value )
056    {
057        map.put( key, ( value ? Boolean.TRUE : Boolean.FALSE ) );
058    }
059
060    protected String getProtectedMapped( String key )
061    {
062        return (String) map.get( key );
063    }
064
065    protected void setProtectedMapped( String key, String value )
066    {
067        map.put( key, value );
068    }
069
070    public void setMappedPrimitive( int key, int value )
071    {
072        map.put( new Integer( key ), new Integer( value ) );
073    }
074
075    public void setAnyMapped( MappedPropertyTestBean key, MappedPropertyTestBean value )
076    {
077        map.put( key, value );
078    }
079
080    public void setMappedSetterOnly( String key, String value )
081    {
082        map.put( key, value );
083    }
084
085    public String getMappedGetterOnly( String key )
086    {
087        return (String) map.get( key );
088    }
089
090    public String getInvalidGetter( String key, String other )
091    {
092        return (String) map.get( key );
093    }
094
095    public Map getMyMap()
096    {
097        return myMap;
098    }
099
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}