Package org.daisy.braille.ui
Class InputHelper
java.lang.Object
org.daisy.braille.ui.InputHelper
Provides a command line input helper for setting arguments interactively and
storing them in the users preferences.
- Author:
- Joel HÃ¥kansson
-
Constructor Summary
ConstructorDescriptionCreates a new InputHelper with the default storage location (determined by the calling class's package name)InputHelper
(Class c) Creates a new InputHelper for the specified class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the settings associated with this object from storage.boolean
getBoolean
(String msg, String key, boolean verify) double
int
getInput
(boolean allowEnter) Gets a integer from user.Gets the value for a key.Selects the value for a key.Selects the value for a key.
-
Constructor Details
-
InputHelper
Creates a new InputHelper for the specified class. The package name for the specified class will be used to locate an appropriate storage location in the user preferences.- Parameters:
c
- the class to create a InputHelper for
-
InputHelper
public InputHelper()Creates a new InputHelper with the default storage location (determined by the calling class's package name)
-
-
Method Details
-
select
Selects the value for a key.- Parameters:
key
- the key to select a value forselect
- the list of available valuesname
- a display name for the keyverify
- if true, and no value is found, lets user select a value- Returns:
- returns the value for the key.
-
select
Selects the value for a key.- Parameters:
key
- the key to get a value forselect
- the list of available valuesname
- the display name for the keyverify
- if true, and no value is found, lets user select a value- Returns:
- returns the value for the key.
-
getKey
Gets the value for a key.- Parameters:
key
- the key to get a value for- Returns:
- returns the value for the key
-
getInput
Gets a integer from user. The assumption is that this value should be a non-zero positive integer, that is the user selects a value from a list starting with one. If the input is an empty string, 0 is returned. If an IO error occurs, -1 is returned.- Returns:
- returns the integer value suppled by the user on the command line.
- Throws:
IOException
- if IO fails.
-
getDouble
- Throws:
IOException
-
getBoolean
- Throws:
IOException
-
clearSettings
Clears the settings associated with this object from storage.- Throws:
BackingStoreException
- if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.IllegalStateException
- if the associated node (or an ancestor) has been removed with the removeNode() method.
-