annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DateRange.java @ 3272:31168ac9c7e7

Partial fix for issue694 (heightmarks snap to nearest cross section). flys-artifacts/trunk@4916 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 10 Jul 2012 15:31:56 +0000
parents ae14f412ba10
children 5a7b4f890d53
rev   line source
3210
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.util.Date;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.io.Serializable;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 public class DateRange
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 implements Serializable
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 protected Date from;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 protected Date to;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 public DateRange(Date from, Date to) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 this.from = from;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 this.to = to;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 public Date getFrom() {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 return from;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 public void setFrom(Date from) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 this.from = from;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 public Date getTo() {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 return to;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 public void setTo(Date to) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 this.to = to;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private static final boolean equalDates(Date a, Date b) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 if (a == null && b != null) return false;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 if (a != null && b == null) return false;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 if (a == null) return true;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 return a.equals(b);
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 @Override
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 public boolean equals(Object other) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 if (!(other instanceof DateRange)) {
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 return false;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 DateRange o = (DateRange)other;
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 return equalDates(from, o.from) && equalDates(to, o.to);
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
ae14f412ba10 SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org