package net.xoetrope.deprecated.xui;
import java.applet.Applet;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.ResourceBundle;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Window;
import javax.swing.Icon;
import net.xoetrope.xui.XImageHolder;
import net.xoetrope.xui.XProject;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.helper.ResourceBundleLoader;
/**
* A class used to manage access to resources. This class wraps access to
* resources such as the files, images, readers and application objects such as
* Window and Frame references.<br>
* File access is provided so that the resource manager can determine the
* source of the file by searching the classpath.
* <p>Copyright (c) Xoetrope Ltd., 1998-2003<br>
* License: see license.txt
* $Revision: 1.4 $
*/
public class XResourceManager
{
private XProject project;
/**
* @deprecated since 2.0 use XProject instead
*/
protected XResourceManager( XProject proj )
{
project = proj;
project.setObject( "ResourceManager", this );
}
/**
* Gets an instance of the resource manager
* @return the XResourceManager instance
* @deprecated since 1.0.3
*/
public static XResourceManager getInstance()
{
XProject currentProject = XProjectManager.getCurrentProject();
XResourceManager rm = (XResourceManager)currentProject.getObject ( "ResourceManager" );
if ( rm == null )
rm = new XResourceManager( currentProject );
return rm;
}
/**
* Loads an image icon
* @param name the image resource name
* @return the image
* @deprecated since 2.0 use XProject instead
*/
public Icon getIcon( String name )
{
return (Icon)project.getIcon( name );
}
/**
* Loads an image resource
* @param name the image resource name
* @return the image
* @deprecated since 2.0 use XProject instead
*/
public Image getImage( String name )
{
return project.getImage( name );
}
/**
* Loads an image resource in a background thread
* @param holder the component containing to display the image
* @param name the image resource name
* @deprecated since 2.0 use XProject instead
*/
public synchronized void getImage( XImageHolder holder, String name )
{
project.getImage( holder, name );
}
/**
* Sets the startup file and loads the associated resource.
* @param fileName the name of the startup resource file.
* @deprecated since 1.0.3 use XProject.setStatupFile
*/
public void setStartupFile( String fileName )
{
project.setStartupFile( fileName );
}
/**
* Gets a startup parameter
* @param name the paramenter name
* @return the value
* @deprecated since 1.0.3 use project.getStartupParam
*/
public String getStartupParam( String name )
{
return project.getStartupParam( name );
}
/**
* Gets a startup parameter
* @param name the paramenter name
* @return the value
* @deprecated since 1.0.3 use XProject.getStartupParamAsInt
*/
public int getStartupParamAsInt( String name )
{
return project.getStartupParamAsInt( name );
}
/**
* Gets a stream for a resource
* @param fileName the resource file name
* @return the InputStream
* @deprecated since 2.0 use XProject instead
*/
public InputStream getInputStream( String fileName )
{
return project.getInputStream( fileName );
}
/**
* Gets a buffered stream for a resource
* @param s the resource name
* @return the input stream
* @deprecated since 2.0 use XProject instead
*/
public BufferedInputStream getBufferedInputStream( String s )
{
return project.getBufferedInputStream( s );
}
/**
* Gets a URL for a resource
* @param fileName the resource file name
* @return the InputStream
* @deprecated since 2.0 use XProject instead
*/
public URL getUrl( String fileName )
{
return project.getUrl( fileName );
}
/**
* Add a custom class loader. Customer class loaders are sometimes added to
* help locate resources in file structures, jars, remote locations etc...
* @param c the classloader
* @deprecated since 2.0 use XProject instead
*/
public void addCustomClassLoader( ClassLoader c )
{
project.addCustomClassLoader( c );
}
/**
* Gets a stream for a file
* @param file the file
* @return the input stream
* @deprecated since 2.0 use XProject instead
*/
public InputStream getInputStream( File file )
{
return project.getInputStream( file );
}
/**
* Gets a buffered stream for a file
* @param file the file
* @return the input stream
* @deprecated since 2.0 use XProject instead
*/
public BufferedInputStream getBufferedInputStream( File file )
{
return project.getBufferedInputStream( file );
}
/**
* Gets a BufferedReader for a resource
* @param file the resource file name
* @return the BufferedReader
* @deprecated since 2.0 use XProject instead
*/
public BufferedReader getBufferedReader( String file ) throws Exception
{
return project.getBufferedReader( file );
}
/**
* Gets a BufferedReader for a resource
* @param file the resource file name
* @param encoding the input encoding e.g. "UTF8" or null for the default
* encoding (UTF8 unless it has been changed)
* @return the BufferedReader
* @deprecated since 2.0 use XProject instead
*/
public BufferedReader getBufferedReader( String file, String encoding ) throws Exception
{
return project.getBufferedReader( file, encoding );
}
/**
* Gets a BufferedReader for a resource
* @param file the resource file
* @param encoding the input encoding e.g. "UTF8" or null for the default
* encoding (UTF8 unless it has been changed)
* @return the BufferedReader
* @deprecated since 2.0 use XProject instead
*/
public BufferedReader getBufferedReader( File file, String encoding ) throws Exception
{
return project.getBufferedReader( file, encoding );
}
/**
* Gets a stream for a file
* @param file the file
* @return the output stream
* @deprecated since 2.0 use XProject instead
*/
public OutputStream getOutputStream( String file )
{
return project.getOutputStream( file );
}
/**
* Gets a buffered stream for a file
* @param file the file
* @return the output stream
* @deprecated since 2.0 use XProject instead
*/
public BufferedOutputStream getBufferedOutputStream( String file )
{
return project.getBufferedOutputStream( file );
}
/**
* Gets a stream for a file
* @param file the file
* @param useProjectParent use the projects default file specification to locate the file
* @return the output stream
* @deprecated since 2.0 use XProject instead
*/
public OutputStream getOutputStream( String file, boolean useProjectParent )
{
return project.getOutputStream( file, useProjectParent );
}
/**
* Gets a buffered stream for a file
* @param file the file
* @param useProjectParent use the projects default file specification to locate the file
* @return the output stream
* @deprecated since 2.0 use XProject instead
*/
public BufferedOutputStream getBufferedOutputStream( String file, boolean useProjectParent )
{
return project.getBufferedOutputStream( file, useProjectParent );
}
/**
* Set the default package name. The default package name is used when
* constructing widgets.
* @param pn
* @deprecated since 2.0 use XProject instead
*/
public void setPackageName( String pn )
{
project.setPackageName( pn );
}
/**
* Get the default package name
* @return the default package name
* @deprecated since 2.0 use XProject instead
*/
public String getPackageName()
{
return project.getPackageName();
}
/**
* Get the applet document base.
* @return the url
* @deprecated since 2.0 use XProject instead
*/
public URL getDocumentBase()
{
return project.getDocumentBase();
}
/**
* Set/Record the URL from which the applet was loaded
* @param u
* @deprecated since 2.0 use XProject instead
*/
public void setDocumentBase( URL u )
{
project.setDocumentBase( u );
}
/**
* Set tbe applet reference
* @param applet
* @deprecated since 2.0 use XProject instead
*/
public void setApplet( Applet applet )
{
project.setApplet( applet );
}
/**
* Set the main Frame reference
* @param frame
* @deprecated since 2.0 use XProject instead
*/
public void setAppFrame( Frame frame )
{
project.setAppFrame( frame );
}
/**
* Set the main Window reference
* @param window
* @deprecated since 2.0 use XProject instead
*/
public void setAppWindow( Window window )
{
project.setAppWindow( window );
}
/**
* Get a reference to the applet object
* @return a reference to the applet
* @deprecated since 2.0 use XProject instead
*/
public Applet getApplet()
{
return project.getApplet();
}
/**
* Get a areference to the applet's Frame
* @return a reference to the frame
* @deprecated since 2.0 use XProject instead
*/
public Frame getAppFrame()
{
return project.getAppFrame();
}
/**
* Get a reference to the application's main Window
* @return a reference to the Window
* @deprecated since 2.0 use XProject instead
*/
public Window getAppWindow()
{
return project.getAppWindow();
}
/**
* Reset the reference to the resourceManager singleton
* @deprecated since 2.0 use XProject instead
*/
public void reset()
{
}
/**
* Get the default file encoding (UTF8 unless modified)
* @return the encoding
* @deprecated since 2.0 use XProject instead
*/
public String getDefaultEncoding()
{
return project.getDefaultEncoding();
}
/**
* Set the default file encoding (UTF8 unless modified)
* @see http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
* @param encoding the encoding e.g. "UTF8" or "ISO-8859-1"
* @deprecated since 2.0 use XProject instead
*/
public void setDefaultEncoding( String encoding )
{
project.setDefaultEncoding( encoding );
}
/**
* Set the object to load language resource bundles
* @param loader the new loader
* @deprecated since 2.0 use XProject instead
*/
public void setResourceBundleLoader( ResourceBundleLoader loader )
{
project.setResourceBundleLoader( loader );
}
/**
* Get the resource bundle loader
* @return the loader
* @deprecated since 2.0 use XProject instead
*/
public ResourceBundleLoader getResourceBundleLoader()
{
return project.getResourceBundleLoader();
}
/**
* Get a resource bundle
* @param name the unqualified name of the resource bundle
* @deprecated since 2.0 use XProject instead
*/
public ResourceBundle getResourceBundle( String name )
{
return project.getResourceBundle( name );
}
/**
* Set the default file/directory specification used to locate files by the
* getOutputStream( String file, boolean useProjectParent ) method
* @param file the file or directory specification
* @deprecated since 2.0 use XProject instead
*/
public void setDefaultFile( String file )
{
project.setDefaultFile( file );
}
}