1 50 51 package org.openlaszlo.iv.flash.url; 52 53 import java.lang.reflect.*; 54 import java.io.*; 55 import java.util.*; 56 import java.net.*; 57 import java.sql.*; 58 import org.openlaszlo.iv.flash.util.*; 59 import org.openlaszlo.iv.flash.api.*; 60 import org.openlaszlo.iv.flash.js.*; 61 62 69 public class JSUrl extends IVUrl { 70 71 private String fileName; 72 private FlashFile flashFile; 73 74 public JSUrl( String surl, FlashFile flashFile ) throws IVException { 75 this.flashFile = flashFile; 76 parse( surl ); 77 } 78 79 protected void parse( String s ) throws IVException { 80 int idx = s.indexOf('?'); 81 if( idx >= 0 && idx < 8 ) { 82 throw new IVException(Resource.INVALURL, new Object [] {s}); 83 } 84 85 if( idx == -1 ) { 86 fileName = s.substring(8); 87 } else { 88 fileName = s.substring(8, idx); 89 } 90 91 File file = new File(fileName); 92 if( !file.isAbsolute() && flashFile != null ) 93 file = new File(flashFile.getFileDir(), file.getPath()); 94 fileName = file.getAbsolutePath(); 95 96 if( idx >= 0 ) parse(s, idx); 97 } 98 99 public String getName() { 100 return fileName; 101 } 102 103 public InputStream getInputStream() throws IOException { 104 FlashBuffer fb = new FlashBuffer(100); 105 PrintStream out = new PrintStream(fb.getOutputStream()); 106 String [] args = new String [parms!=null?parms.size():0]; 107 if( parms != null ) { 108 int i=0; 109 for( Enumeration e = parms.keys(); e.hasMoreElements(); ) { 110 args[i++] = (String ) e.nextElement(); 111 } 112 } 113 114 JSHelper.execFile(fileName, args, out); 115 out.flush(); 116 117 return fb.getInputStream(); 118 } 119 120 } 121 122 | Popular Tags |