%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DefaultAtomicTypeConverterProvider |
|
|
1 | /* |
|
2 | * Copyright 2004-2005 The Apache Software Foundation or its licensors, |
|
3 | * as applicable. |
|
4 | * |
|
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 | * you may not use this file except in compliance with the License. |
|
7 | * 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.portals.graffito.jcr.persistence.atomictypeconverter.impl; |
|
18 | ||
19 | import java.io.InputStream; |
|
20 | import java.sql.Timestamp; |
|
21 | import java.util.Calendar; |
|
22 | import java.util.Date; |
|
23 | import java.util.GregorianCalendar; |
|
24 | import java.util.HashMap; |
|
25 | import java.util.Map; |
|
26 | ||
27 | ||
28 | /** |
|
29 | * An <code>AtomicTypeConverterProvider</code> that registers by default the |
|
30 | * convertes available in Graffito. |
|
31 | * |
|
32 | * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a> |
|
33 | */ |
|
34 | public class DefaultAtomicTypeConverterProvider extends AtomicTypeConverterProviderImpl { |
|
35 | /** |
|
36 | * No-arg constructor. |
|
37 | */ |
|
38 | 0 | public DefaultAtomicTypeConverterProvider() { |
39 | 0 | m_converters= registerDefaultAtomicTypeConverters(); |
40 | 0 | } |
41 | ||
42 | /** |
|
43 | * Full constructor. |
|
44 | * |
|
45 | * @param converters a map of classes and their associated <code>AtomicTypeConverter</code> |
|
46 | * classes. |
|
47 | */ |
|
48 | public DefaultAtomicTypeConverterProvider(Map converters) { |
|
49 | 0 | this(); |
50 | 0 | m_converters.putAll(converters); |
51 | 0 | } |
52 | ||
53 | /** |
|
54 | * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.AtomicTypeConverterProviderImpl#setAtomicTypeConvertors(java.util.Map) |
|
55 | */ |
|
56 | public void setAtomicTypeConvertors(Map converters) { |
|
57 | 0 | m_converters.putAll(converters); |
58 | 0 | } |
59 | ||
60 | protected Map registerDefaultAtomicTypeConverters() { |
|
61 | 0 | Map converters= new HashMap(); |
62 | ||
63 | 0 | converters.put(String.class, StringTypeConverterImpl.class); |
64 | 0 | converters.put(InputStream.class, BinaryTypeConverterImpl.class); |
65 | 0 | converters.put(long.class, LongTypeConverterImpl.class); |
66 | 0 | converters.put(Long.class, LongTypeConverterImpl.class); |
67 | 0 | converters.put(int.class, IntTypeConverterImpl.class); |
68 | 0 | converters.put(Integer.class, IntTypeConverterImpl.class); |
69 | 0 | converters.put(double.class, DoubleTypeConverterImpl.class); |
70 | 0 | converters.put(Double.class, DoubleTypeConverterImpl.class); |
71 | 0 | converters.put(boolean.class, BooleanTypeConverterImpl.class); |
72 | 0 | converters.put(Boolean.class, BooleanTypeConverterImpl.class); |
73 | 0 | converters.put(Calendar.class, CalendarTypeConverterImpl.class); |
74 | 0 | converters.put(GregorianCalendar.class, CalendarTypeConverterImpl.class); |
75 | 0 | converters.put(Date.class, UtilDateTypeConverterImpl.class); |
76 | 0 | converters.put(byte[].class, ByteArrayTypeConverterImpl.class); |
77 | 0 | converters.put(Timestamp.class, TimestampTypeConverterImpl.class); |
78 | ||
79 | 0 | return converters; |
80 | } |
|
81 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |