org.crosswire.common.config
Class AbstractReflectedChoice

java.lang.Object
  extended by org.crosswire.common.config.AbstractReflectedChoice
All Implemented Interfaces:
Choice
Direct Known Subclasses:
BooleanChoice, ClassChoice, FileChoice, FontChoice, IntOptionsChoice, NumberChoice, PathChoice, StringArrayChoice, StringChoice, StringOptionsChoice

public abstract class AbstractReflectedChoice
extends Object
implements Choice

A helper for when we need to be a choice created dynamically.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: AbstractReflectedChoice.java,v 1.4 2004/08/16 22:07:35 joe Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Field Summary
private  Class clazz
          The type that we reflect to
private  String fullPath
          The full path of this item
private  Method getter
          The method to call to get the value
private  String helptext
          The help text (tooltip) for this item
private static Logger log
          The log stream
private  int priority
          The priority of this config level
private  String propertyname
          The property that we call on the reflecting class
private  Method setter
          The method to call to set the value
private  String type
          The type (as specified in config.xml)
 
Fields inherited from interface org.crosswire.common.config.Choice
PRIORITY_ACCESSOR, PRIORITY_CTOR, PRIORITY_EXTENDER, PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_NORMAL, PRIORITY_SYSTEM
 
Constructor Summary
AbstractReflectedChoice()
           
 
Method Summary
abstract  Object convertToObject(String orig)
          Convert from a stored string to an object to use with relfection
abstract  String convertToString(Object orig)
          Convert from a reflection return value to a String for storage
 String getFullPath()
          The full path of the option.
 String getHelpText()
          Gets a brief description of what is going on
 int getPriority()
          Sometimes we need to ensure that we configure items in a certain order, the config package moves the changes to the application starting with the highest priority, moving to the lowest
 String getString()
          String value to associate with the name (key)
 String getType()
          The type by which UIs can pick an appropriate editor
 void init(org.jdom.Element option, ResourceBundle configResources)
          String value to associate with the name (key)
 boolean isSaveable()
          Is this Choice OK to write out to a file, or should we use settings in this run of the program, but forget them for next time.
 boolean requiresRestart()
          Do we need to restart the program in order for this change to have effect?
 void setFullPath(String newFullPath)
          Sets the full path of the option.
 void setHelpText(String helptext)
          Sets a brief description of what is going on
 void setPriority(int priority)
          Sometimes we need to ensure that we configure items in a certain order, the config package moves the changes to the application starting with the highest priority, moving to the lowest
 void setString(String value)
          String value to associate with this Field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.crosswire.common.config.Choice
getConvertionClass
 

Field Detail

clazz

private Class clazz
The type that we reflect to


propertyname

private String propertyname
The property that we call on the reflecting class


type

private String type
The type (as specified in config.xml)


getter

private Method getter
The method to call to get the value


setter

private Method setter
The method to call to set the value


helptext

private String helptext
The help text (tooltip) for this item


fullPath

private String fullPath
The full path of this item


priority

private int priority
The priority of this config level


log

private static final Logger log
The log stream

Constructor Detail

AbstractReflectedChoice

public AbstractReflectedChoice()
Method Detail

init

public void init(org.jdom.Element option,
                 ResourceBundle configResources)
          throws StartupException
Description copied from interface: Choice
String value to associate with the name (key)

Specified by:
init in interface Choice
Throws:
StartupException

getType

public String getType()
Description copied from interface: Choice
The type by which UIs can pick an appropriate editor

Specified by:
getType in interface Choice
Returns:
String The type string as supplied in config.xml

convertToString

public abstract String convertToString(Object orig)
Convert from a reflection return value to a String for storage


convertToObject

public abstract Object convertToObject(String orig)
Convert from a stored string to an object to use with relfection


getFullPath

public String getFullPath()
Description copied from interface: Choice
The full path of the option.

Specified by:
getFullPath in interface Choice
Returns:
String The path string as supplied in config.properties

setFullPath

public void setFullPath(String newFullPath)
Description copied from interface: Choice
Sets the full path of the option.

Specified by:
setFullPath in interface Choice
Parameters:
newFullPath - The path string as supplied in config.properties

getHelpText

public String getHelpText()
Description copied from interface: Choice
Gets a brief description of what is going on

Specified by:
getHelpText in interface Choice
Returns:
Some help text

setHelpText

public void setHelpText(String helptext)
Description copied from interface: Choice
Sets a brief description of what is going on

Specified by:
setHelpText in interface Choice
Parameters:
helptext - Some help text

isSaveable

public boolean isSaveable()
Description copied from interface: Choice
Is this Choice OK to write out to a file, or should we use settings in this run of the program, but forget them for next time. A typical use of this is for password configuration.

Specified by:
isSaveable in interface Choice
Returns:
True if it is safe to store the value in a config file.

getPriority

public int getPriority()
Sometimes we need to ensure that we configure items in a certain order, the config package moves the changes to the application starting with the highest priority, moving to the lowest

Specified by:
getPriority in interface Choice
Returns:
A priority level

setPriority

public void setPriority(int priority)
Sometimes we need to ensure that we configure items in a certain order, the config package moves the changes to the application starting with the highest priority, moving to the lowest

Parameters:
priority - A priority level

requiresRestart

public boolean requiresRestart()
Description copied from interface: Choice
Do we need to restart the program in order for this change to have effect?

Specified by:
requiresRestart in interface Choice
Returns:
True if a restart is required

getString

public String getString()
Description copied from interface: Choice
String value to associate with the name (key)

Specified by:
getString in interface Choice
Returns:
value of this Choice

setString

public void setString(String value)
               throws Exception
Description copied from interface: Choice
String value to associate with this Field. This method can throw any Exception since almost anything could go wrong at this point. The Config dialog ought to cope with any errors.

Specified by:
setString in interface Choice
Parameters:
value - The new value for this Choice
Throws:
Exception

Copyright ? 2003-2004