org.crosswire.common.config
Class MappedOptionsChoice

java.lang.Object
  extended by org.crosswire.common.config.AbstractReflectedChoice
      extended by org.crosswire.common.config.MappedOptionsChoice
All Implemented Interfaces:
Choice, MappedChoice<Object,Object>

public class MappedOptionsChoice
extends AbstractReflectedChoice
implements MappedChoice<Object,Object>

A class to convert between strings and objects of a type.

Author:
Joe Walker [joe at eireneh dot com], DM Smith
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
private static org.slf4j.Logger log
          The log stream
private  Map<?,?> options
           
 
Constructor Summary
MappedOptionsChoice()
           
 
Method Summary
 Object convertToObject(String orig)
          Convert from a stored string to an object to use with reflection
 String convertToString(Object orig)
          Convert from a reflection return value to a String for storage
 Class<String> getConversionClass()
          The class that this Choice works on.
 Map<Object,Object> getOptions()
          The available alternative values to be presented as options to the user where the user interface allows presentation of alternatives.
 void init(org.jdom2.Element option, ResourceBundle configResources)
          String value to associate with the name (key)
 
Methods inherited from class org.crosswire.common.config.AbstractReflectedChoice
getFullPath, getHelpText, getKey, getString, getType, isHidden, isIgnored, isSaveable, requiresRestart, setFullPath, setHelpText, setString
 
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
getFullPath, getHelpText, getKey, getString, getType, isHidden, isIgnored, isSaveable, requiresRestart, setFullPath, setHelpText, setString
 

Field Detail

options

private Map<?,?> options

log

private static org.slf4j.Logger log
The log stream

Constructor Detail

MappedOptionsChoice

public MappedOptionsChoice()
Method Detail

init

public void init(org.jdom2.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
Overrides:
init in class AbstractReflectedChoice
Throws:
StartupException

getOptions

public Map<Object,Object> getOptions()
Description copied from interface: MappedChoice
The available alternative values to be presented as options to the user where the user interface allows presentation of alternatives.

Specified by:
getOptions in interface MappedChoice<Object,Object>
Returns:
A string array of alternatives.

getConversionClass

public Class<String> getConversionClass()
Description copied from interface: Choice
The class that this Choice works on. Used to decide how to display the choice to the user.

Specified by:
getConversionClass in interface Choice
Returns:
The Class that this Choice works using.

convertToString

public String convertToString(Object orig)
Description copied from class: AbstractReflectedChoice
Convert from a reflection return value to a String for storage

Specified by:
convertToString in class AbstractReflectedChoice

convertToObject

public Object convertToObject(String orig)
Description copied from class: AbstractReflectedChoice
Convert from a stored string to an object to use with reflection

Specified by:
convertToObject in class AbstractReflectedChoice

Copyright ? 2003-2011