Cramfull Compiled Resources v2.00

be.arci.pub
Class ResourceViewer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--be.arci.pub.ResourceViewer
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable, java.awt.event.WindowListener

public class ResourceViewer
extends java.applet.Applet
implements java.awt.event.WindowListener, java.awt.event.MouseListener, java.awt.event.ItemListener

Utility class to view, list or dump the resources contained by compiler Cramfull subclasses.

We supply this class as a free service to all users of the Cramfull Compiled Resources library. You are allowed to modify this source code, provided you move the class out of the be.arci package hierarchy.

ResourceViewer plays audio files and views images and animated images. ResourceViewer also displays .properties files as a list of key = value pairs, either for a single .properties resource or for a locale hierarchy of .properties resources, and deserializes stored objects. Other resource types are displayed in hex byte and ASCII format.

You can use ResourceViewer as applet or as an application.

As an applet

These are the possible applet parameters:
resources
a qualified Java class name of the Cramfull subclass, e.g. "org.anic.food.NaturalResources"
single
If true, ResourceViewer loads a single instance using the exact name of the resources parameter. By default ResourceViewer loads a locale-hierarchy using ResourceBundle.getBundle(), with the resources parameter as base name
locale
Locale to use with ResourceBundle.getBundle() (e.g. _fr_CA or _nl_BE_EURO, default getDefaultLocale())
zoom
If true, ResourceViewer zooms in on small images
hexbytes
The number of hex bytes to display for unhandled resource types (default 480)

Example:

<APPLET CODE=be.arci.pub.ResourceViewer WIDTH=700 HEIGHT=400> <PARAM NAME=resources VALUE=org.anic.food.NaturalResources> <PARAM NAME=single VALUE=true> <PARAM NAME=hexbytes VALUE=640> <PARAM NAME=zoom VALUE=true> </APPLET>

As an application

The equivalent command-line parameters are

java be.arci.pub.ResourceViewer [arguments]

ARGUMENTS:

resources
Cramfull subclass; escape leading '-' in the classname with a leading '--'
-s
Single instance (see Applet)
-lLocale
Locale for getBundle() (see Applet)
-z
Zoom (see Applet)
-h###
Number of hex bytes (see Applet)
-l
List all resources in a single instance or getBundle hierarchy
-d
Sets debug mode: list all resources collected from a class file.
-dBaseDir
Dump all contained resources (wether loaded as single instance or as locale-hierarchy) to the local file system, creating any necessary directories starting from the (existing) directory BaseDir.
-o
The above dump runs in overwrite mode

Since:
05/nov/2000
See Also:
Cramfull, Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
ResourceViewer()
           
 
Method Summary
protected  void checkContents()
          View list of resources or dump them all to local file system
 java.lang.String[][] getParameterInfo()
           
 void init()
           
 void itemStateChanged(java.awt.event.ItemEvent e)
           
static void main(java.lang.String[] args)
          Runs ResourceViewer as an application
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void showResource(java.lang.String sResource)
          Displays current resource (current item in lstResources) in pnlResource, depending on it's MIME type or it's resource name.
 void sort(java.awt.List lst)
          Simple sort routine for small collections
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent we)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceViewer

public ResourceViewer()
Method Detail

main

public static void main(java.lang.String[] args)
Runs ResourceViewer as an application

init

public void init()
Overrides:
init in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent we)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

checkContents

protected void checkContents()
View list of resources or dump them all to local file system

showResource

public void showResource(java.lang.String sResource)
Displays current resource (current item in lstResources) in pnlResource, depending on it's MIME type or it's resource name.
  1. If the MIME type starts with "audio/", we play an AudioClip.
  2. If the MIME type starts with "image/", we display an Image.
  3. If the resource name starts with SERIALIZED_TAG, we display a deserialized Object.
  4. If the resource name ends with .properties, and contains an underscore ('_'), we load a set of Properties objects
  5. If the resource name ends with .properties, and does not contain an underscore ('_'), we load a locale hierarchy of Properties objects with the resource name (.properties suffix truncated) as base name.
  6. For other resources, we display the first n hexadecimal bytes side by side with their ASCII character value.

Parameters:
sResource - current resource name
See Also:
SerializingResourceCompiler.SERIALIZED_TAG

sort

public void sort(java.awt.List lst)
Simple sort routine for small collections

Cramfull Compiled Resources v2.00