Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/Range.java @ 5590:b75005269a6c
Datacage: Fix potential connection leak to SedDB.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 08 Apr 2013 12:07:43 +0200 |
parents | 7b1c5fe4ebf3 |
children | 80b9218ac007 |
rev | line source |
---|---|
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.math.BigDecimal; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
7 import javax.persistence.Entity; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
8 import javax.persistence.Id; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
9 import javax.persistence.Table; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
10 import javax.persistence.GeneratedValue; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
11 import javax.persistence.Column; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
12 import javax.persistence.SequenceGenerator; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
13 import javax.persistence.GenerationType; |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
172
diff
changeset
|
14 import javax.persistence.JoinColumn; |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
172
diff
changeset
|
15 import javax.persistence.OneToOne; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
16 |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
17 @Entity |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
18 @Table(name = "ranges") |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public class Range |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 implements Serializable |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 { |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
22 private Integer id; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 private BigDecimal a; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 private BigDecimal b; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 private River river; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public Range() { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
31 public Range(double a, double b, River river) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
32 this(new BigDecimal(a), new BigDecimal(b), river); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
33 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
34 |
201
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
35 public Range(BigDecimal a, BigDecimal b, River river) { |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
36 this.a = a; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
37 this.b = b; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
38 this.river = river; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
39 } |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
40 |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
41 @Id |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
42 @SequenceGenerator( |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
43 name = "SEQUENCE_RANGES_ID_SEQ", |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
44 sequenceName = "RANGES_ID_SEQ", |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
45 allocationSize = 1) |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
46 @GeneratedValue( |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
47 strategy = GenerationType.SEQUENCE, |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
48 generator = "SEQUENCE_RANGES_ID_SEQ") |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
49 @Column(name = "id") |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
50 public Integer getId() { |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
51 return id; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
52 } |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
53 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
54 public void setId(Integer id) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 this.id = id; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
58 @Column(name = "a") // FIXME: type mapping needed? |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
59 public BigDecimal getA() { |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
60 return a; |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
61 } |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
62 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 public void setA(BigDecimal a) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 this.a = a; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
67 @Column(name = "b") // FIXME: type mapping needed? |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
68 public BigDecimal getB() { |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
69 return b; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 public void setB(BigDecimal b) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 this.b = b; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
5587
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
76 public boolean contains(double x) { |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
77 BigDecimal b = this.b != null ? this.b : a; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
78 double av = a.doubleValue(); |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
79 double bv = b.doubleValue(); |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
80 if (av > bv) { |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
81 double t = av; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
82 av = bv; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
83 bv = t; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
84 } |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
85 return x >= av && x <= bv; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
86 } |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
87 |
188
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
88 @OneToOne |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
89 @JoinColumn(name = "river_id") |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
90 public River getRiver() { |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
91 return river; |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
92 } |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
93 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 public void setRiver(River river) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 this.river = river; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
97 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
98 public int code() { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
99 int code = 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
100 if (a != null) code = 1; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
101 if (b != null) code |= 2; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
102 return code; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
103 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
104 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
105 public boolean intersects(BigDecimal c) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
106 return !(a.compareTo(c) > 0 || b.compareTo(c) < 0); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
107 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
108 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
109 public boolean intersects(Range other) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
110 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
111 int code = code(); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
112 int ocode = other.code(); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
113 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
114 if (code == 0 || ocode == 0) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
115 return false; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
116 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
117 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
118 switch (code) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
119 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
120 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
121 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
122 return a.compareTo(other.a) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
123 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
124 return a.compareTo(other.b) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
125 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
126 return other.intersects(a); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
127 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
128 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
129 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
130 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
131 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
132 return b.compareTo(other.a) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
133 case 2: // has b |
205
697d1faa8217
Forgot to save the last change before commit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
204
diff
changeset
|
134 return b.compareTo(other.b) == 0; |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
135 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
136 return other.intersects(b); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
137 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
138 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
139 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
140 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
141 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
142 return intersects(other.a); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
143 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
144 return intersects(other.b); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
145 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
146 return !(other.b.compareTo(a) < 0 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
147 ||other.a.compareTo(b) > 0); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
148 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
149 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
150 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
151 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
152 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
153 return false; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
154 } |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |