/** *<code>Mappings</code>generatestwoMapsandaListwhichareusedby *javazicBackEnd. * *@since1.4
*/ class Mappings { // All aliases specified by Link statements. It's alias name to // real name mappings. private Map<String,String> aliases;
private List<Integer> rawOffsetsIndex;
private List<Set<String>> rawOffsetsIndexTable;
// Zone names to be excluded from rawOffset table. Those have GMT // offsets to change some future time. private List<String> excludeList;
/** *Constructorcreatessomenecessaryinstances.
*/
Mappings() {
aliases = new TreeMap<String,String>();
rawOffsetsIndex = new LinkedList<Integer>();
rawOffsetsIndexTable = new LinkedList<Set<String>>();
}
for (String zoneName : zones.keySet()) {
Zone zone = zones.get(zoneName);
String zonename = zone.getName(); int rawOffset = zone.get(zone.size()-1).getGmtOffset();
// If the GMT offset of this Zone will change in some // future time, this Zone is added to the exclude list. boolean isExcluded = false; for (int i = 0; i < zone.size(); i++) {
ZoneRec zrec = zone.get(i); if ((zrec.getGmtOffset() != rawOffset)
&& (zrec.getUntilTime(0) > Time.getCurrentTime())) { if (excludeList == null) {
excludeList = new ArrayList<String>();
}
excludeList.add(zone.getName());
isExcluded = true; break;
}
}
if (!rawOffsetsIndex.contains(new Integer(rawOffset))) { // Find the index to insert this raw offset zones int n = rawOffsetsIndex.size(); int i; for (i = 0; i < n; i++) { if (rawOffsetsIndex.get(i) > rawOffset) { break;
}
}
rawOffsetsIndex.add(i, rawOffset);
Set<String> perRawOffset = new TreeSet<String>(); if (!isExcluded) {
perRawOffset.add(zonename);
}
rawOffsetsIndexTable.add(i, perRawOffset);
} elseif (!isExcluded) { int i = rawOffsetsIndex.indexOf(new Integer(rawOffset));
Set<String> perRawOffset = rawOffsetsIndexTable.get(i);
perRawOffset.add(zonename);
}
}
Map<String,String> a = zi.getAliases(); // If there are time zone names which refer to any of the // excluded zones, add those names to the excluded list. if (excludeList != null) { for (String zoneName : a.keySet()) {
String realname = a.get(zoneName); if (excludeList.contains(realname)) {
excludeList.add(zoneName);
}
}
}
aliases.putAll(a);
}
if ((perRO.contains(aliases.get(key)) || isExcluded)
&& Zone.isTargetZone(key)) {
validname = true; if (!isExcluded) {
perRO.add(key);
Main.info("Alias <"+key+"> added to the list.");
} break;
}
}
if (!validname) {
Main.info("Alias <"+key+"> removed from the list.");
toBeRemoved.add(key);
}
}
// Remove zones, if any, from the list. for (String key : toBeRemoved) {
aliases.remove(key);
} // Eliminate any alias-to-alias mappings. For example, if // there are A->B and B->C, A->B is changed to A->C.
Map<String, String> newMap = new HashMap<String, String>(); for (String key : aliases.keySet()) {
String realid = aliases.get(key);
String leaf = realid; while (aliases.get(leaf) != null) {
leaf = aliases.get(leaf);
} if (!realid.equals(leaf)) {
newMap.put(key, leaf);
}
}
aliases.putAll(newMap);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.