org.pietschy.command
Class AbstractReflectionIconFactory

java.lang.Object
  extended by org.pietschy.command.AbstractReflectionIconFactory
All Implemented Interfaces:
IconFactory
Direct Known Subclasses:
MyAbstractReflectionIconFactory

public abstract class AbstractReflectionIconFactory
extends java.lang.Object
implements IconFactory

This implementation provides the basic infrastructure for translating the icon values to method calls. Subclasses must implement a method for every method type specified by the configuration files.

For example, a configuration of

   <icon type="icon-factory">createColoredIcon(200,127,127)<icon>
will result in a reflective call to the method
   public Icon createColoredIcon(String s1, String s2, String s3)
on the subclass.

See Also:
CommandManager.setIconFactory(IconFactory)

Constructor Summary
AbstractReflectionIconFactory()
           
 
Method Summary
 javax.swing.Icon createIcon(java.lang.String iconValue)
          Converts the the iconValue into a method call on this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractReflectionIconFactory

public AbstractReflectionIconFactory()
Method Detail

createIcon

public javax.swing.Icon createIcon(java.lang.String iconValue)
                            throws java.lang.Exception
Converts the the iconValue into a method call on this class.

For example, a configuration of

   <icon type="icon-factory">createColoredIcon(200,127,127)<icon>
will result in a reflective call to the method
   public Icon createColoredIcon(String s1, String s2, String s3)
on the subclass.

Specified by:
createIcon in interface IconFactory
Parameters:
iconValue - the icon text specified in the configuration file which will be interpreted as a method call on the subclass.
Returns:
an Icon created by the method specified in iconValue.
Throws:
java.lang.Exception - if the subclass throws and exception, or if there is an error invoking the method.