Package com.sun.interview
Class IntQuestion
- java.lang.Object
-
- com.sun.interview.Question
-
- com.sun.interview.IntQuestion
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntQuestion(Interview interview, java.lang.String tag)Create a question with a nominated tag.protectedIntQuestion(Interview interview, java.lang.String tag, int min, int max)Create a question with a nominated tag.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Clear any response to this question, resetting the value back to its initial state.intgetDefaultValue()Get the default response for this question.intgetLabelIncrementHint()Get a hint for the rendering system for the increment between labels.intgetLabelStartHint()Get a hint for the rendering system for the lowest value that might be labelled.intgetLowerBound()Get the inclusive lower bound for responses to this question.java.lang.StringgetStringValue()Get the response to this question as a string.int[]getSuggestions()Get the suggested responses to this question, or null if none.intgetUpperBound()Get the inclusive upper bound for responses to this question.intgetValue()Get the current (default or latest) response to this question.intgetValueOnPath()Verify this question is on the current path, and if it is, return the current value.booleanisValid()Deprecated.see #isValueValidbooleanisValueAlwaysValid()Check if the question always has a valid response.booleanisValueValid()Check if the question currently has a valid response.protected voidload(java.util.Map<java.lang.String,java.lang.String> data)Load the value for this question from a dictionary, using the tag as the key.protected voidsave(java.util.Map<java.lang.String,java.lang.String> data)Save the value for this question in a dictionary, using the tag as the key.protected voidsetBounds(int min, int max)Set the bounds for the response to this question.voidsetDefaultValue(int v)Set the default response for this question, used by the clear method.protected voidsetLabelHints(int start, int increment)Set hints for the rendering system for the values that might be labelled.voidsetSuggestions(int... newSuggestions)Set the set of suggested responses.voidsetValue(int newValue)Set the current value.voidsetValue(java.lang.String s)Set the response to this question to the value represented by a string-valued argument.voidsetValue(java.lang.String s, java.util.Locale l)Set the response to this question to the value represented by a string-valued argument, given in certain locale.-
Methods inherited from class com.sun.interview.Question
addMarker, equals, export, getChecklistItems, getHelpID, getImage, getInterview, getKey, getNext, getResourceString, getResourceString, getSummary, getTag, getText, getTextArgs, hashCode, hasMarker, isEnabled, isHidden, reload, removeMarker, setHelpID, setImage, setImage, setSummary, setText
-
-
-
-
Constructor Detail
-
IntQuestion
protected IntQuestion(Interview interview, java.lang.String tag)
Create a question with a nominated tag.- Parameters:
interview- The interview containing this question.tag- A unique tag to identify this specific question.
-
IntQuestion
protected IntQuestion(Interview interview, java.lang.String tag, int min, int max)
Create a question with a nominated tag.- Parameters:
interview- The interview containing this question.tag- A unique tag to identify this specific question.min- The inclusive lower bound for responses to this questionmax- The inclusive upper bound for responses to this question- Throws:
java.lang.IllegalArgumentException- ifminis greater than or equal tomax.
-
-
Method Detail
-
setBounds
protected void setBounds(int min, int max)Set the bounds for the response to this question. If the current value is valid and not within bounds, it will be adjusted to the nearest bound.- Parameters:
min- The inclusive lower bound for responses to this questionmax- The inclusive upper bound for responses to this question- Throws:
java.lang.IllegalArgumentException- ifminis greater than or equal tomax.
-
getLowerBound
public int getLowerBound()
Get the inclusive lower bound for responses to this question.- Returns:
- the lower bound
-
getUpperBound
public int getUpperBound()
Get the inclusive upper bound for responses to this question.- Returns:
- the upper bound
-
getSuggestions
public int[] getSuggestions()
Get the suggested responses to this question, or null if none.- Returns:
- The suggestions.
- See Also:
setSuggestions(int...)
-
setSuggestions
public void setSuggestions(int... newSuggestions)
Set the set of suggested responses.- Parameters:
newSuggestions- The values to be set, or null if none- See Also:
getSuggestions()
-
getDefaultValue
public int getDefaultValue()
Get the default response for this question.- Returns:
- the default response for this question.
- See Also:
setDefaultValue(int)
-
setDefaultValue
public void setDefaultValue(int v)
Set the default response for this question, used by the clear method.- Parameters:
v- the default response for this question.- See Also:
getDefaultValue()
-
isValid
@Deprecated public boolean isValid()
Deprecated.see #isValueValidCheck if the value is set. Unset values are represented by the special valueInteger.MIN_VALUE.- Returns:
- true if a value has been set for this question and is within the specified bounds
- See Also:
clear()
-
getValue
public int getValue()
Get the current (default or latest) response to this question. If the value is unset, the result will beInteger.MIN_VALUE.- Returns:
- The current value.
- See Also:
isValid(),setValue(java.lang.String)
-
setValue
public void setValue(java.lang.String s) throws Interview.FaultSet the response to this question to the value represented by a string-valued argument. Argument is decoded against current locale.- Specified by:
setValuein classQuestion- Parameters:
s- A string containing the numeric value to be set. The number should be in the range of valid values defined for this question; if it is not, the value will be retained, but isValueValid() will return false.- Throws:
Interview.Fault- This exception is just retained for backwards compatibility; it should never actually be thrown.- See Also:
getValue(),setValue(String, Locale)
-
setValue
public void setValue(int newValue)
Set the current value.- Parameters:
newValue- The value to be set. It should be in the range of valid values defined for this question.- See Also:
getValue()
-
getValueOnPath
public int getValueOnPath() throws Interview.NotOnPathFaultVerify this question is on the current path, and if it is, return the current value.- Returns:
- the current value of this question
- Throws:
Interview.NotOnPathFault- if this question is not on the current path- See Also:
getValue()
-
getStringValue
public java.lang.String getStringValue()
Description copied from class:QuestionGet the response to this question as a string.- Specified by:
getStringValuein classQuestion- Returns:
- a string representing the current response to this question, or null.
- See Also:
Question.setValue(String)
-
setValue
public void setValue(java.lang.String s, java.util.Locale l)Set the response to this question to the value represented by a string-valued argument, given in certain locale.- Parameters:
s- A string containing the numeric value to be set. The number should be in the range of valid values defined for this question; if it is not, the value will be retained, but isValueValid() will return false.l- A locale that should be used to decode numeric value from given string parameter- See Also:
getValue(),setValue(String)
-
isValueValid
public boolean isValueValid()
Description copied from class:QuestionCheck if the question currently has a valid response.- Specified by:
isValueValidin classQuestion- Returns:
- true if the question currently has a valid response, and false otherwise.
-
isValueAlwaysValid
public boolean isValueAlwaysValid()
Description copied from class:QuestionCheck if the question always has a valid response. This may be true, for example, for a choice question with a default response.- Specified by:
isValueAlwaysValidin classQuestion- Returns:
- true if the question always has a valid response, and false otherwise.
-
setLabelHints
protected void setLabelHints(int start, int increment)Set hints for the rendering system for the values that might be labelled.- Parameters:
start- The lowest value to be labelledincrement- The increment for successive labels
-
getLabelStartHint
public int getLabelStartHint()
Get a hint for the rendering system for the lowest value that might be labelled.- Returns:
- The lowest value that might be labelled.
-
getLabelIncrementHint
public int getLabelIncrementHint()
Get a hint for the rendering system for the increment between labels.- Returns:
- The increment between values that might be labelled.
-
clear
public void clear()
Clear any response to this question, resetting the value back to its initial state.
-
load
protected void load(java.util.Map<java.lang.String,java.lang.String> data)
Load the value for this question from a dictionary, using the tag as the key.
-
-