X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FPropertyFile.java;h=f312a7ee8c24ffa166eb6ee2c6c3fb8ece4d5a9b;hb=ce791e4058158295bce9cf7b6698c2b565d571d7;hp=4e8542f9d5da13427f902182ae5d668c0a06dd56;hpb=865f9307f2434c6908077fce669c6595a24e7532;p=org.ibex.core.git diff --git a/src/org/ibex/js/PropertyFile.java b/src/org/ibex/js/PropertyFile.java index 4e8542f..f312a7e 100644 --- a/src/org/ibex/js/PropertyFile.java +++ b/src/org/ibex/js/PropertyFile.java @@ -5,10 +5,12 @@ import org.ibex.util.*; import java.util.*; import java.io.*; +// FIXME: Update for new api + /** A JS interface to a Java '.properties' file; very crude */ public class PropertyFile extends JS { - private final Properties p = new Properties(); + /*private final Properties p = new Properties(); private final Hash cache = new Hash(10, 3); private File f; @@ -20,13 +22,14 @@ public class PropertyFile extends JS { public String coerceToString() { return (String)p.get(prefix.substring(0, prefix.length() - 1)); } public Enumeration keys() throws JSExn { throw new JSExn("PropertyFile.keys() not supported"); } public Object get(Object key) throws JSExn { + if (toString(key).equals("")) return coerceToString(); Object ret = p.get(prefix + escape(toString(key))); if (ret != null) return ret; return new Minion(prefix + escape(toString(key)) + "."); } public void put(Object key, Object val) throws JSExn { try { - p.put(prefix + "." + escape(toString(key)), toString(val)); + p.put(prefix + (prefix.equals("") ? "" : ".") + escape(toString(key)), toString(val)); File fnew = new File(f.getName() + ".new"); FileOutputStream fo = new FileOutputStream(fnew); p.save(fo, ""); @@ -38,7 +41,7 @@ public class PropertyFile extends JS { } public static String escape(String s) { - return s.replaceAll("\\\\", "\\\\\\\\").replaceAll(".", "\\\\.").replaceAll("=","\\\\="); } + return s.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\.", "\\\\.").replaceAll("=","\\\\="); } public PropertyFile(File f) throws IOException { this.f = f; this.p.load(new FileInputStream(f)); } public void put(Object key, Object val) throws JSExn { new Minion("").put(key, val); } public Enumeration keys() throws JSExn { return new Minion("").keys(); } @@ -46,5 +49,5 @@ public class PropertyFile extends JS { Object ret = p.get(toString(key)); if (ret != null) return ret; return new Minion(escape(toString(key))); - } + }*/ }