Revision: 1742
          http://svn.sourceforge.net/vexi/?rev=1742&view=rev
Author:   mkpg2
Date:     2007-03-20 06:21:05 -0700 (Tue, 20 Mar 2007)

Log Message:
-----------
Moving unused (by Vexi) JS code into its own dir.

Modified Paths:
--------------
    core/trunk/org.ibex.js/.classpath

Added Paths:
-----------
    core/trunk/org.ibex.js/src_unused/
    core/trunk/org.ibex.js/src_unused/org/
    core/trunk/org.ibex.js/src_unused/org/ibex/
    core/trunk/org.ibex.js/src_unused/org/ibex/js/
    core/trunk/org.ibex.js/src_unused/org/ibex/js/Directory.java
    core/trunk/org.ibex.js/src_unused/org/ibex/js/JSReflection.java
    core/trunk/org.ibex.js/src_unused/org/ibex/js/PropertyFile.java

Removed Paths:
-------------
    core/trunk/org.ibex.js/src/org/ibex/js/Directory.java
    core/trunk/org.ibex.js/src/org/ibex/js/JSReflection.java
    core/trunk/org.ibex.js/src/org/ibex/js/PropertyFile.java

Modified: core/trunk/org.ibex.js/.classpath
===================================================================
--- core/trunk/org.ibex.js/.classpath   2007-03-20 13:17:35 UTC (rev 1741)
+++ core/trunk/org.ibex.js/.classpath   2007-03-20 13:21:05 UTC (rev 1742)
@@ -4,6 +4,7 @@
        <classpathentry kind="src" path="src_gen"/>
        <classpathentry kind="src" path="src_dev"/>
        <classpathentry kind="src" path="src_junit"/>
+       <classpathentry kind="src" path="src_unused"/>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry combineaccessrules="false" exported="true" kind="src" 
path="/org.ibex.io"/>
        <classpathentry combineaccessrules="false" exported="true" kind="src" 
path="/org.ibex.net"/>

Deleted: core/trunk/org.ibex.js/src/org/ibex/js/Directory.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/Directory.java       2007-03-20 
13:17:35 UTC (rev 1741)
+++ core/trunk/org.ibex.js/src/org/ibex/js/Directory.java       2007-03-20 
13:21:05 UTC (rev 1742)
@@ -1,136 +0,0 @@
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the Apache Public Source License 2.0 ("the License").
-// You may not use this file except in compliance with the License.
-
-package org.ibex.js; 
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-
-import org.ibex.io.Stream;
-import org.ibex.util.Encode;
-
-// FEATURE: support for move
-// FEATURE: support for bytestreams
-// FEATURE: cache directories so we can do equality checking on them?
-// FEATURE: autoconvert "true" to true and "0.3" to 0.3 on readback
-
-/** 
- * A crude mechanism for using a filesystem as object storage.
- *
- *  This object represents a directory; writing a string, number, or
- *  boolean to any of its properties will create a file with the
- *  (encoded) property name as its filename and the "stringified"
- *  value as its contents.
- *
- *  Writing 'null' to one of this object's properties will
- *  [recursively if necessary] delete the corresponding directory
- *  entry.
- *  
- *  Writing any other object to one of this object's properties will
- *  create a new Directory object and copy the other object's keys()
- *  into the new Directory.  This means that assigning one directory
- *  to a property of another directory will <i>copy</i> the directory,
- *  not move it.  There is currently no way to move directories.
- *
- *  If an object is written to a property that already has an entry,
- *  the old one is deleted (equivalent to writing 'null') first.
- * 
- *  WARNING: when instantiating a Directory object with a file
- *  argument that points to a non-directory File, this class will
- *  delete that file and create a directory!
- */
-public class Directory extends JS.Immutable {
-
-    File f;
-
-    /** 
-     *  Create the directory object.  Existing directories will be
-     *  preserved; if a file is present it will be obliterated.
-     */ 
-
-    public Directory(File f) throws IOException {
-        this.f = f;
-        if (!f.exists()) new Directory(new File(f.getParent()));
-        if (!f.isDirectory()) destroy(f);
-        f.mkdirs();
-    }
-
-    private static void destroy(File f) throws IOException {
-        if (!f.exists()) return;
-        if (f.isDirectory()) {
-            String[] entries = f.list();
-            for(int i=0; i<entries.length; i++) destroy(new 
File(f.getAbsolutePath() + File.separatorChar + entries[i]));
-        }
-        f.delete();
-    }
-
-    public void put(JS key0, JS val) throws JSExn {
-        try {
-            if (key0 == null) return;
-            String key = JSU.toString(key0);
-            File f2 = new File(f.getAbsolutePath() + File.separatorChar + 
Encode.toFilename(key));
-            destroy(f2);
-            if (val == null) return;
-            // FIXME - this cannot be right (JS never instance of io.Fountain)
-            if (val instanceof org.ibex.io.Fountain) {
-                Stream stream = ((org.ibex.io.Fountain)val).getStream();
-                Stream out = new Stream(null, new FileOutputStream(f2));
-                stream.transcribe(out);
-                out.close();
-            } else if (val instanceof JSPrimitive) {
-                OutputStream out = new FileOutputStream(f2);
-                Writer w = new OutputStreamWriter(out);
-                w.write(JSU.toString(val));
-                w.flush();
-                out.close();
-            } else {
-                Directory d2 = new Directory(f2);
-                JS.Enumeration e = val.keys();
-                while(e.hasNext()) {
-                    JS k = e.next();
-                    JS v = val.get(k);
-                    d2.put(k, v);
-                }
-            }
-        } catch (IOException ioe) {
-            throw new JSExn.IO(ioe);
-        }
-    }
-
-    public JS get(JS key0) throws JSExn {
-        try {
-            if (key0 == null) return null;
-            String key = JSU.toString(key0);
-            File f2 = new File(f.getAbsolutePath() + File.separatorChar + 
Encode.toFilename(key));
-            if (!f2.exists()) return null;
-            if (f2.isDirectory()) return new Directory(f2);
-            char[] chars = new char[((int)f2.length()) * 4 + 10];
-            int numchars = 0;
-            Reader r = new InputStreamReader(new FileInputStream(f2));
-            while(true) {
-                int numread = r.read(chars, numchars, chars.length - numchars);
-                if (numread == -1) return JSU.S(new String(chars, 0, 
numchars));
-                numchars += numread;
-            }
-        } catch (IOException ioe) {
-            throw new JSExn.IO(ioe);
-        }
-    }
-
-    public JS.Enumeration keys() {
-        final String[] elements = f.list();
-        return new JS.Enumeration(null) {
-                int i = 0;
-                public boolean _hasNext() { return i < elements.length; }
-                public JS _next() { return 
JSU.S(Encode.fromFilename(elements[i++])); }
-            };
-    }
-}

