public abstract class Question
extends java.lang.Object
interviews
.
They provide text and an optional graphic to be presented to the user,
and they provide a place to store the user's response.
Various subtypes are provided, according to the type of response they
request and store.
Questions are identified internally by a unique tag, which is used to identify
the question in contexts such as resource bundles, dictionaries, and so on.Modifier and Type | Field and Description |
---|---|
protected Interview |
interview
The interview to which this question belongs.
|
protected java.lang.String |
key
A unique key to identify the resources for this question.
|
protected java.lang.String |
tag
A unique tag to identify this question.
|
Modifier | Constructor and Description |
---|---|
protected |
Question(Interview interview)
Create a question with no identifying tag.
|
protected |
Question(Interview interview,
java.lang.String baseTag)
Create a question with a nominated tag.
|
Modifier and Type | Method and Description |
---|---|
void |
addMarker(java.lang.String name)
Add a named marker to this question, if it has not already been added.
|
abstract void |
clear()
Clear any state for this question, setting the value
to a question-specific default value.
|
boolean |
equals(java.lang.Object other)
Check if this question equals another.
|
protected void |
export(java.util.Map data)
Export any appropriate values to the dictionary, as part
of
Interview.export(java.util.Map) . |
Checklist.Item[] |
getChecklistItems()
Get any items which should be added to the interview's
checklist.
|
java.lang.Object |
getHelpID()
Get the JavaHelp ID identifying the "more info" help for this
question, or null if none.
|
java.net.URL |
getImage()
Get the graphic for this question.
|
Interview |
getInterview()
Return the interview of which this question is a part.
|
java.lang.String |
getKey()
Get the key for a question.
|
protected abstract Question |
getNext()
Get the next question to be asked.
|
protected java.lang.String |
getResourceString(java.lang.String key)
Get an entry from the interview's resource bundle.
|
protected java.lang.String |
getResourceString(java.lang.String key,
boolean checkAncestorsFirst)
Get an entry from the interview's resource bundle.
|
abstract java.lang.String |
getStringValue()
Get the response to this question as a string.
|
java.lang.String |
getSummary()
Set the summary text for this question.
|
java.lang.String |
getTag()
Get the tag for a question.
|
java.lang.String |
getText()
Get the text for this question.
|
protected java.lang.Object[] |
getTextArgs()
Get any arguments necessary to go with the question text.
|
int |
hashCode() |
boolean |
hasMarker(java.lang.String name)
Check if a marker has been added to this question.
|
boolean |
isEnabled()
Determine if this question is currently enabled.
|
boolean |
isHidden()
Determine if this question is currently "hidden".
|
abstract boolean |
isValueAlwaysValid()
Check if the question always has a valid response.
|
abstract boolean |
isValueValid()
Check if the question currently has a valid response.
|
protected abstract void |
load(java.util.Map data)
Load any state for this question from a dictionary,
using the tag as the key.
|
void |
reload()
This methods invokes save(Map), clear() and load(Map).
|
void |
removeMarker(java.lang.String name)
Remove a named marker to this question.
|
protected abstract void |
save(java.util.Map data)
Save any state for this question in a dictionary,
using the tag as the key.
|
void |
setHelpID(java.lang.Object object)
Set HelpID object associated with the Question.
|
void |
setImage(java.lang.String resource)
Set the URL for a specific graphic for this question.
|
protected void |
setImage(java.net.URL u)
Set the URL for a specific graphic for this question.
|
protected void |
setSummary(java.lang.String summary)
Set the summary text for this question.
|
protected void |
setText(java.lang.String text)
Set the text for this question.
|
abstract void |
setValue(java.lang.String s)
Set the response to this question to the value represented by
a string-valued argument.
|
protected Interview interview
protected java.lang.String tag
protected final java.lang.String key
protected Question(Interview interview, java.lang.String baseTag)
interview
- The interview containing this question.baseTag
- A name to uniquely identify this question within its interview.protected Question(Interview interview)
interview
- The interview containing this question.public Interview getInterview()
public java.lang.String getKey()
getTag()
public java.lang.String getTag()
getKey()
protected void setText(java.lang.String text)
text
.text
- the text for this questiongetText()
public java.lang.String getText()
.text
.setText(java.lang.String)
protected java.lang.Object[] getTextArgs()
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
. By default, this
method returns null. If the text for the question contains
variable entries (using the '{' '}' notation), you should
override this method to provide the corresponding values.protected void setSummary(java.lang.String summary)
smry
.summary
- a short summary of the text for this questiongetSummary()
public java.lang.String getSummary()
setSummary(java.lang.String)
public void setImage(java.lang.String resource)
resource
- The name of a resource containing the
desired image.getImage()
protected void setImage(java.net.URL u)
u
- The URL of a resource containing the
desired image.getImage()
public java.net.URL getImage()
setImage(java.lang.String)
has been called to supply a specific image for this question,
that will be the result here; otherwise, the value defaults
first to a question-specific resource (tag.gif
)
and then to a default image
for the interview.setImage(java.lang.String)
public java.lang.Object getHelpID()
public void setHelpID(java.lang.Object object)
object
- Should be instance of javax.help.Map.IDpublic Checklist.Item[] getChecklistItems()
Interview.createChecklist()
public void addMarker(java.lang.String name)
name
- the name of the marker to be added.java.lang.NullPointerException
- if name is nullpublic void removeMarker(java.lang.String name)
name
- the name of the marker to be removed.public boolean hasMarker(java.lang.String name)
name
- the name of the marker to be checked.public boolean isHidden()
Interview.prev()
and
Interview.next()
, etc.
By default, questions are not hidden, and this method returns false.
Override this method if you want to hide a question - note that the
value of isEnabled()
is currently tied to the value of
this method. Developers who wish to independently play with hiding and
enabling should override both methods.isEnabled()
public boolean isEnabled()
Interview.prev()
and
Interview.next()
, etc.
By default, all questions are enabled, and this method returns true.
Override this method if you want to hide a question.
It can be convenient to determine whether or not a question should be
disabled by using the values of earlier questions.
Note: for backwards compatibility, the default implementation
returns !isHidden()
.protected abstract Question getNext()
public abstract void clear()
public abstract java.lang.String getStringValue()
setValue(String)
public abstract void setValue(java.lang.String s) throws Interview.Fault
s
- A string containing a value value appropriate for the
particular type of question whose value is being set.Interview.Fault
- (retained for compatibility; should not be thrown)getStringValue()
public abstract boolean isValueValid()
public abstract boolean isValueAlwaysValid()
protected abstract void load(java.util.Map data)
data
- The map from which to load the value for this question.protected abstract void save(java.util.Map data)
data
- The map in which to save the value for this question.protected void export(java.util.Map data)
Interview.export(java.util.Map)
. The default is to do nothing.
Note that only questions which are on the current path have
their export method called. Questions do not appear on the
current path if they are not accessible from any question on the
path, or if they have been disabled.data
- The map in which to export any data for this question.Interview.getPath()
,
isEnabled()
public void reload()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected java.lang.String getResourceString(java.lang.String key)
key
- the name of the entry to be returnedInterview.getResourceString(String)
protected java.lang.String getResourceString(java.lang.String key, boolean checkAncestorsFirst)
key
- the name of the entry to be returnedcheckAncestorsFirst
- whether to recursively call this method on the
parent (if any) before checking this bundle, or only afterwards, if this
bundle does not provide a valueInterview.getResourceString(String, boolean)
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.