JGraphpad Pro
v6.0.5.0


com.jgraph.editor
Class JGraphEditorResources

java.lang.Object
  extended bycom.jgraph.editor.JGraphEditorResources

public class JGraphEditorResources
extends Object

Manages a set of resource bundles to retrieve keys and reads images and streams from the classpath. In order to find a key, the class searches all bundles in inverse insertion order (last inserted first).


Field Summary
protected static LinkedList bundles
          Ordered list of the inserted resource bundles.
 
Constructor Summary
JGraphEditorResources()
           
 
Method Summary
static void addBundle(String basename)
          Adds a resource bundle.
static void addBundles(String[] basenames)
          Adds an array of resource bundles using addBundle(String).
static LinkedList getBundles()
          Returns the bundles.
static ImageIcon getImage(String uri)
          Returns the specified file as an image or null if there was an exception.
static InputStream getInputStream(String uri)
          Returns the specified file as a buffered input stream or null if there was an exception.
static OutputStream getOutputStream(String uri)
          Returns a buffered output stream for the specified URI or null if there was an exception.
static String getString(String key)
          Returns the value for key by searching the resource bundles in inverse order or null if no value can be found for key.
static String getString(String key, Object param)
          Returns the value for key replacing every occurrence of {0} with param.
static String getString(String key, Object[] params)
          Returns the value for key replacing every occurrence of {i} with params[i] where i is an integer (i = 0, 1, ..., n).
static void setBundles(LinkedList bundles)
          Sets the bundles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bundles

protected static LinkedList bundles
Ordered list of the inserted resource bundles.

Constructor Detail

JGraphEditorResources

public JGraphEditorResources()
Method Detail

addBundle

public static void addBundle(String basename)
Adds a resource bundle.

Parameters:
basename - The basename of the resource bundle to add.

addBundles

public static void addBundles(String[] basenames)
Adds an array of resource bundles using addBundle(String).

Parameters:
basenames - The array of basenames to add.

getString

public static String getString(String key)
Returns the value for key by searching the resource bundles in inverse order or null if no value can be found for key.

Parameters:
key - The key to be searched for.
Returns:
Returns the value for key or null.
See Also:
ResourceBundle.getString(java.lang.String)

getString

public static String getString(String key,
                               Object param)
Returns the value for key replacing every occurrence of {0} with param. This is a shortcut method for values with only one placeholder.

Returns:
Returns the parametrized value for key.
See Also:
getString(String, Object[])

getString

public static String getString(String key,
                               Object[] params)
Returns the value for key replacing every occurrence of {i} with params[i] where i is an integer (i = 0, 1, ..., n).

Returns:
Returns the parametrized value for key.

getImage

public static ImageIcon getImage(String uri)
Returns the specified file as an image or null if there was an exception. Exceptions are silently ignored by this method. This implementation first tries to load the specified filename from the classpath. If the file cannot be found, it tries loading it as external file or URL.

Parameters:
uri - The URI to load the image from.
Returns:
Returns the image for filename.
See Also:
ImageIO.read(java.net.URL), Class.getResource(java.lang.String)

getInputStream

public static InputStream getInputStream(String uri)
                                  throws MalformedURLException,
                                         FileNotFoundException,
                                         IOException
Returns the specified file as a buffered input stream or null if there was an exception. Exceptions are silently ignored by this method. This implementation first tries to load the specified filename from the classpath. If the file cannot be found, it tries loading it as external file or URL.

Parameters:
uri - The URI to return the input stream for.
Returns:
Returns the input stream for filename.
Throws:
IOException - If the URI can not be read.
FileNotFoundException - If the URI can not be found.
MalformedURLException - If the URI is an invalid URL.
See Also:
Class.getResource(java.lang.String), URL.openStream(), BufferedInputStream

getOutputStream

public static OutputStream getOutputStream(String uri)
                                    throws FileNotFoundException
Returns a buffered output stream for the specified URI or null if there was an exception.

Parameters:
uri - The URI to return the output stream for.
Returns:
Returns an output stream for the specified URI.
Throws:
FileNotFoundException - If the specified URI can not be found.

getBundles

public static LinkedList getBundles()
Returns the bundles.

Returns:
Returns the bundles.

setBundles

public static void setBundles(LinkedList bundles)
Sets the bundles.

Parameters:
bundles - The bundles to set.

JGraphpad Pro
v6.0.5.0


Copyright (C) 2005 JGraph.com. All rights reserved.