home *** CD-ROM | disk | FTP | other *** search
- import java.util.Vector;
- import stardiv.tools.SjProtocolWindow;
-
- class JavaObjectHolder {
- private static Vector theObjects = new Vector();
- private static int emptySlots = 0;
- private static int nextSlotToTry = 0;
-
- public static int addObject(Object var0) throws NullPointerException {
- Vector var1 = theObjects;
- synchronized(var1){}
-
- try {
- if (SjProtocolWindow.IsMemTraceModeOn()) {
- System.out.println("@@@addObject " + var0 + " #total=" + theObjects.size());
- }
-
- if (var0 == null) {
- throw new NullPointerException();
- } else {
- int var3 = theObjects.size();
-
- while(nextSlotToTry < var3) {
- if (theObjects.elementAt(nextSlotToTry) == null) {
- int var4 = nextSlotToTry;
- --emptySlots;
- theObjects.setElementAt(var0, var4);
- ++nextSlotToTry;
- int var5 = var4;
- return var5;
- }
-
- ++nextSlotToTry;
- if (nextSlotToTry >= var3) {
- considerRecyclingSlots();
- }
- }
-
- int var8 = nextSlotToTry++;
- theObjects.addElement(var0);
- int var9 = var8;
- return var9;
- }
- } catch (Throwable var7) {
- throw var7;
- }
- }
-
- public static void removeObject(int var0) {
- Vector var1 = theObjects;
- synchronized(var1){}
-
- try {
- try {
- if (SjProtocolWindow.IsMemTraceModeOn()) {
- System.out.println("@@@removeObject " + var0 + " " + theObjects.elementAt(var0) + " #total=" + theObjects.size());
- }
-
- if (theObjects.elementAt(var0) != null) {
- theObjects.setElementAt((Object)null, var0);
- ++emptySlots;
- considerRecyclingSlots();
- return;
- }
- } catch (IndexOutOfBoundsException var5) {
- return;
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- public static void replaceObject(int var0, Object var1) {
- Vector var2 = theObjects;
- synchronized(var2){}
-
- try {
- try {
- theObjects.setElementAt(var1, var0);
- return;
- } catch (IndexOutOfBoundsException var6) {
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public static String DumpMemory() {
- String var0 = "";
- Vector var1 = theObjects;
- synchronized(var1){}
-
- try {
- int var3 = theObjects.size();
-
- for(int var4 = 0; var4 < var3; ++var4) {
- var0 = var0 + var4 + " " + theObjects.elementAt(var4) + "\n";
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- return var0;
- }
-
- public static Object getObject(int var0) throws IndexOutOfBoundsException {
- Object var1 = theObjects.elementAt(var0);
- return var1;
- }
-
- private static void considerRecyclingSlots() {
- int var0 = theObjects.size();
- if (nextSlotToTry >= var0 && emptySlots > var0 / 2) {
- nextSlotToTry = 0;
- }
-
- }
- }
-