Package com.sun.interview
Class StringQuestion
- java.lang.Object
-
- com.sun.interview.Question
-
- com.sun.interview.StringQuestion
-
-
Field Summary
Fields Modifier and Type Field Description protected intnominalMaxLengthThe nominal maximum length for the string.protected java.lang.String[]suggestionsSuggested values for this question.protected java.lang.StringvalueThe current response for this question.
-
Constructor Summary
Constructors Modifier Constructor Description protectedStringQuestion(Interview interview, java.lang.String tag)Create a question with a nominated tag.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear any response to this question, resetting the value back to its initial state.protected static booleanequal(java.lang.String s1, java.lang.String s2)Compare two strings for equality.java.lang.StringgetDefaultValue()Get the default response for this question.intgetNominalMaxLength()Get the nominal maximum length for the string.java.lang.StringgetStringValue()Get the response to this question as a string.java.lang.String[]getSuggestions()Get the suggested responses to this question, or null if none.java.lang.StringgetValue()Get the current (default or latest) response to this question.java.lang.StringgetValueOnPath()Verify this question is on the current path, and if it is, return the current value.booleanisValueAlwaysValid()Check if the question always has a valid response.booleanisValueValid()Check if the question currently has a valid response.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.voidsetDefaultValue(java.lang.String v)Set the default response for this question, used by the clear method.voidsetNominalMaxLength(int nominalMaxLength)Set the expected maximum length for the string.voidsetSuggestions(java.lang.String... newSuggestions)Set the set of suggested responses.voidsetValue(java.lang.String newValue)Set the current value.-
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, load, reload, removeMarker, setHelpID, setImage, setImage, setSummary, setText
-
-
-
-
Constructor Detail
-
StringQuestion
protected StringQuestion(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.
-
-
Method Detail
-
equal
protected static boolean equal(java.lang.String s1, java.lang.String s2)Compare two strings for equality.- Parameters:
s1- the first string to be compared, or nulls2- the other string to be compared, or null- Returns:
- true if both parameters are null, or if both are non-null and equal.
-
getDefaultValue
public java.lang.String getDefaultValue()
Get the default response for this question.- Returns:
- the default response for this question.
- See Also:
setDefaultValue(java.lang.String)
-
setDefaultValue
public void setDefaultValue(java.lang.String v)
Set the default response for this question, used by the clear method.- Parameters:
v- the default response for this question.- See Also:
getDefaultValue()
-
getValue
public java.lang.String getValue()
Get the current (default or latest) response to this question.- Returns:
- The current value.
- See Also:
setValue(java.lang.String)
-
setValue
public void setValue(java.lang.String newValue)
Set the current value.- Specified by:
setValuein classQuestion- Parameters:
newValue- The value to be set.- See Also:
getValue()
-
getValueOnPath
public java.lang.String 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)
-
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.
-
getNominalMaxLength
public int getNominalMaxLength()
Get the nominal maximum length for the string.- Returns:
- the nominal maximum length for the string.
- See Also:
setNominalMaxLength(int)
-
setNominalMaxLength
public void setNominalMaxLength(int nominalMaxLength)
Set the expected maximum length for the string.- Parameters:
nominalMaxLength- the nominal maximum length for the string.- See Also:
getNominalMaxLength()
-
getSuggestions
public java.lang.String[] getSuggestions()
Get the suggested responses to this question, or null if none.- Returns:
- The suggestions.
- See Also:
setSuggestions(java.lang.String...)
-
setSuggestions
public void setSuggestions(java.lang.String... newSuggestions)
Set the set of suggested responses.- Parameters:
newSuggestions- The values to be set, or null if none- Throws:
java.lang.IllegalArgumentException- if any of the values in the array are null- See Also:
getSuggestions()
-
clear
public void clear()
Clear any response to this question, resetting the value back to its initial state.
-
-