1 | /* |
2 | * Copyright 2007 brunella ltd |
3 | * |
4 | * Licensed under the LGPL Version 3 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * |
7 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
8 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
10 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
11 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
12 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
13 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
14 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
15 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
16 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
17 | * THE POSSIBILITY OF SUCH DAMAGE. |
18 | */ |
19 | package sf.qof.mapping; |
20 | |
21 | import java.util.Date; |
22 | import java.util.HashSet; |
23 | import java.util.Set; |
24 | |
25 | public abstract class AbstractDateTimeMapping extends AbstractBaseMapping implements Mapping, ParameterMapping, |
26 | ResultMapping { |
27 | |
28 | private static final Set<Class<?>> types = new HashSet<Class<?>>(); |
29 | static { |
30 | types.add(Date.class); |
31 | } |
32 | |
33 | public static Set<Class<?>> getTypes() { |
34 | return types; |
35 | } |
36 | |
37 | public void accept(Mapper mapper, MappingVisitor visitor) { |
38 | visitor.visit(mapper, this); |
39 | } |
40 | |
41 | public abstract void accept(Mapper mapper, DateTimeMappingVisitor visitor); |
42 | |
43 | public static class DateMapping extends AbstractDateTimeMapping { |
44 | public void accept(Mapper mapper, DateTimeMappingVisitor visitor) { |
45 | visitor.visit(mapper, this); |
46 | } |
47 | } |
48 | |
49 | public static class TimeMapping extends AbstractDateTimeMapping { |
50 | public void accept(Mapper mapper, DateTimeMappingVisitor visitor) { |
51 | visitor.visit(mapper, this); |
52 | } |
53 | } |
54 | |
55 | public static class TimestampMapping extends AbstractDateTimeMapping { |
56 | public void accept(Mapper mapper, DateTimeMappingVisitor visitor) { |
57 | visitor.visit(mapper, this); |
58 | } |
59 | } |
60 | } |