1 50 51 package org.openlaszlo.iv.flash.util; 52 53 import java.io.*; 54 import java.net.*; 55 import java.util.*; 56 import org.openlaszlo.iv.flash.api.*; 57 import org.openlaszlo.iv.flash.url.*; 58 59 72 public class UrlDataSource extends DataSource { 73 74 private IVUrl url; 75 76 public UrlDataSource() {} 77 78 94 public UrlDataSource( String surl, FlashFile flashFile ) throws IVException, IOException { 95 url = null; 96 97 if( surl == null || surl.length() == 0 ) { 98 throw new IOException( "null datasource" ); 99 } 100 101 if( surl.charAt(0) == '#' || surl.charAt(0) == '=' ) { 102 setReader( new NativeLineReader(surl) ); 103 } else { 104 StringTokenizer st = new StringTokenizer(surl, ";"); 105 IVVector urls = new IVVector(); 106 while( st.hasMoreTokens() ) { 107 url = IVUrl.newUrl( st.nextToken(), flashFile ); 108 urls.addElement(url); 109 } 110 if( urls.size() > 1 ) { 111 url = null; 112 setReader( new MultipleUrlsReader(urls, flashFile) ); 113 } else { 114 if( !url.hasDataReady() ) { 115 setReader(Util.getUrlReader(flashFile, url)); 116 } 117 } 118 } 119 } 120 121 127 public String [][] getData() throws IOException { 128 if( url != null && url.hasDataReady() ) return url.getData(); 129 return super.getData(); 130 } 131 } | Popular Tags |