nl.uva.vlet.util
Class ResourceLoader

java.lang.Object
  extended by nl.uva.vlet.util.ResourceLoader

public class ResourceLoader
extends java.lang.Object

Alternative ResourceLoader which supports VRLs and URIs. Note: since this class might be used at init time, the VRS/Registry can't be used ! To be compatible with 'applet' mode an be usefull at init time, the URL class is used to provide input streams. If the Registry is properly initialezed URL class can handle VRLs, if not it will defaul to standaard URLs (And exception will be trown is the VRL is not an URL).


Field Summary
static java.lang.String CHARSET_ISO_8859_1
          8-bits US/Euro 'standard' encoding
static java.lang.String CHARSET_LATIN
          Same as ISO-8859-1
static java.lang.String CHARSET_US_ASCII
          7-bits (US) Ascii, mother of all ASCII's
static java.lang.String CHARSET_UTF16BE
           
static java.lang.String CHARSET_UTF16LE
           
static java.lang.String CHARSET_UTF8
           
static java.lang.String DEFAULT_CHARSET
           
 
Constructor Summary
ResourceLoader()
           
 
Method Summary
static javax.swing.ImageIcon getIcon(java.lang.String vrl)
          Just fetch uncached icon from specified (relative) url or full path.
static javax.swing.Icon getIconOrDefault(java.lang.String url)
           
static java.awt.Image getImage(java.lang.String url)
          Load (a)synchronously an image specified by VRL URI.
static java.io.InputStream getInputstream(java.lang.String urlstr)
          Tries to load resource from relative or absolute url: - get current classLoader to resource 'urlstr' - get thread classload to resolve 'urlstr' - tries if urlstr is an absolute url and performs openConnection().getInputStream()
static java.io.InputStream getInputstream(VRL uri)
          Returns an inputstream from the specified URI.
static java.io.OutputStream getOutputStream(java.lang.String locstr)
           
static java.io.OutputStream getOutputStream(VRL vrl)
           
static java.lang.String getText(java.io.InputStream inps, int maxSize, java.lang.String charset)
          Read text from input stream in encoding 'charset'.
static java.lang.String getText(java.io.InputStream inps, java.lang.String charset)
           
static java.lang.String getText(VNode node)
           
static java.lang.String getText(VRL loc)
           
static java.lang.String getText(VRL location, int maxSize, java.lang.String charset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARSET_UTF8

public static final java.lang.String CHARSET_UTF8
See Also:
Constant Field Values

CHARSET_UTF16BE

public static final java.lang.String CHARSET_UTF16BE
See Also:
Constant Field Values

CHARSET_UTF16LE

public static final java.lang.String CHARSET_UTF16LE
See Also:
Constant Field Values

CHARSET_US_ASCII

public static final java.lang.String CHARSET_US_ASCII
7-bits (US) Ascii, mother of all ASCII's

See Also:
Constant Field Values

CHARSET_ISO_8859_1

public static final java.lang.String CHARSET_ISO_8859_1
8-bits US/Euro 'standard' encoding

See Also:
Constant Field Values

CHARSET_LATIN

public static final java.lang.String CHARSET_LATIN
Same as ISO-8859-1

See Also:
Constant Field Values

DEFAULT_CHARSET

public static final java.lang.String DEFAULT_CHARSET
See Also:
Constant Field Values
Constructor Detail

ResourceLoader

public ResourceLoader()
Method Detail

getImage

public static java.awt.Image getImage(java.lang.String url)
Load (a)synchronously an image specified by VRL URI. Support URLs and VRS locations as well as (CLASSPATH) relative URLs (icons/myicon.gif). Checks whether 'url' is on of the following: I) relative URL from context classpath II) relative URL from default classpath III) global URL


getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String vrl)
Just fetch uncached icon from specified (relative) url or full path. This class does not do any caching or scaling. Use (gui.util) IconRender.getIcon() class for rendered&cached icons.

Parameters:
vrl -
Returns:
Throws:
VlException

getInputstream

public static java.io.InputStream getInputstream(java.lang.String urlstr)
                                          throws VlIOException,
                                                 VlURISyntaxException
Tries to load resource from relative or absolute url: - get current classLoader to resource 'urlstr' - get thread classload to resolve 'urlstr' - tries if urlstr is an absolute url and performs openConnection().getInputStream()

Parameters:
urlstr -
Returns:
Throws:
VlIOException
VlURISyntaxException

getInputstream

public static java.io.InputStream getInputstream(VRL uri)
                                          throws VlException
Returns an inputstream from the specified URI.

Parameters:
uri -
Returns:
Throws:
VlException

getText

public static java.lang.String getText(java.io.InputStream inps,
                                       java.lang.String charset)
                                throws VlIOException
Throws:
VlIOException

getText

public static java.lang.String getText(VRL location,
                                       int maxSize,
                                       java.lang.String charset)
                                throws VlException
Throws:
VlException

getText

public static java.lang.String getText(VRL loc)
                                throws VlException
Throws:
VlException

getText

public static java.lang.String getText(VNode node)
                                throws VlException
Throws:
VlException

getText

public static java.lang.String getText(java.io.InputStream inps,
                                       int maxSize,
                                       java.lang.String charset)
                                throws VlIOException
Read text from input stream in encoding 'charset'. (Default is utf-8) Does this line by line. Line seperators might be changed!

Parameters:
inps -
charset -
Returns:
Throws:
VlIOException

getOutputStream

public static java.io.OutputStream getOutputStream(java.lang.String locstr)
                                            throws VlException
Throws:
VlException

getOutputStream

public static java.io.OutputStream getOutputStream(VRL vrl)
                                            throws VlException
Throws:
VlException

getIconOrDefault

public static javax.swing.Icon getIconOrDefault(java.lang.String url)