public class SetupInstruction extends Object
This class can be used as-is or can be subclassed if additional processing needs to be performed during the setup (such as pre-processing to obtain a default value at runtime or post-processing the new user-entered value).
| Constructor and Description |
|---|
SetupInstruction(String preference_name,
String default_value,
SetupValidityChecker validity_checker,
String prompt_message,
String help_message,
boolean no_echo_prompt)
Constructor for
SetupInstruction. |
| Modifier and Type | Method and Description |
|---|---|
String |
getDefaultValue()
Returns the default value that is to be assigned to the preference if the answer to the prompt was an empty
return.
|
String |
getHelpMessage()
Returns the human-readable help message that describes the preference being setup in more detail.
|
String |
getPreferenceName()
Returns the name of the preference that is setup by this instruction.
|
Preferences |
getPreferences()
Returns the preferences that are being setup according to this instruction.
|
String |
getPromptMessage()
Returns the human-readable prompt message that asks the question of the user for the new preference value.
|
SetupValidityChecker |
getValidityChecker()
Returns the optionally defined validity checker object that will be responsible for making sure any new
preference value to be set is valid.
|
boolean |
isUsingNoEchoPrompt()
If
true, the prompt will not echo what the user typed (as you would want if the prompt is asking for
a password, for example). |
void |
postProcess()
This method is called by
Setup to inform this object that the preferences have been setup with the
information in this instruction - getPreferences() will return the preferences that have been changed. |
void |
preProcess()
This method is called by
Setup to inform this object that the preferences are about to be setup with the
information in this instruction. |
protected void |
setDefaultValue(String default_value)
Sets the default value that is to be assigned to the preference if the answer to the prompt was an empty return.
|
protected void |
setHelpMessage(String help_message)
Sets the human-readable help message that describes the preference being setup in more detail.
|
void |
setPreferences(Preferences preferences)
Sets the preferences that are being setup according to this instruction object.
|
protected void |
setPromptMessage(String prompt_message)
Sets the human-readable prompt message that asks the question of the user for the new preference value.
|
protected void |
setUsingNoEchoPrompt(boolean no_echo)
If
true, the prompt will not echo what the user typed (as you would want if the prompt is asking for
a password, for example). |
protected void |
setValidityChecker(SetupValidityChecker validity_checker)
Sets the validity checker object that will be responsible for making sure any new preference value to be set is
valid.
|
String |
toString() |
public SetupInstruction(String preference_name, String default_value, SetupValidityChecker validity_checker, String prompt_message, String help_message, boolean no_echo_prompt) throws IllegalArgumentException
SetupInstruction.preference_name - the name of the preference that this instruction will setup (must not be
null)default_value - the default value of the preference should the user input be an empty returnvalidity_checker - an optional object that can be used to validate a new preference value (may be
null)prompt_message - the human-readable prompt string that will be shown to the user that asks for the
customized preference value the user wants to use (may be null, in which
case, the Setup should not stop and ask the user for a value - the default value
will be used automatically)help_message - the human-readable help string that provides more detail on the preference (for the user
to see if they don't know what the preference is for)no_echo_prompt - if true, the prompt is assumed to be for some secure setting that should no
be echoed to the screen to avoid spying eyes from seeing it. When true, the
prompt will be asked a second time to confirm the answer, since the user won't be able
to see what is being typedIllegalArgumentException - if preference_name is nullpublic void preProcess()
Setup to inform this object that the preferences are about to be setup with the
information in this instruction. Subclasses are free to override this method to perform some pre-processing in
case it wants to do things like define a default value based on information it gathers
at runtime, define a different prompt message, etc.
This method implementation is a no-op and simply does nothing but return.
public void postProcess()
Setup to inform this object that the preferences have been setup with the
information in this instruction - getPreferences() will return the preferences that have been changed.
Subclasses are free to override this method to perform some post-processing in case it wants to do things like
modify the preferences based on the new values in the preferences.
This method implementation is a no-op and simply does nothing but return.
public Preferences getPreferences()
null if this instruction hasn't
been told what preferences are being setup)public void setPreferences(Preferences preferences)
preferences - the preferences being setuppublic String getPreferenceName()
public String getDefaultValue()
protected void setDefaultValue(String default_value)
default_value - the new value of defaultValuepublic SetupValidityChecker getValidityChecker()
null, all values are considered valid.null)protected void setValidityChecker(SetupValidityChecker validity_checker)
null, all values will be considered valid.validity_checker - the object that performs validation checks on new values of the preference handled by
this instruction (may be null)public String getPromptMessage()
null, the user will not be prompted; instead, the
default value will be the value to be used as the new preference value.null)protected void setPromptMessage(String prompt_message)
prompt_message is null, the user will not be prompted; instead, the
default value will be the value to be used as the new preference value.prompt_message - the new prompt message string (may be null)public String getHelpMessage()
protected void setHelpMessage(String help_message)
help_message - the new help message stringpublic boolean isUsingNoEchoPrompt()
true, the prompt will not echo what the user typed (as you would want if the prompt is asking for
a password, for example).protected void setUsingNoEchoPrompt(boolean no_echo)
true, the prompt will not echo what the user typed (as you would want if the prompt is asking for
a password, for example).no_echo - flag to indicate if the prompt will not echo back to the user what is being typedpublic String toString()
toString in class ObjectObject.toString()Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.