net.sourceforge.pavlov.pluglets
Class PlugletLoader

java.lang.Object
  extended by net.sourceforge.pavlov.pluglets.PlugletLoader
Direct Known Subclasses:
StrategyLoader, VelocityPlugletLoader

public class PlugletLoader
extends Object

PlugletLoader Generates a vector of objects that are a subclass of a given class. These objects must have a no-arg constructor and be in a given directory. If a serious error occurs (no such directory, can't read directory, no files) the vector will be null. Otherwise, individual classes are skipped. Current implementation prints status and error/exception information to stdout. There is, at this time, little support for JarFiles or subdirectories.


Field Summary
protected static Category cat
           
protected  Vector<Pluglet> pluglets
          Vector of pluglets that have been successfully loaded.
 
Constructor Summary
protected PlugletLoader()
           
  PlugletLoader(String baseClassName, String directory)
          Creates a new PlugletLoader instance.
 
Method Summary
 void addToAnswerEventProducer(AnswerEventProducer cont)
          Deprecated. This should be in FeedbackPluglet
 void addToContainer(Container cont)
          Add each of my pluglets that are a subclass of java.awt.Component, to the given java.awt.Container.
 void addToJMenuAsCheckboxes(JMenu menu)
          Given a JMenu, will add to it each loaded pluglet as a JCheckboxMenuItem.
 ButtonGroup addToJMenuAsRadioButtons(JMenu menu)
          Given a JMenu, will add to it each loaded pluglet as a JRadioButtonMenuItem.
 Pluglet getPluginByName(String name)
          Returns the named plugin if it exists, otherwise null.
 boolean isAJarFile(File f)
          Returns true if the file is recognized as a Jar file.
protected  String mungeName(String in)
          Returns the filename, sans extention, of a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pluglets

protected Vector<Pluglet> pluglets
Vector of pluglets that have been successfully loaded.


cat

protected static final Category cat
Constructor Detail

PlugletLoader

protected PlugletLoader()

PlugletLoader

public PlugletLoader(String baseClassName,
                     String directory)
Creates a new PlugletLoader instance.

Parameters:
baseClassName - a String value
directory - a String value
Method Detail

addToJMenuAsCheckboxes

public void addToJMenuAsCheckboxes(JMenu menu)
Given a JMenu, will add to it each loaded pluglet as a JCheckboxMenuItem. The item's name will be the pluglet's getText() and the item's tooltip will be the pluglet's getDescription().

Parameters:
menu - a JMenu value

addToJMenuAsRadioButtons

public ButtonGroup addToJMenuAsRadioButtons(JMenu menu)
Given a JMenu, will add to it each loaded pluglet as a JRadioButtonMenuItem. The item's name will be the pluglet's getText() and the item's tooltip will be the pluglet's getDescription(). Returns the ButtonGroup to which the items belong.

Parameters:
menu - a JMenu value
Returns:
a ButtonGroup value

addToContainer

public void addToContainer(Container cont)
Add each of my pluglets that are a subclass of java.awt.Component, to the given java.awt.Container.

Parameters:
cont - a Container value

getPluginByName

public Pluglet getPluginByName(String name)
Returns the named plugin if it exists, otherwise null.

Parameters:
name - a String value
Returns:
a Pluglet value

addToAnswerEventProducer

@Deprecated
public void addToAnswerEventProducer(AnswerEventProducer cont)
Deprecated. This should be in FeedbackPluglet

Describe addToAnswerEventProducer method here.

Parameters:
cont - an AnswerEventProducer value

mungeName

protected String mungeName(String in)
Returns the filename, sans extention, of a given string. FIXME: this can be implemented with java.io.File methods

Parameters:
in - a String value
Returns:
a String value

isAJarFile

public boolean isAJarFile(File f)
Returns true if the file is recognized as a Jar file.

Parameters:
f - a File value
Returns:
a boolean value