diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/Manifest.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/Manifest.java')
| -rw-r--r-- | NET/worlds/scape/Manifest.java | 92 |
1 files changed, 92 insertions, 0 deletions
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<Object, String> _ht = new Hashtable<Object, String>(); + 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("<anonymous>"); + } + + 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<Object> 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<Object> v = (Vector<Object>)prop.get(); + if (v != null) { + Enumeration<Object> ve = v.elements(); + + while (ve.hasMoreElements()) { + this.saveMaybeProp(ve.nextElement()); + } + } + + this._out.undent(); + this._out.println("}"); + } else { + this.saveMaybeProp(prop.get()); + } + } + } +} |