Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.config
Class AbstractReflectedChoice

    java.lang.Object
      org.crosswire.common.config.AbstractReflectedChoice

All Implemented Interfaces:
  Choice

Direct Known Subclasses:
  BooleanChoice, ClassChoice, FileChoice, FontChoice, IntOptionsChoice, MappedOptionsChoice, 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.

Author:
  Joe Walker, DM Smith
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private Class<? extends Object>` | `clazz` The type that we reflect to
`private boolean` | `external` Whether this choice is managed externally, via setXXX and getXXX.
`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 boolean` | `hidden` Whether this choice should be visible or hidden
`private boolean` | `ignored` Whether this choice should be ignored altogether.
`private String` | `key` The key of the option.
`private static org.slf4j.Logger` | `log` The log stream
`private String` | `propertyname` The property that we call on the reflecting class
`private boolean` | `restart` Whether this choice is requires a restart to be seen.
`private Method` | `setter` The method to call to set the value
`private String` | `type` The type (as specified in config.xml)

Constructor Summary
`AbstractReflectedChoice()`

Method Summary
`abstract Object` | `convertToObject(String orig)` Convert from a stored string to an object to use with reflection
`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
`String` | `getKey()` The key of the option.
`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.jdom2.Element option, ResourceBundle configResources)` String value to associate with the name (key)
`boolean` | `isHidden()` Whether this should be visible in a Config Editor.
`boolean` | `isIgnored()` Whether this should be ignored altogether in a Config Editor.
`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` | `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
`getConversionClass`

Field Detail

### key

    private String key

  The key of the option.

### clazz

    private Class<? extends Object> 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

### hidden

    private boolean hidden

  Whether this choice should be visible or hidden

### ignored

    private boolean ignored

  Whether this choice should be ignored altogether.

### external

    private boolean external

  Whether this choice is managed externally, via setXXX and getXXX.

### restart

    private boolean restart

  Whether this choice is requires a restart to be seen.

### log

    private static final org.slf4j.Logger log

  The log stream

Constructor Detail

### AbstractReflectedChoice

    public AbstractReflectedChoice()

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`
  Parameters:
    `option` - the option
    `configResources` - the resource bundle to load
  Throws:
    `StartupException` - if startup is not possible

### getKey

    public String getKey()

  Description copied from interface: `Choice`
  The key of the option.

  Specified by:
    `getKey` in interface `Choice`
  Returns:
    String The key string as supplied in config.xml

### 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

  Parameters:
    `orig` - the object to be converted to a string
  Returns:
    the marshaled representation of the object

### convertToObject

    public abstract Object convertToObject(String orig)

  Convert from a stored string to an object to use with reflection

  Parameters:
    `orig` - the marshaled representation of the object
  Returns:
    the reconstituted object

### 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.

### isHidden

    public boolean isHidden()

  Description copied from interface: `Choice`
  Whether this should be visible in a Config Editor.

  Specified by:
    `isHidden` in interface `Choice`
  Returns:
    hidden or visible

### isIgnored

    public boolean isIgnored()

  Description copied from interface: `Choice`
  Whether this should be ignored altogether in a Config Editor.

  Specified by:
    `isIgnored` in interface `Choice`
  Returns:
    hidden or visible

### 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 ConfigException

  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:
    `ConfigException` - if there is a problem with the configuration

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2015
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD