Revision: 2464
http://vexi.svn.sourceforge.net/vexi/?rev=2464&view=rev
Author: mkpg2
Date: 2007-10-14 20:19:24 -0700 (Sun, 14 Oct 2007)
Log Message:
-----------
Feature. Create templates from strings (via blessing named,non-dir streams).
Cleaned up Fountain.
Modified Paths:
--------------
trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java
trunk/core/org.ibex.js/src/org/ibex/js/SOAP.java
trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp
trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountainKeys.java
Modified: trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java 2007-10-15
03:19:14 UTC (rev 2463)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java 2007-10-15
03:19:24 UTC (rev 2464)
@@ -169,10 +169,7 @@
/** byte arrays */
public static class ByteArray extends Fountain {
private byte[] bytes;
- private String cacheKey;
- public ByteArray(byte[] bytes, String cacheKey) { this.bytes = bytes;
this.cacheKey = cacheKey; }
- public String getCacheKey() throws NotCacheableException {
- if (cacheKey == null) throw new NotCacheableException(); return
cacheKey; }
+ public ByteArray(byte[] bytes) { this.bytes = bytes; }
public InputStream getInputStream() throws IOException { return new
ByteArrayInputStream(bytes); }
}
@@ -185,7 +182,6 @@
try{this.path = new
java.io.File(path).getCanonicalPath();}catch(IOException e){throw new
JSExn(e.getMessage());}
this.writeable = writeable;}
public String canonical() { return "file://"+path; }
- public String getCacheKey() throws NotCacheableException { throw new
NotCacheableException(); /* already on disk */ }
public InputStream getInputStream() throws IOException {
try{return new FileInputStream(path);
}catch(FileNotFoundException e){return null;}
@@ -202,7 +198,7 @@
}else
throw new JSExn("not writeable " + writeable);
}
- Set _getKeyCache() throws IOException {
+ Set _getKeySet() throws IOException {
Set s = new HashSet();
java.io.File f = new java.io.File(path);
if(f.isDirectory()){
@@ -241,7 +237,7 @@
public int getLength() { return length; }
};*/
}
- Set _getKeyCache() throws IOException{
+ Set _getKeySet() throws IOException{
InputStream pis = parent.getInputStream();
ZipInputStream zis = new ZipInputStream(pis);
ZipEntry ze = zis.getNextEntry();
@@ -327,13 +323,13 @@
return null;
}
- Set _getKeyCache(){
+ Set _getKeySet(){
Set s = new HashSet();
// Done in 'correct' order, but actually order here is
unimportant.
for (int i=fountains.size()-1; i>=0 ; i--) {
Fountain stream = (Fountain)fountains.elementAt(i);
try{
- Set s2 = stream.getKeyCache();
+ Set s2 = stream.getKeySet();
s.addAll(s2);
}catch(IOException e){
Log.warn(Multiple.class, "Couldn't access
substream "+e.getMessage());
@@ -478,7 +474,7 @@
// pushed up to the JS interface itself.
public Keys keys(JS principal) throws JSExn {
try {
- final Set s = getKeyCache();
+ final Set s = getKeySet();
return new Keys(this){
protected JS contains(JS key){return
JSU.B(s.contains(JSU.toString(key)));}
public Enumeration iterator() throws JSExn{
@@ -497,14 +493,14 @@
}
}
WeakReference keyCache = null;
- Set getKeyCache() throws IOException{
+ Set getKeySet() throws IOException{
Set s = (Set) ((keyCache==null)?null:keyCache.get());
if(s==null){
- s = _getKeyCache();
+ s = _getKeySet();
}
return s;
}
- Set _getKeyCache() throws IOException{
+ Set _getKeySet() throws IOException{
throw new IOException("Cannot list " + getClass().getSimpleName());
}
Modified: trunk/core/org.ibex.js/src/org/ibex/js/SOAP.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/SOAP.java 2007-10-15 03:19:14 UTC
(rev 2463)
+++ trunk/core/org.ibex.js/src/org/ibex/js/SOAP.java 2007-10-15 03:19:24 UTC
(rev 2464)
@@ -93,7 +93,7 @@
} else if (me instanceof byte[]) {
objects.pop();
- objects.push(new Fountain.ByteArray(Encode.fromBase64(new
String(content.getBuf(), 0, content.size())), null));
+ objects.push(new Fountain.ByteArray(Encode.fromBase64(new
String(content.getBuf(), 0, content.size()))));
content.reset();
} else if (me instanceof Integer) {
Modified: trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp 2007-10-15 03:19:14 UTC
(rev 2463)
+++ trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp 2007-10-15 03:19:24 UTC
(rev 2464)
@@ -113,8 +113,7 @@
case "string": setLast(JSU.S(new String(content.getBuf(), 0,
content.size())));
case "double": setLast(JSU.N(Double.parseDouble(new
String(content.getBuf(), 0, content.size()))));
case "base64":
- setLast(new Fountain.ByteArray(Encode.fromBase64(new
String(content.getBuf(), 0, content.size())),
- null));
+ setLast(new Fountain.ByteArray(Encode.fromBase64(new
String(content.getBuf(), 0, content.size()))));
case "name": objects.add(JSU.S(new String(content.getBuf(), 0,
content.size())));
case "value": if ("".equals(objects.peek()))
setLast(JSU.S(new String(content.getBuf(), 0,
content.size())));
Modified: trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountainKeys.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountainKeys.java
2007-10-15 03:19:14 UTC (rev 2463)
+++ trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountainKeys.java
2007-10-15 03:19:24 UTC (rev 2464)
@@ -112,22 +112,22 @@
File tmpDir = Util.createTmpDir();
File zip = createZip(tmpDir, filenames);
Fountain.Zip fz = new Fountain.Zip(new
Fountain.File(zip.getAbsolutePath()));
- assertKeys("", fz.getKeyCache(),3);
+ assertKeys("", fz.getKeySet(),3);
Fountain.Zip fza = (Zip) fz.get(JSU.S("dira"));
- assertKeys("dira",fza.getKeyCache(),2);
+ assertKeys("dira",fza.getKeySet(),2);
Fountain.Zip fzb = (Zip) fz.get(JSU.S("dirb"));
- assertKeys("dirb",fzb.getKeyCache(),1);
+ assertKeys("dirb",fzb.getKeySet(),1);
}
public void testFile() throws Exception {
File tmpDir = Util.createTmpDir();
File f = createHierarchy(tmpDir);
Fountain.File ff = new Fountain.File(f.getAbsolutePath());
- assertKeys("", ff.getKeyCache(),3);
+ assertKeys("", ff.getKeySet(),3);
Fountain.File fza = (Fountain.File) ff.get(JSU.S("dira"));
- assertKeys("dira",fza.getKeyCache(),2);
+ assertKeys("dira",fza.getKeySet(),2);
Fountain.File fzb = (Fountain.File) ff.get(JSU.S("dirb"));
- assertKeys("dirb",fzb.getKeyCache(),1);
+ assertKeys("dirb",fzb.getKeySet(),1);
}
private void assertSize(int expected, JS keys) throws JSExn{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn