1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package de.jaret.examples.timebars.fzd.model;
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.List;
26
27 import de.jaret.util.date.Interval;
28 import de.jaret.util.date.IntervalImpl;
29
30 /***
31 * @author Peter Kliem
32 * @version $Id: Umlauf.java 259 2007-02-16 13:54:00Z olk $
33 */
34 public class Umlauf extends IntervalImpl {
35 protected String _umlaufbezeichnug;
36 protected List _fahrten = new ArrayList();
37 protected Fahrzeug _fahrzeug;
38
39 /***
40 * @param umlaufbezeichnug
41 */
42 public Umlauf(String umlaufbezeichnug) {
43 _umlaufbezeichnug = umlaufbezeichnug;
44 }
45
46 /***
47 * @return Returns the fahrzeug.
48 */
49 public Fahrzeug getFahrzeug() {
50 return _fahrzeug;
51 }
52
53 /***
54 * @param fahrzeug The fahrzeug to set.
55 */
56 public void setFahrzeug(Fahrzeug fahrzeug) {
57 Fahrzeug oldVal = _fahrzeug;
58 _fahrzeug = fahrzeug;
59 firePropertyChange("Fahrzeug", oldVal, fahrzeug);
60 }
61
62 /***
63 * @return Returns the fahrten.
64 */
65 public List getFahrten() {
66 return _fahrten;
67 }
68
69 public void addFahrt(Fahrt fahrt) {
70 _fahrten.add(fahrt);
71
72 Collections.sort(_fahrten, new Comparator() {
73 public int compare(Object arg0, Object arg1) {
74 Interval i1 = (Interval) arg0;
75 Interval i2 = (Interval) arg1;
76
77 return i1.getBegin().compareTo(i2.getBegin());
78 }
79 });
80
81 if (_begin == null) {
82 setBegin(fahrt.getBegin().copy());
83 setEnd(fahrt.getEnd().copy());
84 } else {
85 if (_begin.compareTo(fahrt.getBegin()) > 0) {
86 setBegin(fahrt.getBegin().copy());
87 } else if (_end.compareTo(fahrt.getEnd()) < 0) {
88 setEnd(fahrt.getEnd().copy());
89 }
90 }
91 }
92
93 /***
94 * @return Returns the umlaufbezeichnug.
95 */
96 public String getUmlaufbezeichnug() {
97 return _umlaufbezeichnug;
98 }
99 }