From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/scape/Manifest.java | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 NET/worlds/scape/Manifest.java (limited to 'NET/worlds/scape/Manifest.java') diff --git a/NET/worlds/scape/Manifest.java b/NET/worlds/scape/Manifest.java new file mode 100644 index 0000000..dc888a9 --- /dev/null +++ b/NET/worlds/scape/Manifest.java @@ -0,0 +1,92 @@ +package NET.worlds.scape; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +public class Manifest { + private IndentStream _out; + private Hashtable _ht = new Hashtable(); + private int _lastID = 0; + + public Manifest(IndentStream out) { + this._out = out; + this._out.println("MANIFEST Worlds, Inc."); + this._out.indent(); + } + + public Manifest(String name) throws IOException { + this(new IndentStream(new FileOutputStream(name))); + } + + public void done() { + this._out.undent(); + this._out.println("END MANIFEST"); + this._out.close(); + this._out = null; + this._ht = null; + } + + private void printID(String s) { + this._out.print(" (#" + s + ")"); + } + + private void printRef(Object obj) { + if (obj instanceof SuperRoot) { + this._out.print(((SuperRoot)obj).getName()); + } else { + this._out.print(""); + } + + if (this._ht.containsKey(obj)) { + this.printID(this._ht.get(obj)); + this._out.println(" --q.v.--"); + } else { + String newID = Integer.toString(this._lastID++); + this._ht.put(obj, newID); + this.printID(newID); + this._out.println(":" + obj.getClass().getName() + " ["); + this._out.indent(); + this.saveProps((Properties)obj); + this._out.undent(); + this._out.println("]"); + } + } + + private void saveMaybeProp(Object obj) { + if (obj instanceof Properties && !obj.getClass().getName().equals("NET.worlds.scape.Transform")) { + this.printRef(obj); + } else { + this._out.println(obj); + } + } + + public void saveProps(Properties obj) { + Enumeration pe = new EnumProperties(obj); + + while (pe.hasMoreElements()) { + Property prop = (Property)pe.nextElement(); + this._out.print(prop.getName()); + this._out.print(" := "); + if (prop instanceof VectorProperty) { + this._out.println("{"); + this._out.indent(); + Vector v = (Vector)prop.get(); + if (v != null) { + Enumeration ve = v.elements(); + + while (ve.hasMoreElements()) { + this.saveMaybeProp(ve.nextElement()); + } + } + + this._out.undent(); + this._out.println("}"); + } else { + this.saveMaybeProp(prop.get()); + } + } + } +} -- cgit v1.2.3