Deleted: core/trunk/org.ibex.js/src/org/ibex/js/JSReflection.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/JSReflection.java    2007-03-20 
13:17:35 UTC (rev 1741)
+++ core/trunk/org.ibex.js/src/org/ibex/js/JSReflection.java    2007-03-20 
13:21:05 UTC (rev 1742)
@@ -1,129 +0,0 @@
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the Apache Public Source License 2.0 ("the License").
-// You may not use this file except in compliance with the License.
-
-package org.ibex.js; 
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-
-/** Automatic JS-ification via Reflection (not for use in the core) */
-public class JSReflection extends JS.Immutable {
-    public static JS wrap(Object o) throws JSExn {
-        if (o == null) return null;
-        if (o instanceof String) return JSU.S((String)o);
-        if (o instanceof Boolean) return JSU.B(((Boolean)o).booleanValue());
-        if (o instanceof Number) return JSU.N((Number)o);
-        if (o instanceof JS) return (JS)o;
-        if (o instanceof Object[]) throw new JSExn("Reflection onto Object[] 
not supported yet");
-        return new Wrapper(o);
-    }
-
-    public static class Wrapper extends JS.Immutable {
-        private final Object o;
-        public Wrapper(Object o) { this.o = o; }
-        public Object unwrap() { return o; }
-        public Enumeration keys() throws JSExn { throw new 
JSExn("JSReflection.keys() not supported yet"); }
-        public JS get(JS key) throws JSExn {
-            String k = JSU.toString(key);
-            Class c = o.getClass();
-            while(c != null) {
-                try {
-                    Field f = c.getField(k);
-                    if (f != null) return wrap(f.get(o));
-                } catch (NoSuchFieldException nfe) {
-                } catch (IllegalAccessException nfe) {
-                } catch (SecurityException nfe) { }
-                c = c.getSuperclass();
-            }
-            
-            try {
-                java.lang.reflect.Method[] methods = o.getClass().getMethods();
-                for(int i=0; i<methods.length; i++) if 
(methods[i].getName().equals(k)) return METHOD;
-            } catch (SecurityException nfe) { }
-            return null;
-        }
-        
-        public void put(JS key, JS val) throws JSExn { throw new JSExn("put() 
not supported yet"); }
-        
-        public JS call(JS method, JS[] args) throws JSExn {
-            String k = JSU.toString(method);
-            try {
-                java.lang.reflect.Method[] methods = o.getClass().getMethods();
-                for(int j=0; j<methods.length; j++) {
-                    if (methods[j].getName().equals(k) &&
-                        methods[j].getParameterTypes().length == args.length) {
-                        return wrap(methods[j].invoke(o, (Object[])args));
-                    }
-                }
-            } catch (IllegalAccessException nfe) {
-            } catch (InvocationTargetException it) {
-                Throwable ite = it.getTargetException();
-                if (ite instanceof JSExn) throw ((JSExn)ite);
-                JSU.warn(ite);
-                throw new JSExn("unhandled reflected exception: " + 
ite.toString());
-            } catch (SecurityException nfe) { }
-            throw new JSExn("called a reflection method with the wrong number 
of arguments");
-        }
-    }
-
-    public static class Array extends JS.Immutable {
-        final Object[] arr;
-        public Array(Object[] arr) { this.arr = arr; }
-        // FEATURE: Add a JSCounterEnumeration
-        public Enumeration keys() throws JSExn {
-            return new Enumeration(null) {
-                private int n = 0;
-                public boolean _hasNext() { return n < arr.length; }
-                public JS _next() { return JSU.N(n++); }
-            };
-        }
-        public JS get(JS key) throws JSExn { return wrap(arr[JSU.toInt(key)]); 
}
-    }
-
-    public Enumeration keys() throws JSExn { throw new 
JSExn("JSReflection.keys() not supported yet"); }
-
-    public JS get(JS key) throws JSExn {
-        String k = JSU.toString(key);
-        Class c = this.getClass();
-        while(c != null) {
-            try {
-                Field f = c.getField(k);
-                if (f != null) return wrap(f.get(this));
-            } catch (NoSuchFieldException nfe) {
-            } catch (IllegalAccessException nfe) {
-            } catch (SecurityException nfe) { }
-            c = c.getSuperclass();
-        }
-
-        try {
-            java.lang.reflect.Method[] methods = this.getClass().getMethods();
-            for(int i=0; i<methods.length; i++) if 
(methods[i].getName().equals(k)) return METHOD;
-        } catch (SecurityException nfe) { }
-        return null;
-    }
-
-    public void put(JS key, JS val) throws JSExn {
-        throw new JSExn("put() not supported yet");
-    }
-
-    public JS call(JS method, JS[] args) throws JSExn {
-        String k = JSU.toString(method);
-        try {
-            java.lang.reflect.Method[] methods = this.getClass().getMethods();
-            for(int j=0; j<methods.length; j++) {
-                if (methods[j].getName().equals(k) &&
-                    methods[j].getParameterTypes().length == args.length) {
-                    return wrap(methods[j].invoke(this, (Object[])args));
-                }
-            }
-        } catch (IllegalAccessException nfe) {
-        } catch (InvocationTargetException it) {
-            Throwable ite = it.getTargetException();
-            if (ite instanceof JSExn) throw ((JSExn)ite);
-            JSU.warn(ite);
-            throw new JSExn("unhandled reflected exception: " + 
ite.toString());
-        } catch (SecurityException nfe) { }
-        throw new JSExn("called a reflection method with the wrong number of 
arguments");
-    }
-} 

Deleted: core/trunk/org.ibex.js/src/org/ibex/js/PropertyFile.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/PropertyFile.java    2007-03-20 
13:17:35 UTC (rev 1741)
+++ core/trunk/org.ibex.js/src/org/ibex/js/PropertyFile.java    2007-03-20 
13:21:05 UTC (rev 1742)
@@ -1,53 +0,0 @@
-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
-// Licensed under the Apache Public Source License 2.0 ("the License").
-// You may not use this file except in compliance with the License.
-
-package org.ibex.js; 
-
-
-// FEATURE: Update for new api
-
-/** A JS interface to a Java '.properties' file; very crude */
-public class PropertyFile extends JS.Immutable {
-
-    /*private final Properties p = new Properties();
-    private final Hash cache = new Hash(10, 3);
-    private File f;
-
-    private class Minion extends JS {
-        private final String prefix;
-        Minion(String prefix) { this.prefix = prefix; }
-        public Number coerceToNumber()  { return N(coerceToString()); }
-        public Boolean coerceToBoolean() { return 
B(coerceToString().equals("true")); }
-        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 + (prefix.equals("") ? "" : ".") + 
escape(toString(key)), toString(val));
-                File fnew = new File(f.getName() + ".new");
-                FileOutputStream fo = new FileOutputStream(fnew);
-                p.save(fo, "");
-                fo.close();
-                fnew.renameTo(f);
-                f = fnew;
-            } catch (IOException e) { throw new JSExn(e); }
-        }
-    }
-
-    public static String escape(String s) {
-        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(); }
-    public Object get(Object key) throws JSExn {
-        Object ret = p.get(toString(key));
-        if (ret != null) return ret;
-        return new Minion(escape(toString(key)));
-    }*/
-}

Copied: core/trunk/org.ibex.js/src_unused/org/ibex/js/Directory.java (from rev 
1740, core/trunk/org.ibex.js/src/org/ibex/js/Directory.java)
===================================================================
--- core/trunk/org.ibex.js/src_unused/org/ibex/js/Directory.java                
                (rev 0)
+++ core/trunk/org.ibex.js/src_unused/org/ibex/js/Directory.java        
2007-03-20 13:21:05 UTC (rev 1742)
@@ -0,0 +1,136 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.js; 
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.ibex.io.Stream;
+import org.ibex.util.Encode;
+
+// FEATURE: support for move
+// FEATURE: support for bytestreams
+// FEATURE: cache directories so we can do equality checking on them?
+// FEATURE: autoconvert "true" to true and "0.3" to 0.3 on readback
+
+/** 
+ * A crude mechanism for using a filesystem as object storage.
+ *
+ *  This object represents a directory; writing a string, number, or
+ *  boolean to any of its properties will create a file with the
+ *  (encoded) property name as its filename and the "stringified"
+ *  value as its contents.
+ *
+ *  Writing 'null' to one of this object's properties will
+ *  [recursively if necessary] delete the corresponding directory
+ *  entry.
+ *  
+ *  Writing any other object to one of this object's properties will
+ *  create a new Directory object and copy the other object's keys()
+ *  into the new Directory.  This means that assigning one directory
+ *  to a property of another directory will <i>copy</i> the directory,
+ *  not move it.  There is currently no way to move directories.
+ *
+ *  If an object is written to a property that already has an entry,
+ *  the old one is deleted (equivalent to writing 'null') first.
+ * 
+ *  WARNING: when instantiating a Directory object with a file
+ *  argument that points to a non-directory File, this class will
+ *  delete that file and create a directory!
+ */
+public class Directory extends JS.Immutable {
+
+    File f;
+
+    /** 
+     *  Create the directory object.  Existing directories will be
+     *  preserved; if a file is present it will be obliterated.
+     */ 
+
+    public Directory(File f) throws IOException {
+        this.f = f;
+        if (!f.exists()) new Directory(new File(f.getParent()));
+        if (!f.isDirectory()) destroy(f);
+        f.mkdirs();
+    }
+
+    private static void destroy(File f) throws IOException {
+        if (!f.exists()) return;
+        if (f.isDirectory()) {
+            String[] entries = f.list();
+            for(int i=0; i<entries.length; i++) destroy(new 
File(f.getAbsolutePath() + File.separatorChar + entries[i]));
+        }
+        f.delete();
+    }
+
+    public void put(JS key0, JS val) throws JSExn {
+        try {
+            if (key0 == null) return;
+            String key = JSU.toString(key0);
+            File f2 = new File(f.getAbsolutePath() + File.separatorChar + 
Encode.toFilename(key));
+            destroy(f2);
+            if (val == null) return;
+            // FIXME - this cannot be right (JS never instance of io.Fountain)
+            if (val instanceof org.ibex.io.Fountain) {
+                Stream stream = ((org.ibex.io.Fountain)val).getStream();
+                Stream out = new Stream(null, new FileOutputStream(f2));
+                stream.transcribe(out);
+                out.close();
+            } else if (val instanceof JSPrimitive) {
+                OutputStream out = new FileOutputStream(f2);
+                Writer w = new OutputStreamWriter(out);
+                w.write(JSU.toString(val));
+                w.flush();
+                out.close();
+            } else {
+                Directory d2 = new Directory(f2);
+                JS.Enumeration e = val.keys();
+                while(e.hasNext()) {
+                    JS k = e.next();
+                    JS v = val.get(k);
+                    d2.put(k, v);
+                }
+            }
+        } catch (IOException ioe) {
+            throw new JSExn.IO(ioe);
+        }
+    }
+
+    public JS get(JS key0) throws JSExn {
+        try {
+            if (key0 == null) return null;
+            String key = JSU.toString(key0);
+            File f2 = new File(f.getAbsolutePath() + File.separatorChar + 
Encode.toFilename(key));
+            if (!f2.exists()) return null;
+            if (f2.isDirectory()) return new Directory(f2);
+            char[] chars = new char[((int)f2.length()) * 4 + 10];
+            int numchars = 0;
+            Reader r = new InputStreamReader(new FileInputStream(f2));
+            while(true) {
+                int numread = r.read(chars, numchars, chars.length - numchars);
+                if (numread == -1) return JSU.S(new String(chars, 0, 
numchars));
+                numchars += numread;
+            }
+        } catch (IOException ioe) {
+            throw new JSExn.IO(ioe);
+        }
+    }
+
+    public JS.Enumeration keys() {
+        final String[] elements = f.list();
+        return new JS.Enumeration(null) {
+                int i = 0;
+                public boolean _hasNext() { return i < elements.length; }
+                public JS _next() { return 
JSU.S(Encode.fromFilename(elements[i++])); }
+            };
+    }
+}

Copied: core/trunk/org.ibex.js/src_unused/org/ibex/js/JSReflection.java (from 
rev 1740, core/trunk/org.ibex.js/src/org/ibex/js/JSReflection.java)
===================================================================
--- core/trunk/org.ibex.js/src_unused/org/ibex/js/JSReflection.java             
                (rev 0)
+++ core/trunk/org.ibex.js/src_unused/org/ibex/js/JSReflection.java     
2007-03-20 13:21:05 UTC (rev 1742)
@@ -0,0 +1,129 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.js; 
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+
+/** Automatic JS-ification via Reflection (not for use in the core) */
+public class JSReflection extends JS.Immutable {
+    public static JS wrap(Object o) throws JSExn {
+        if (o == null) return null;
+        if (o instanceof String) return JSU.S((String)o);
+        if (o instanceof Boolean) return JSU.B(((Boolean)o).booleanValue());
+        if (o instanceof Number) return JSU.N((Number)o);
+        if (o instanceof JS) return (JS)o;
+        if (o instanceof Object[]) throw new JSExn("Reflection onto Object[] 
not supported yet");
+        return new Wrapper(o);
+    }
+
+    public static class Wrapper extends JS.Immutable {
+        private final Object o;
+        public Wrapper(Object o) { this.o = o; }
+        public Object unwrap() { return o; }
+        public Enumeration keys() throws JSExn { throw new 
JSExn("JSReflection.keys() not supported yet"); }
+        public JS get(JS key) throws JSExn {
+            String k = JSU.toString(key);
+            Class c = o.getClass();
+            while(c != null) {
+                try {
+                    Field f = c.getField(k);
+                    if (f != null) return wrap(f.get(o));
+                } catch (NoSuchFieldException nfe) {
+                } catch (IllegalAccessException nfe) {
+                } catch (SecurityException nfe) { }
+                c = c.getSuperclass();
+            }
+            
+            try {
+                java.lang.reflect.Method[] methods = o.getClass().getMethods();
+                for(int i=0; i<methods.length; i++) if 
(methods[i].getName().equals(k)) return METHOD;
+            } catch (SecurityException nfe) { }
+            return null;
+        }
+        
+        public void put(JS key, JS val) throws JSExn { throw new JSExn("put() 
not supported yet"); }
+        
+        public JS call(JS method, JS[] args) throws JSExn {
+            String k = JSU.toString(method);
+            try {
+                java.lang.reflect.Method[] methods = o.getClass().getMethods();
+                for(int j=0; j<methods.length; j++) {
+                    if (methods[j].getName().equals(k) &&
+                        methods[j].getParameterTypes().length == args.length) {
+                        return wrap(methods[j].invoke(o, (Object[])args));
+                    }
+                }
+            } catch (IllegalAccessException nfe) {
+            } catch (InvocationTargetException it) {
+                Throwable ite = it.getTargetException();
+                if (ite instanceof JSExn) throw ((JSExn)ite);
+                JSU.warn(ite);
+                throw new JSExn("unhandled reflected exception: " + 
ite.toString());
+            } catch (SecurityException nfe) { }
+            throw new JSExn("called a reflection method with the wrong number 
of arguments");
+        }
+    }
+
+    public static class Array extends JS.Immutable {
+        final Object[] arr;
+        public Array(Object[] arr) { this.arr = arr; }
+        // FEATURE: Add a JSCounterEnumeration
+        public Enumeration keys() throws JSExn {
+            return new Enumeration(null) {
+                private int n = 0;
+                public boolean _hasNext() { return n < arr.length; }
+                public JS _next() { return JSU.N(n++); }
+            };
+        }
+        public JS get(JS key) throws JSExn { return wrap(arr[JSU.toInt(key)]); 
}
+    }
+
+    public Enumeration keys() throws JSExn { throw new 
JSExn("JSReflection.keys() not supported yet"); }
+
+    public JS get(JS key) throws JSExn {
+        String k = JSU.toString(key);
+        Class c = this.getClass();
+        while(c != null) {
+            try {
+                Field f = c.getField(k);
+                if (f != null) return wrap(f.get(this));
+            } catch (NoSuchFieldException nfe) {
+            } catch (IllegalAccessException nfe) {
+            } catch (SecurityException nfe) { }
+            c = c.getSuperclass();
+        }
+
+        try {
+            java.lang.reflect.Method[] methods = this.getClass().getMethods();
+            for(int i=0; i<methods.length; i++) if 
(methods[i].getName().equals(k)) return METHOD;
+        } catch (SecurityException nfe) { }
+        return null;
+    }
+
+    public void put(JS key, JS val) throws JSExn {
+        throw new JSExn("put() not supported yet");
+    }
+
+    public JS call(JS method, JS[] args) throws JSExn {
+        String k = JSU.toString(method);
+        try {
+            java.lang.reflect.Method[] methods = this.getClass().getMethods();
+            for(int j=0; j<methods.length; j++) {
+                if (methods[j].getName().equals(k) &&
+                    methods[j].getParameterTypes().length == args.length) {
+                    return wrap(methods[j].invoke(this, (Object[])args));
+                }
+            }
+        } catch (IllegalAccessException nfe) {
+        } catch (InvocationTargetException it) {
+            Throwable ite = it.getTargetException();
+            if (ite instanceof JSExn) throw ((JSExn)ite);
+            JSU.warn(ite);
+            throw new JSExn("unhandled reflected exception: " + 
ite.toString());
+        } catch (SecurityException nfe) { }
+        throw new JSExn("called a reflection method with the wrong number of 
arguments");
+    }
+} 

Copied: core/trunk/org.ibex.js/src_unused/org/ibex/js/PropertyFile.java (from 
rev 1740, core/trunk/org.ibex.js/src/org/ibex/js/PropertyFile.java)
===================================================================
--- core/trunk/org.ibex.js/src_unused/org/ibex/js/PropertyFile.java             
                (rev 0)
+++ core/trunk/org.ibex.js/src_unused/org/ibex/js/PropertyFile.java     
2007-03-20 13:21:05 UTC (rev 1742)
@@ -0,0 +1,53 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.js; 
+
+
+// FEATURE: Update for new api
+
+/** A JS interface to a Java '.properties' file; very crude */
+public class PropertyFile extends JS.Immutable {
+
+    /*private final Properties p = new Properties();
+    private final Hash cache = new Hash(10, 3);
+    private File f;
+
+    private class Minion extends JS {
+        private final String prefix;
+        Minion(String prefix) { this.prefix = prefix; }
+        public Number coerceToNumber()  { return N(coerceToString()); }
+        public Boolean coerceToBoolean() { return 
B(coerceToString().equals("true")); }
+        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 + (prefix.equals("") ? "" : ".") + 
escape(toString(key)), toString(val));
+                File fnew = new File(f.getName() + ".new");
+                FileOutputStream fo = new FileOutputStream(fnew);
+                p.save(fo, "");
+                fo.close();
+                fnew.renameTo(f);
+                f = fnew;
+            } catch (IOException e) { throw new JSExn(e); }
+        }
+    }
+
+    public static String escape(String s) {
+        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(); }
+    public Object get(Object key) throws JSExn {
+        Object ret = p.get(toString(key));
+        if (ret != null) return ret;
+        return new Minion(escape(toString(key)));
+    }*/
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to