001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry.enhance;
016
017import java.util.HashMap;
018import java.util.Map;
019
020/**
021 *  @author Mindbridge
022 *  @since 3.0
023 */
024public class JavaClassMapping
025{
026
027    /**
028     *  Map of type (as Class), keyed on type name. 
029     * 
030     */
031
032    private Map _typeMap = new HashMap();
033
034    {
035        recordType("boolean", boolean.class);
036        recordType("boolean[]", boolean[].class);
037
038        recordType("short", short.class);
039        recordType("short[]", short[].class);
040
041        recordType("int", int.class);
042        recordType("int[]", int[].class);
043
044        recordType("long", long.class);
045        recordType("long[]", long[].class);
046
047        recordType("float", float.class);
048        recordType("float[]", float[].class);
049
050        recordType("double", double.class);
051        recordType("double[]", double[].class);
052
053        recordType("char", char.class);
054        recordType("char[]", char[].class);
055
056        recordType("byte", byte.class);
057        recordType("byte[]", byte[].class);
058
059        recordType("java.lang.Object", Object.class);
060        recordType("java.lang.Object[]", Object[].class);
061
062        recordType("java.lang.String", String.class);
063        recordType("java.lang.String[]", String[].class);
064    }
065
066    public void recordType(String name, Class type)
067    {
068        _typeMap.put(name, type);
069    }
070
071    public Class getType(String name)
072    {
073        return (Class) _typeMap.get(name);
074    }
075
076}