ca.nengo.config
Class MainHandler
java.lang.Object
ca.nengo.config.MainHandler
- All Implemented Interfaces:
- ConfigurationHandler
public final class MainHandler
- extends java.lang.Object
- implements ConfigurationHandler
A composite ConfigurationHandler which delegates to other underlying ConfigurationHandlers
that can handle specific classes.
- Author:
- Bryan Tripp
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HANDLERS_FILE_PROPERTY
public static java.lang.String HANDLERS_FILE_PROPERTY
getInstance
public static MainHandler getInstance()
- Returns:
- Singleton instance
addHandler
public void addHandler(ConfigurationHandler handler)
- Parameters:
handler
- New handler to which the MainHandler can delegate
canHandle
public boolean canHandle(java.lang.Class<?> c)
- Specified by:
canHandle
in interface ConfigurationHandler
- Parameters:
c
- A Class
- Returns:
- True if this handler can handle values of the given class
- See Also:
ConfigurationHandler.canHandle(java.lang.Class)
fromString
public java.lang.Object fromString(java.lang.Class<?> c,
java.lang.String s)
- Parameters:
c
- The class of the object represented by ss
- A String representation of an object
- Returns:
- x.fromString(s), where x is a handler appropriate for the class c
fromString
public java.lang.Object fromString(java.lang.String s)
- Specified by:
fromString
in interface ConfigurationHandler
- Parameters:
s
- A String representation of an object, eg from toString(o) or user
input
- Returns:
- An object built from the given string
- See Also:
ConfigurationHandler.fromString(java.lang.String)
getEditor
public java.awt.Component getEditor(java.lang.Object o,
ConfigurationChangeListener listener,
javax.swing.JComponent parent)
- Specified by:
getEditor
in interface ConfigurationHandler
- Parameters:
o
- An object for which canHandle(o.getClass()) == truelistener
- An ActionListener. The returned editor component must 1) add this listener
to the part of itself that produces an event when editing is complete, and 2) call
setProxy() with an EditorProxy through which the listener can retrieve a
new object value when editing is complete
- Returns:
- A UI component (eg JTextField) that allows the user to change the
object's value. If null, the calling property editor will attempt
to create a default editor, possibly using fromString(...).
- See Also:
ca.nengo.config.ConfigurationHandler#getEditor(Object, ConfigurationChangeListener)
getRenderer
public java.awt.Component getRenderer(java.lang.Object o)
- Specified by:
getRenderer
in interface ConfigurationHandler
- Parameters:
o
- An object for which canHandle(o.getClass()) == true
- Returns:
- A UI component (eg JLabel) that shows the object's value.
If null, the calling property editor will attempt to create
a default display, possibly using toString(o).
- See Also:
ConfigurationHandler.getRenderer(java.lang.Object)
toString
public java.lang.String toString(java.lang.Object o)
- Specified by:
toString
in interface ConfigurationHandler
- Parameters:
o
- An object for which canHandle(o.getClass()) == true
- Returns:
- A String representation of the object, suitable for user display
- See Also:
ConfigurationHandler.toString(java.lang.Object)
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class<?> c)
- Specified by:
getDefaultValue
in interface ConfigurationHandler
- Parameters:
c
- A class for which canHandle(c) == true
- Returns:
- A default value of the given class
- See Also:
ConfigurationHandler.getDefaultValue(java.lang.Class)