105 lines
3.5 KiB
Java
105 lines
3.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.tridium.platform.qnx;
|
|
|
|
import com.tridium.platform.qnx.TimeZoneEntry;
|
|
import java.io.BufferedReader;
|
|
import java.io.FileReader;
|
|
import java.io.IOException;
|
|
import java.util.Hashtable;
|
|
import java.util.Vector;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class TzUtil {
|
|
TimeZoneEntry lastTzNameLookup;
|
|
TimeZoneEntry lastEtcTimezoneLookup;
|
|
private boolean loaded;
|
|
private Hashtable byEtcTimezone;
|
|
private Hashtable byTzName;
|
|
private String[] tz_names;
|
|
|
|
public void load(String string) throws IOException {
|
|
String string2;
|
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(string));
|
|
this.byEtcTimezone = new Hashtable(350);
|
|
this.byTzName = new Hashtable(350);
|
|
Vector<String> vector = new Vector<String>(350);
|
|
while ((string2 = bufferedReader.readLine()) != null) {
|
|
if (!string2.startsWith("tz")) continue;
|
|
string2 = string2.replace('\t', ' ');
|
|
int n = string2.indexOf(34);
|
|
int n2 = string2.indexOf(34, n + 1);
|
|
String string3 = string2.substring(n + 1, n2).trim();
|
|
String string4 = string2.substring(n2);
|
|
n = string4.indexOf(44);
|
|
n2 = string4.indexOf(44, n + 1);
|
|
String string5 = string4.substring(n + 1, n2).trim();
|
|
String string6 = string4.substring(n2 + 1).trim();
|
|
if (!string6.equals("")) {
|
|
n = string6.indexOf(34);
|
|
n2 = string6.indexOf(34, n + 1);
|
|
string6 = string6.substring(n + 1, n2).trim();
|
|
}
|
|
TimeZoneEntry timeZoneEntry = new TimeZoneEntry(string3, string5, string6);
|
|
this.byEtcTimezone.put(timeZoneEntry.etcTimezone, timeZoneEntry);
|
|
this.byTzName.put(string3, timeZoneEntry);
|
|
vector.add(string3);
|
|
}
|
|
try {
|
|
bufferedReader.close();
|
|
}
|
|
catch (Exception exception) {}
|
|
this.tz_names = new String[vector.size()];
|
|
vector.toArray(this.tz_names);
|
|
this.loaded = true;
|
|
}
|
|
|
|
public String getTzName(String string) {
|
|
if (!this.loaded && this.lastTzNameLookup != null && this.lastTzNameLookup.etcTimezone.equals(string)) {
|
|
return this.lastTzNameLookup.tz_name;
|
|
}
|
|
TimeZoneEntry timeZoneEntry = (TimeZoneEntry)this.byEtcTimezone.get(string);
|
|
if (timeZoneEntry == null) {
|
|
return "Unknown timezone";
|
|
}
|
|
this.lastTzNameLookup = timeZoneEntry;
|
|
return timeZoneEntry.tz_name;
|
|
}
|
|
|
|
public String getEtcTimezone(String string) {
|
|
if (this.lastEtcTimezoneLookup != null && this.lastEtcTimezoneLookup.tz_name.equals(string)) {
|
|
return this.lastEtcTimezoneLookup.etcTimezone;
|
|
}
|
|
TimeZoneEntry timeZoneEntry = (TimeZoneEntry)this.byTzName.get(string);
|
|
if (timeZoneEntry == null) {
|
|
return "UTC";
|
|
}
|
|
this.lastEtcTimezoneLookup = timeZoneEntry;
|
|
return timeZoneEntry.etcTimezone;
|
|
}
|
|
|
|
public String[] getTzNames() {
|
|
return this.tz_names;
|
|
}
|
|
|
|
private final /* synthetic */ void this() {
|
|
this.lastTzNameLookup = null;
|
|
this.lastEtcTimezoneLookup = null;
|
|
this.loaded = false;
|
|
}
|
|
|
|
public TzUtil() throws IOException {
|
|
this.this();
|
|
this.load("/etc/timezone/uc_tz_t");
|
|
}
|
|
|
|
public TzUtil(String string) throws IOException {
|
|
this.this();
|
|
this.load(string);
|
|
}
|
|
}
|
|
|