2026-03-17 13:31:18 -07:00

336 lines
10 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.util.ArrayIterator
*/
package com.tridium.util;
import com.tridium.nre.util.ArrayIterator;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class StringTable
extends Dictionary {
static final String[] EMPTY = new String[0];
String[] keys;
Object[] values;
int count;
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.values = new Object[n];
Object[] objectArray2 = this.values;
System.arraycopy(stringArray, 0, this.keys, 0, n);
System.arraycopy(objectArray, 0, this.values, 0, n);
int n2 = n / 2;
while (n2 >= 1) {
int n3 = n2;
while (n3 < n) {
String string = stringArray2[n3];
Object object = objectArray2[n3];
int n4 = n3;
while (n4 >= n2 && string.compareTo(stringArray2[n4 - n2]) < 0) {
stringArray2[n4] = stringArray2[n4 - n2];
objectArray2[n4] = objectArray2[n4 - n2];
n4 -= n2;
}
stringArray2[n4] = string;
objectArray2[n4] = object;
++n3;
}
n2 /= 2;
}
}
public synchronized Object get(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) {
if (this.keys.length >= this.count) {
this.ensureCapacity(Math.max(8, this.count * 2));
}
String[] stringArray = this.keys;
if (this.count == 0) {
stringArray[0] = string;
this.values[0] = object;
++this.count;
return null;
}
if (this.count == 1) {
int n = string.compareTo(stringArray[0]);
if (n == 0) {
Object object2 = this.values[0];
this.values[0] = object;
return object2;
}
if (n < 0) {
stringArray[1] = stringArray[0];
this.values[1] = this.values[0];
stringArray[0] = string;
this.values[0] = object;
++this.count;
} else {
stringArray[1] = string;
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 object3 = this.values[n3];
this.values[n3] = object;
return object3;
}
if (n4 < 0) {
n4 = string.compareTo(stringArray[n]);
if (n4 == 0) {
Object object4 = this.values[n];
this.values[n] = object;
return object4;
}
if (n4 < 0) {
n3 = n;
break;
}
n2 = n3 - 1;
} else {
n4 = string.compareTo(stringArray[n2]);
if (n4 == 0) {
Object object5 = this.values[n2];
this.values[n2] = object;
return object5;
}
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.values, n3, this.values, n3 + 1, this.count - n3);
this.values[n3] = object;
++this.count;
return null;
}
public synchronized Object remove(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.values, n3 + 1, this.values, n3, this.count - n3 - 1);
this.keys[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.keys, 0, stringArray, 0, this.count);
return stringArray;
}
public synchronized Object[] elementArray() {
Object[] objectArray = new Object[this.count];
System.arraycopy(this.values, 0, objectArray, 0, this.count);
return objectArray;
}
public synchronized Object[] elementArray(Object[] objectArray) {
System.arraycopy(this.values, 0, objectArray, 0, this.count);
return objectArray;
}
public synchronized void copyElementsInto(Object[] objectArray, int n) {
System.arraycopy(this.values, 0, objectArray, n, this.count);
}
public synchronized boolean isEmpty() {
boolean bl = false;
if (this.count == 0) {
bl = true;
}
return bl;
}
public synchronized int size() {
return this.count;
}
public synchronized void ensureCapacity(int n) {
if (this.keys.length < n) {
String[] stringArray = new String[n];
Object[] objectArray = new Object[n];
System.arraycopy(this.keys, 0, stringArray, 0, this.count);
System.arraycopy(this.values, 0, objectArray, 0, this.count);
this.keys = stringArray;
this.values = objectArray;
}
}
public synchronized void clear() {
this.keys = EMPTY;
this.values = EMPTY;
this.count = 0;
}
public Iterator keyIterator() {
return new ArrayIterator((Object[])this.keys, 0, this.size());
}
public Iterator valueIterator() {
return new ArrayIterator(this.values, 0, this.size());
}
public Enumeration keys() {
return new Enumerator(true);
}
public Enumeration elements() {
return new Enumerator(false);
}
public Object get(Object object) {
return this.get((String)object);
}
public Object put(Object object, Object object2) {
return this.put((String)object, object2);
}
public Object remove(Object object) {
return this.remove((String)object);
}
public synchronized void dump() {
Enumeration enumeration = this.keys();
while (enumeration.hasMoreElements()) {
String string = (String)enumeration.nextElement();
System.out.println(" " + string + " = " + this.get(string));
}
}
public static void main(String[] stringArray) {
StringTable stringTable = new StringTable();
stringTable.put("value", (Object)"200");
stringTable.put("hee", (Object)"2000");
ArrayIterator arrayIterator = (ArrayIterator)stringTable.keyIterator();
System.out.println("Size --> " + stringTable.size());
while (arrayIterator.hasNext()) {
System.out.println("\t Next element -> " + arrayIterator.next());
}
System.out.println("---------");
while (arrayIterator.hasPrevious()) {
System.out.println("\t Next element -> " + arrayIterator.previous());
}
while (arrayIterator.hasNext()) {
System.out.println("\t Next element -> " + arrayIterator.next());
}
}
private final /* synthetic */ void this() {
this.keys = EMPTY;
this.values = EMPTY;
this.count = 0;
}
public StringTable() {
this.this();
}
public StringTable(int n) {
this.this();
this.keys = new String[n];
this.values = new Object[n];
}
public StringTable(String[] stringArray, Object[] objectArray) {
this.this();
this.init(stringArray, objectArray);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class Enumerator
implements Enumeration {
private boolean doKeys;
private int index;
public boolean hasMoreElements() {
boolean bl = false;
if (this.index < StringTable.this.count) {
bl = true;
}
return bl;
}
public Object nextElement() {
if (this.index >= StringTable.this.count) {
throw new NoSuchElementException("StringTable");
}
if (this.doKeys) {
return StringTable.this.keys[this.index++];
}
return StringTable.this.values[this.index++];
}
public Enumerator(boolean bl) {
this.doKeys = bl;
this.index = 0;
}
}
}