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 61 73 public class JavaUrl extends IVUrl { 74 75 private Class clazz; 76 77 public JavaUrl( String surl ) throws IVException { 78 parse( surl ); 79 } 80 81 protected void parse( String s ) throws IVException { 82 int idx = s.indexOf('?'); 83 if( idx >= 0 && idx < 10 ) { 84 throw new IVException(Resource.INVALURL, new Object [] {s}); 85 } 86 87 String className; 88 if( idx == -1 ) { 89 className = s.substring(10); 90 } else { 91 className = s.substring( 10, idx ); 92 } 93 try { 94 clazz = Class.forName(className); 95 } catch( Exception e ) { 96 throw new IVException(Resource.INVALURL, new Object [] {s}, e); 97 } 98 99 if( idx >= 0 ) parse(s, idx); 100 } 101 102 public String getName() { 103 return clazz.getName(); 104 } 105 106 public InputStream getInputStream() throws IOException { 107 InputStream is = null; 108 try { 109 Method getStream = clazz.getMethod("getStream", new Class [] { Hashtable.class } ); 110 is = (InputStream) getStream.invoke( null, new Object [] { parms } ); 111 } catch( Exception e ) { 112 throw new IOException( e.getLocalizedMessage() ); 113 } 114 if (is == null) 117 throw new IOException("null input stream"); 118 return is; 119 } 120 121 } 122 | Popular Tags |