Sophie Net: Vamp HQ - Luxor XUL - Rachel - Apollo - The Saturn Times - The Richmond Post
Rachel LogoOverview | Tutorial Part I | Part II | API Reference | FAQ | History | Powered By Rachel | License | Contact | Download | Source | Javadoc | Rachel @ Sourceforge

Rachel API Quick Reference

Intro

This page presents a quick reference to Rachel's API. The ResMan class provides centralized access to your icons, images, properties, text files, xml documents and more stored in your app's jars.

Resource Mangager (ResMan) Power Getter Method Line-Up

Method Description
String getText ( String name ) returns a text file stored in the app's jar as a String
ImageIcon getIcon ( String name ) returns an icon stored in the app's jar; supports gif and jpg formats.
BufferedImage getImage ( String name ) returns an image (aka graphic picture) stored in the app's jar; supports gif, jpgeg and png out-of-the-box; other formats supported through image i/o plugins
org.jdom.Document getXmlDocument ( String name ) returns an XML document stored in the app's jar as a parsed JDOM document
Properties getProperties ( String name ) returns a properties file stored in the app's jar as a property table
InputStream getInputStream ( String name ) returns a reference to the resources's InputStream
URL getUrl( String name ) returns the resources's URL

Resource Loader Config API

Method Description
ResourceLoader setResourceLoader ( ResourceLoader loader ) tells Rachel where to look for resources; see Resource Loader Overview for your choices

Resource Loader Overview

Class Description
rachel.loader.ClassResourceLoader gets resources out of jars identified by a single class (known as resource anchor)
rachel.loader.FileResourceLoader gets resources from the file system using the passed in directory as a root
rachel.loader.JarResourceLoader gets resources out of jars identified by URLs
rachel.loader.ResourceLoaderManager allows you to bundle together various resource loaders and pass it as a single unit to ResMan.setResourceLoader; note, that ResourceLoaderManager uses a linear search, that is, the first resource loader added will get consulted first, if he can't find the resource the ResourceLoaderManager tries the next one in line and so on.

Web Server Resource Loader Overview

Class Description
rachel.http.loader.ClassResourceLoader serves up resources out of jars identified by a single class (known as resource anchor)
rachel.http.loader.WebResourceManager allows you to bundle together various resource loaders and pass it as a single unit to Rachel's web server
setResourceLoader

tells Rachel where to look for resources; see Resource Loader Overview for your choices

Syntax:

ResourceLoader ResMan.setResourceLoader( ResourceLoader loader )
ResourceLoader ResourceManager.setResourceLoader( ResourceLoader loader )

Arguments:

loader
ResMan uses the passed in resource loader to retrieve resources; note, that you can bundle multiple resource loaders together using rachel.loader.ResourceLoaderManagager

Examples:

ResMan.setResourceLoader( new ClassResourceLoader( Tool.class ) );

ResourceLoaderManager roots = new ResourceLoaderManager();
roots.addResourceLoader( new ClassResourceLoader( CrossRefAnchor.class ) );
roots.addResourceLoader( new ClassResourceLoader( JavaDocAnchor.class ) );
ResMan.setResourceLoader( roots );
getText

returns a text file stored in the app's jar as a String

Syntax:

String ResMan.getText( String name )
String ResourceManager.getResourceAsString( String name )

Arguments:

name
the text file's internal path inside the jar

Prerequisites:

Examples:

String strunkHtmlSnippet = ResMan.getText( "strunk.html" );
getIcon

returns an icon stored in the app's jar; supports gif and jpg formats.

Syntax:

ImageIcon ResMan.getIcon( String name )
ImageIcon ResourceManager.getResourceAsIcon( String name )

Arguments:

name
the icon's internal path inside the jar

Prerequisites:

Examples:

ImageIcon appIcon = ResMan.getIcon( "images/inform.gif" ); 
getImage

returns an image (aka graphic picture) stored in the app's jar; getImage uses Java's 1.4 new plugable image i/o toolkit. Out-of-the-box it can read gif, jpeg and png graphics formats. If you need other formats such as bmp or tiff, for example, ship a image i/o plug-in with your app.

Syntax:

BufferedImage ResMan.getImage( String name )
BufferedImage ResourceManager.getResourceAsImage( String name )

Arguments:

name
the image's internal path inside the jar

Prerequisites:

Examples:

BufferedImage vanessaImg = ResMan.getImage( "images/vanessa.jpg" );
getXmlDocument

returns an XML document stored in the app's jar as a pre-parsed JDOM tree ready-to-use

Syntax:

org.jdom.Document ResMan.getXmlDocument( String name )
org.jdom.Document ResourceManager.getResourceAsXmlDocument( String name )

Arguments:

name
the xml document's internal path inside the jar

Prerequisites:

Examples:

Document doc = ResMan.getXmlDocument( "overview.xml" );
getProperties

returns a properties file stored in the app's jars as a property table

Syntax:

java.util.Properties ResMan.getProperties( String name )
java.util.Properties ResourceManager.getResourceAsProperties( String name )

Arguments:

name
the properties file's internal path inside the jar

Prerequisites:

Examples:

Properties props = ResMan.getProperties( "menu.properties" );
getInputStream

returns a reference to the resources's InputStream; use it if ResMan doesn't sport a power getter for your desired format yet (e.g. mp3 audio, mpeg video, etc.) or if you want to pass on the raw InputStream.

Syntax:

InputStream ResMan.getInputStream( String name )
InputStream ResourceManager.getResourceAsStream( String name )

Arguments:

name
the resources's internal path inside the jar

Prerequisites:

Examples:

InputStream inStream   = ResMan.getInputStream( "overview.xml" );
InputStream xslStream  = ResMan.getInputStream( "doc2html.xsl" );
More Quick Links: Batik SVG · Velocity · Python · Jython · JDOM · dom4j · Jaxen · Eclipse SWT · Mono · Mozilla · Web Start · Skin L&F · Kunststoff L&F
SourceForge Logo Send your comments, suggestions, praise or poems to webmistress@vamphq.com Copyright © 2001, 2002 Gerald Bauer