01: package com.silvermindsoftware.hitch.handlers;
02:
03: /**
04: * Copyright 2007 Brandon Goodin
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import com.silvermindsoftware.hitch.handlers.type.*;
20:
21: import java.util.Date;
22: import java.util.HashMap;
23: import java.util.Map;
24: import java.math.BigDecimal;
25:
26: public class TypeHandlerFactory {
27:
28: private Map<Object, TypeHandler> typeHandler;
29:
30: public TypeHandlerFactory() {
31:
32: this .typeHandler = new HashMap<Object, TypeHandler>();
33: register(String.class, new StringTypeHandler());
34: register(Integer.class, new IntegerTypeHandler());
35: register(Long.class, new LongTypeHandler());
36: register(Float.class, new FloatTypeHandler());
37: register(Double.class, new DoubleTypeHandler());
38: register(Date.class, new DateTypeHandler());
39: register(BigDecimal.class, new BigDecimalTypeHandler());
40:
41: }
42:
43: public void register(Object key, TypeHandler componentHandler) {
44: this .typeHandler.put(key, componentHandler);
45: }
46:
47: public TypeHandler getHandler(Object key) {
48: return typeHandler.get(key);
49: }
50:
51: }
|