3
* Copyright (C) 2008 W. Xaver
4
* W.Xaver[at]googlemail.com
5
* http://zdfmediathk.sourceforge.net/
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
package msearch.filmeLaden;
22
import java.text.ParseException;
23
import java.text.SimpleDateFormat;
24
import java.util.Calendar;
25
import java.util.Date;
26
import java.util.SimpleTimeZone;
27
import msearch.tool.MSLog;
29
public class DatenFilmlisteUrl implements Comparable<DatenFilmlisteUrl> {
31
public static final String SERVER_ART_AKT = "akt";
32
public static final String SERVER_ART_OLD = "old";
33
public static final String SERVER_ART_DIFF = "diff";
35
public static final String FILM_UPDATE_SERVER_PRIO_1 = "1";
36
public static final String FILM_UPDATE_SERVER = "film-update-server";
37
public static final String FILM_UPDATE_SERVER_NR = "film-update-server-nr";
38
public static final int FILM_UPDATE_SERVER_NR_NR = 0;
39
public static final String FILM_UPDATE_SERVER_URL = "film-update-server-url";
40
public static final int FILM_UPDATE_SERVER_URL_NR = 1;
41
public static final String FILM_UPDATE_SERVER_DATUM = "film-update-server-datum"; // Datum in UTC
42
public static final int FILM_UPDATE_SERVER_DATUM_NR = 2;
43
public static final String FILM_UPDATE_SERVER_ZEIT = "film-update-server-zeit"; // Zeit in UTC
44
public static final int FILM_UPDATE_SERVER_ZEIT_NR = 3;
45
public static final String FILM_UPDATE_SERVER_PRIO = "film-update-server-prio";
46
public static final int FILM_UPDATE_SERVER_PRIO_NR = 4;
47
public static final String FILM_UPDATE_SERVER_ART = "film-update-server-art";
48
public static final int FILM_UPDATE_SERVER_ART_NR = 5;
49
public static final int FILM_UPDATE_SERVER_MAX_ELEM = 6;
50
public static final String[] FILM_UPDATE_SERVER_COLUMN_NAMES = {FILM_UPDATE_SERVER_NR, FILM_UPDATE_SERVER_URL,
51
FILM_UPDATE_SERVER_DATUM, FILM_UPDATE_SERVER_ZEIT, FILM_UPDATE_SERVER_PRIO, FILM_UPDATE_SERVER_ART};
53
public static final String[] FILM_UPDATE_SERVER_COLUMN_NAMES_ANZEIGE = {"Nr", "Update-Url", "Datum", "Zeit", "Prio", "Art"};
56
private SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
58
public DatenFilmlisteUrl() {
59
sdf.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC"));
63
public DatenFilmlisteUrl(String url, String prio, String zeit, String datum, String art) {
64
sdf.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC"));
66
arr[FILM_UPDATE_SERVER_URL_NR] = url;
67
arr[FILM_UPDATE_SERVER_PRIO_NR] = prio;
68
arr[FILM_UPDATE_SERVER_DATUM_NR] = datum;
69
arr[FILM_UPDATE_SERVER_ZEIT_NR] = zeit;
70
arr[FILM_UPDATE_SERVER_ART_NR] = art;
73
public Date getDate() {
74
String date = arr[FILM_UPDATE_SERVER_DATUM_NR] + " " + arr[FILM_UPDATE_SERVER_ZEIT_NR];
78
} catch (Exception ex) {
84
public String getDateStr() {
85
SimpleDateFormat sdf_ = new SimpleDateFormat("dd.MM.yyyy");
86
sdf_.setTimeZone(SimpleTimeZone.getDefault());
89
d = sdf_.format(getDate());
90
} catch (Exception ex) {
91
d = sdf_.format(new Date());
96
public String getTimeStr() {
97
SimpleDateFormat sdf_ = new SimpleDateFormat("HH:mm:ss");
98
sdf_.setTimeZone(SimpleTimeZone.getDefault());
101
d = sdf_.format(getDate());
102
} catch (Exception ex) {
103
d = sdf_.format(new Date());
109
public int compareTo(DatenFilmlisteUrl arg0) {
112
//31.10.2010 16:54:17
113
String ich = arr[FILM_UPDATE_SERVER_DATUM_NR] + " " + arr[FILM_UPDATE_SERVER_ZEIT_NR];
114
String du = arg0.arr[FILM_UPDATE_SERVER_DATUM_NR] + " " + arg0.arr[FILM_UPDATE_SERVER_ZEIT_NR];
115
if (ich.equals(du)) {
118
Date d_ich = sdf.parse(ich);
119
Date d_du = sdf.parse(du);
120
ret = d_du.compareTo(d_ich);
121
} catch (ParseException ex) {
122
MSLog.fehlerMeldung(936542876, MSLog.FEHLER_ART_PROG, this.getClass().getName(), ex);
127
public boolean aelterAls(int tage) {
130
//31.10.2010 16:54:17
131
String ich = arr[FILM_UPDATE_SERVER_DATUM_NR] + " " + arr[FILM_UPDATE_SERVER_ZEIT_NR];
132
Date d_ich = sdf.parse(ich);
133
Calendar cal = Calendar.getInstance();
134
// tage vom calendar abziehen
135
cal.add(Calendar.DATE, -tage);
136
ret = d_ich.before(cal.getTime());
137
} catch (ParseException ex) {
138
MSLog.fehlerMeldung(915468973, MSLog.FEHLER_ART_PROG, this.getClass().getName(), ex);
143
private void makeArr() {
144
arr = new String[FILM_UPDATE_SERVER_MAX_ELEM];
145
for (int i = 0; i < arr.length; ++i) {