net.wotonomy.foundation.internal
Class URLResourceReader

java.lang.Object
  extended by net.wotonomy.foundation.internal.URLResourceReader

public class URLResourceReader
extends java.lang.Object

This implementation of URL Resource Reader assumes 2 types of base urls. A base url that ends with / is considered a resource folder, whereas a resource that does not end with / is considered a zip/jar resource folder. If the resource folder happens is a zip/jar archive, the entries are always cached. For non-zip base urls, one could specify whether or not it should be cached.

Author:
Harish Prabandham

Constructor Summary
URLResourceReader(java.io.InputStream is)
          Creates a new URLResourceReader object with the given input stream.
URLResourceReader(java.net.URL baseurl)
          equivalent to URLResourceReader(baseurl, false)
URLResourceReader(java.net.URL baseurl, boolean cache)
          Creates a new URLResourceReader object.
 
Method Summary
 void close()
           
 byte[] getResource(java.lang.String resource)
          Returns an array of bytes read for this resource if the resource exists.
 java.util.Enumeration getResourceNames()
          Returns an Enumeration of all "known" resource names.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLResourceReader

public URLResourceReader(java.net.URL baseurl,
                         boolean cache)
                  throws java.io.IOException
Creates a new URLResourceReader object. You can either give the URL of the zip/jar file or a base url where to look for additional resources. If the url ends with "/" then it is assumed to be a Base URL.

Parameters:
The - base url to look for the resources.
If - the base url is not a zip/jar, then true indicates that entries should be cached, false otherwise.
Throws:
java.io.IOException

URLResourceReader

public URLResourceReader(java.net.URL baseurl)
                  throws java.io.IOException
equivalent to URLResourceReader(baseurl, false)

Throws:
java.io.IOException

URLResourceReader

public URLResourceReader(java.io.InputStream is)
                  throws java.io.IOException
Creates a new URLResourceReader object with the given input stream. The stream is assumed to be a zip/jar stream.

Throws:
java.io.IOException
Method Detail

getResourceNames

public java.util.Enumeration getResourceNames()
Returns an Enumeration of all "known" resource names.


getResource

public byte[] getResource(java.lang.String resource)
Returns an array of bytes read for this resource if the resource exists. This method blocks until the resource has been fully read. If the resource does not exist, this method returns null.


close

public void close()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 null. All Rights Reserved.