/* * Decompiled with CFR 0.152. * * Could not load the following classes: * javax.baja.nre.util.TextUtil */ package com.tridium.util; import com.tridium.util.StringTable; import javax.baja.nre.util.TextUtil; /* * Illegal identifiers - consider using --renameillegalidents true */ public class CaseInsensitiveStringTable extends StringTable { String[] origKeys; public synchronized void init(String[] stringArray, Object[] objectArray) { if (stringArray.length != objectArray.length) { throw new IllegalArgumentException(); } int n = this.count = stringArray.length; this.keys = new String[n]; String[] stringArray2 = this.keys; this.origKeys = new String[n]; String[] stringArray3 = this.origKeys; this.values = new Object[n]; Object[] objectArray2 = this.values; System.arraycopy(stringArray, 0, this.keys, 0, n); System.arraycopy(stringArray, 0, this.origKeys, 0, n); System.arraycopy(objectArray, 0, this.values, 0, n); int n2 = 0; while (n2 < n) { stringArray2[n2] = TextUtil.toLowerCase((String)stringArray2[n2]); ++n2; } n2 = n / 2; while (n2 >= 1) { int n3 = n2; while (n3 < n) { String string = stringArray2[n3]; String string2 = stringArray3[n3]; Object object = objectArray2[n3]; int n4 = n3; while (n4 >= n2 && string.compareTo(stringArray2[n4 - n2]) < 0) { stringArray2[n4] = stringArray2[n4 - n2]; stringArray3[n4] = stringArray3[n4 - n2]; objectArray2[n4] = objectArray2[n4 - n2]; n4 -= n2; } stringArray2[n4] = string; stringArray3[n4] = string2; objectArray2[n4] = object; ++n3; } n2 /= 2; } } public synchronized Object get(String string) { string = TextUtil.toLowerCase((String)string); String[] stringArray = this.keys; int n = -1; int n2 = this.count; while (n2 - n > 1) { int n3 = (n2 + n) / 2; int n4 = string.compareTo(stringArray[n3]); if (n4 < 0) { n2 = n3; continue; } if (n4 > 0) { n = n3; continue; } return this.values[n3]; } return null; } public synchronized Object put(String string, Object object) { String string2 = string; string = TextUtil.toLowerCase((String)string); if (this.keys.length >= this.count) { this.ensureCapacity(Math.max(8, this.count * 2)); } String[] stringArray = this.keys; if (this.count == 0) { Object object2 = this.values[0]; stringArray[0] = string; this.origKeys[0] = string2; this.values[0] = object; ++this.count; return object2; } if (this.count == 1) { int n = string.compareTo(stringArray[0]); if (n == 0) { Object object3 = this.values[0]; this.origKeys[0] = string2; this.values[0] = object; return object3; } if (n < 0) { stringArray[1] = stringArray[0]; this.origKeys[1] = this.origKeys[0]; this.values[1] = this.values[0]; stringArray[0] = string; this.origKeys[0] = string2; this.values[0] = object; ++this.count; } else { stringArray[1] = string; this.origKeys[1] = string2; this.values[1] = object; ++this.count; } return null; } int n = 0; int n2 = this.count - 1; int n3 = (n2 - n) / 2; while (n <= n2) { int n4 = string.compareTo(stringArray[n3]); if (n4 == 0) { Object object4 = this.values[n3]; this.origKeys[n3] = string2; this.values[n3] = object; return object4; } if (n4 < 0) { n4 = string.compareTo(stringArray[n]); if (n4 == 0) { Object object5 = this.values[n]; this.origKeys[n] = string2; this.values[n] = object; return object5; } if (n4 < 0) { n3 = n; break; } n2 = n3 - 1; } else { n4 = string.compareTo(stringArray[n2]); if (n4 == 0) { Object object6 = this.values[n2]; this.origKeys[n2] = string2; this.values[n2] = object; return object6; } if (n4 > 0) { n3 = n2 + 1; break; } n = n3 + 1; } n3 = n + (n2 - n) / 2; } System.arraycopy(stringArray, n3, stringArray, n3 + 1, this.count - n3); stringArray[n3] = string; System.arraycopy(this.origKeys, n3, this.origKeys, n3 + 1, this.count - n3); this.origKeys[n3] = string2; System.arraycopy(this.values, n3, this.values, n3 + 1, this.count - n3); this.values[n3] = object; ++this.count; return null; } public synchronized Object remove(String string) { string = TextUtil.toLowerCase((String)string); String[] stringArray = this.keys; int n = -1; int n2 = this.count; while (n2 - n > 1) { int n3 = (n2 + n) / 2; int n4 = string.compareTo(stringArray[n3]); if (n4 < 0) { n2 = n3; continue; } if (n4 > 0) { n = n3; continue; } Object object = this.values[n3]; System.arraycopy(this.keys, n3 + 1, this.keys, n3, this.count - n3 - 1); System.arraycopy(this.origKeys, n3 + 1, this.origKeys, n3, this.count - n3 - 1); System.arraycopy(this.values, n3 + 1, this.values, n3, this.count - n3 - 1); this.keys[this.count - 1] = null; this.origKeys[this.count - 1] = null; this.values[this.count - 1] = null; --this.count; return object; } return null; } public synchronized String[] keyArray() { String[] stringArray = new String[this.count]; System.arraycopy(this.origKeys, 0, stringArray, 0, this.count); return stringArray; } public synchronized String[] normalizedKeyArray() { String[] stringArray = new String[this.count]; System.arraycopy(this.keys, 0, stringArray, 0, this.count); return stringArray; } public synchronized void ensureCapacity(int n) { if (this.keys.length < n) { String[] stringArray = new String[n]; String[] stringArray2 = new String[n]; Object[] objectArray = new Object[n]; System.arraycopy(this.keys, 0, stringArray, 0, this.count); System.arraycopy(this.origKeys, 0, stringArray2, 0, this.count); System.arraycopy(this.values, 0, objectArray, 0, this.count); this.keys = stringArray; this.origKeys = stringArray2; this.values = objectArray; } } public synchronized void clear() { this.keys = EMPTY; this.origKeys = EMPTY; this.values = EMPTY; this.count = 0; } public synchronized void dump() { int n = 0; while (n < this.count) { System.out.println(" " + this.keys[n] + " (" + this.origKeys[n] + ") = " + this.values[n]); ++n; } } private final /* synthetic */ void this() { this.origKeys = EMPTY; } public CaseInsensitiveStringTable() { this.this(); } public CaseInsensitiveStringTable(int n) { this.this(); this.keys = new String[n]; this.origKeys = new String[n]; this.values = new Object[n]; } public CaseInsensitiveStringTable(String[] stringArray, Object[] objectArray) { this.this(); this.init(stringArray, objectArray); } }