public class Setup extends Object
upgraded.| Constructor and Description |
|---|
Setup(Preferences preferences,
String intro_message,
List<SetupInstruction> instructions,
PromptInput in,
PrintWriter out)
Creates a new
Setup object. |
| Modifier and Type | Method and Description |
|---|---|
PromptInput |
getIn()
Returns the input object where the answers to the setup prompts will be read from.
|
List<SetupInstruction> |
getInstructions()
Returns the set of instructions that are used to ask the setup questions.
|
String |
getIntroMessage()
Returns the intro message that will be printed to the
output stream before the setup()
begins processing the instructions. |
PrintWriter |
getOut()
Returns the output stream where the prompts and any other output messages will be written to.
|
Preferences |
getPreferences()
Returns the preferences that are to be customized via this setup instance.
|
protected String |
preferencesDump(Preferences prefs)
Given a set of preferences, this will dump each name/value in the returned string separated with a newline.
|
protected String |
prompt(String prompt_message,
String pref_name,
String help_message,
String default_value,
PromptInput in,
PrintWriter out,
boolean no_echo)
Prints the prompt message to the output stream and waits for the new value to be input.
|
boolean |
setup()
Performs the setup by asking questions and setting preferences according to this object's
setup instructions. |
public Setup(Preferences preferences, String intro_message, List<SetupInstruction> instructions, PromptInput in, PrintWriter out)
Setup object.preferences - the set of preferences that need to be customizedintro_message - a human-readable string that will be output prior to starting the
setup() - this can be used to explain to the user what these set of preferences are
for (may be null)instructions - the set of instructions this class will use to customize the preferencesin - the input where the answers to the setup prompts will come fromout - the output stream where the setup prompts will be outputpublic Preferences getPreferences()
public String getIntroMessage()
output stream before the setup()
begins processing the instructions. If this is null, it will be ignored.null)public List<SetupInstruction> getInstructions()
public PromptInput getIn()
public PrintWriter getOut()
public boolean setup()
setup instructions.true if the setup finished; false if the user canceled the setup and reverted
back to the original valuesRuntimeException - if failed to access the preferences backend storeprotected String prompt(String prompt_message, String pref_name, String help_message, String default_value, PromptInput in, PrintWriter out, boolean no_echo)
Note that the default_value is only used to show in the prompt. Specifically, it will not be
returned if the user simply hit the ENTER key without entering a value. In that case, an empty string is
returned; the caller should detect this and set the value to the default as appropriate.
The returned value will be null if the user wants to rely on the system internal default and not
set the preference value at all.
prompt_message - the prompt message printed to the output stream that tells the user what is being asked
forpref_name - the actual preference name that is to be set to the answer of the prompthelp_message - a more detailed help message that tells the user what is being asked fordefault_value - what the value should be if the user just hits the ENTER keyin - where the user input is coming fromout - the stream where the prompt messages will be writtenno_echo - if true, user should not see what is being typed at the promptnull)RuntimeException - if failed to read from the input streamprotected String preferencesDump(Preferences prefs)
prefs - the preferences whose values are to be dumped in the given stringCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.