public class Interview
extends java.lang.Object
questions
, to be
presented to the user via some tool such as an assistant or wizard.
Interviews may be stand-alone, or designed to be part of other interviews.Modifier and Type | Class and Description |
---|---|
static class |
Interview.BadHelpFault
Deprecated.
No longer used in this API, direct JavaHelp usage was removed.
|
static class |
Interview.Fault
This exception is to report problems that occur while updating an interview.
|
static class |
Interview.HelpNotFoundFault
Deprecated.
No longer used in this API, direct JavaHelp usage was removed.
|
static class |
Interview.NotOnPathFault
This exception is thrown when a question is expected to be on
the current path, and is not.
|
static interface |
Interview.Observer
An observer interface for receiving notifications as the state of
the interview is updated.
|
Modifier and Type | Field and Description |
---|---|
static int |
EXPORT_IGNORE_ALL_EXCEPTIONS
A value indicating that export should ignore all exceptions that arise
while calling each question's export method.
|
static int |
EXPORT_IGNORE_NO_EXCEPTIONS
A value indicating that export should not ignore any exceptions that arise
while calling each question's export method.
|
static int |
EXPORT_IGNORE_RUNTIME_EXCEPTIONS
A value indicating that export should ignore runtime exceptions that arise
while calling each question's export method.
|
protected static java.lang.String |
EXTERNAL_PREF |
protected static HelpSetFactory |
helpSetFactory |
protected static java.lang.String |
INTERVIEW |
protected static java.lang.String |
LOCALE |
protected static java.lang.String |
MARKERS |
protected static java.lang.String |
MARKERS_PREF |
protected static java.lang.String |
QUESTION |
static int |
SEMANTIC_MAX_VERSION
The highest version number currently in use.
|
static int |
SEMANTIC_PRE_32
Where necessary, the harness interview should behave as it did before the
3.2 release.
|
static int |
SEMANTIC_VERSION_32
Where necessary, the harness interview should behave as it did for the
3.2 release.
|
static int |
SEMANTIC_VERSION_43
Where necessary, the harness interview should behave as it did for the
4.3 release.
|
protected static java.lang.String |
TEMPLATE_PREF |
Modifier | Constructor and Description |
---|---|
protected |
Interview(Interview parent,
java.lang.String baseTag)
Create an interview to be used as part of another interview.
|
protected |
Interview(java.lang.String tag)
Create a top-level interview.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Interview.Observer o)
Add an observer to monitor updates to the interview.
|
protected Question |
callInterview(Interview i,
Question q)
Return a special type of question used to indicate that
a sub-interview interview should be called before proceeding
to the next question in this interview.
|
void |
clear()
Clear any responses to all the questions in this interview, and then
recursively, in its child interviews.
|
void |
clearMarkedResponses(java.lang.String name)
Clear the response to marked questions.
|
boolean |
containsObserver(Interview.Observer o) |
Checklist |
createChecklist()
Create a checklist composed of all checklist items
for questions on the current path.
|
Checklist.Item |
createChecklistItem(java.lang.String sectionKey,
java.lang.String textKey)
Create a checklist item based on entries in the interview's resource bundle.
|
Checklist.Item |
createChecklistItem(java.lang.String sectionKey,
java.lang.String textKey,
java.lang.Object textArg)
Create a checklist item based on entries in the interview's resource bundle.
|
Checklist.Item |
createChecklistItem(java.lang.String sectionKey,
java.lang.String textKey,
java.lang.Object[] textArgs)
Create a checklist item based on entries in the interview's resource bundle.
|
void |
export(java.util.Map data)
Export values for questions on the current path, by calling
Question.export(java.util.Map)
for each question returned by getPath() . |
java.util.Map |
getAllQuestions()
Get all questions in this interview and
recursively, in all child interviews.
|
Question |
getCurrentQuestion()
Get the current question in the interview.
|
java.net.URL |
getDefaultImage()
Get a default image to be used for the questions of an interview.
|
int |
getExportIgnoreExceptionPolicy()
Get a value representing the policy regarding how to treat
exceptions that may arise during export.
|
java.util.Map<java.lang.String,java.lang.String> |
getExternalProperties()
Get a (shallow) copy of the current "external" values.
|
Question |
getFirstQuestion()
Get the first question of the interview.
|
java.lang.Object |
getHelpSet()
Get the help set used to locate the "more info" for each question.
|
Interview |
getInterview(java.lang.String tag)
Get a sub-interview with a given tag name.
|
int |
getInterviewSemantics()
Determine which semantics are being used for interview and question
behavior.
|
Interview |
getParent()
Get the parent interview for which this is a child.
|
Question[] |
getPath()
Get the set of questions on the current path.
|
Question[] |
getPathToCurrent()
Get the set of questions on the current path up to and
including the current question.
|
java.util.Set |
getPropertyKeys()
Retrieve set of keys for the "external" values being stored in the
configuration.
|
java.util.Set |
getQuestions()
Get the complete set of questions in this interview and
recursively, in all child interviews.
|
Question[] |
getRawPath(boolean includeFinals)
Get the current set path of questions, including some things normally
hidden.
|
java.util.ResourceBundle |
getResourceBundle()
Get the resource bundle for this interview, used to look up
internationalized strings, such as the title and text of each question.
|
protected java.lang.String |
getResourceString(java.lang.String key)
Get an entry from the resource bundle.
|
protected java.lang.String |
getResourceString(java.lang.String key,
boolean checkAncestorsFirst)
Get an entry from the resource bundle.
|
Interview |
getRoot()
Get the root interview object for an interview series.
|
java.lang.String |
getTag()
Get a tag used to qualify the tags of questions in this interview.
|
java.lang.String |
getTitle()
Get a descriptive title associated with this interview.
|
boolean |
hasNext(Question q)
Determine if a question has a non-null successor.
|
boolean |
hasValidNext(Question q)
Determine if a question has a successor which is neither null
nor an ErrorQuestion.
|
boolean |
isChecklistEmpty()
Check whether any questions on the current path have any
associated checklist items.
|
static boolean |
isChecksumValid(java.util.Map data,
boolean okIfOmitted)
Deprecated.
As of version 4.4.1, checksums are no longer
calculated or checked. True is always returned.
|
boolean |
isEdited()
Determine if this interview as having been edited or not.
|
boolean |
isFinishable()
Check if the interview has been completed.
|
boolean |
isFirst(Question q)
Determine if a question is the first question of the interview.
|
protected boolean |
isInterviewFinishable()
Check if this subinterview has been completed.
|
boolean |
isLast(Question q)
Determine if a question is the last question of the interview.
|
boolean |
isRoot()
Determine if this is the root interview.
|
boolean |
isStarted()
Check if the interview has been started.
|
java.util.Iterator |
iteratePath(boolean flattenNestedInterviews)
Get an iterator for the set of questions on the current path.
|
java.util.Iterator |
iteratePathToCurrent(boolean flattenNestedInterviews)
Get an iterator for the set of questions on the current path
up to and including the current question.
|
void |
last()
Advance to the last question in the interview.
|
void |
load(java.util.Map data)
Load the state for questions from an archive map.
|
void |
load(java.util.Map data,
boolean checkChecksum)
Load the state for questions from an archive map.
|
void |
next()
Advance to the next question in the interview.
|
boolean |
pathContains(Interview i)
Check if the path contains questions from a specific interview.
|
boolean |
pathContains(Question q)
Check if the path contains a specific question.
|
void |
prev()
Back up to the previous question in the interview.
|
void |
propagateTemplateForAll() |
protected static java.util.Locale |
readLocale(java.util.Map data)
Reads information about locale from the given map.
|
void |
removeAllMarkers()
Remove all the markers, whatever their name.
|
void |
removeMarkers(java.lang.String name)
Remove all the markers with a specified name.
|
void |
removeObserver(Interview.Observer o)
Remove an observer previously registered to monitor updates to the interview.
|
void |
reset()
Start (or restart) the interview.
|
java.lang.String |
retrieveProperty(java.lang.String key)
Retrieve a property from the collection of "external" values being
stored in the configuration.
|
java.util.Set |
retrieveTemplateKeys() |
java.lang.String |
retrieveTemplateProperty(java.lang.String key)
Retrieve a template property.
|
void |
save(java.util.Map data)
Save the state for questions in an archive map.
|
protected void |
setBaseTag(java.lang.String newBaseTag)
Change the base tag for this interview.
|
void |
setCurrentQuestion(Question q)
Jump to a specific question in the interview.
|
protected void |
setDefaultImage(java.net.URL u)
Set a default image to be used for the questions of an interview.
|
void |
setEdited(boolean edited)
Mark this interview as having been edited or not.
|
void |
setExportIgnoreExceptionPolicy(int policy)
Set the policy regarding how to treat exceptions that may arise during export.
|
protected void |
setFirstQuestion(Question q)
Set the first question for an interview.
|
protected void |
setHelpSet(java.lang.Object hs)
Set the help set used to locate the "more info" for each question.
|
protected void |
setHelpSet(java.lang.String name)
Set the name of the help set used to locate the "more info"
for each question.
|
protected void |
setHelpSet(java.lang.String name,
java.io.File file)
Set the name of the help set used to locate the "more info"
for each question.
|
void |
setInterviewSemantics(int value)
This method is being used to toggle changes which are not
backwards compatible with existing interviews.
|
protected void |
setResourceBundle(java.lang.String name)
Set the base name of the resource bundle used to look up
internationalized strings, such as the title and text of each
question.
|
protected void |
setResourceBundle(java.lang.String name,
java.io.File file)
Set the base name of the resource bundle used to look up
internationalized strings, such as the title and text of each
question.
|
protected void |
setTitle(java.lang.String title)
Set a descriptive title to be used to annotate this interview.
|
java.lang.String |
storeProperty(java.lang.String key,
java.lang.String value)
Store an "external" value into the configuration.
|
void |
storeTemplateProperties(java.util.Properties props)
Clear a previous template properties and store the new into the configuration.
|
java.lang.String |
storeTemplateProperty(java.lang.String key,
java.lang.String value)
Store a template value into the configuration.
|
void |
updatePath()
Update the current path, typically because a response to
a question has changed.
|
void |
updatePath(Question q)
Update the current path, typically because a response to
a question has changed.
|
void |
verifyPathContains(Question q)
Verify that the current path contains a specified question,
and throw an exception if it does not.
|
protected static void |
writeLocale(java.util.Map data)
Writes information about current locale to the given map.
|
public static final int EXPORT_IGNORE_ALL_EXCEPTIONS
public static final int EXPORT_IGNORE_RUNTIME_EXCEPTIONS
public static final int EXPORT_IGNORE_NO_EXCEPTIONS
protected static final HelpSetFactory helpSetFactory
public static final int SEMANTIC_PRE_32
setInterviewSemantics(int)
,
Constant Field Valuespublic static final int SEMANTIC_VERSION_32
setInterviewSemantics(int)
,
Constant Field Valuespublic static final int SEMANTIC_VERSION_43
setInterviewSemantics(int)
,
Constant Field Valuespublic static final int SEMANTIC_MAX_VERSION
setInterviewSemantics(int)
,
Constant Field Valuesprotected static final java.lang.String QUESTION
protected static final java.lang.String INTERVIEW
protected static final java.lang.String LOCALE
protected static final java.lang.String MARKERS
protected static final java.lang.String MARKERS_PREF
protected static final java.lang.String EXTERNAL_PREF
protected static final java.lang.String TEMPLATE_PREF
protected Interview(java.lang.String tag)
tag
- A tag that will be used to qualify the tags of any
questions in this interview, to help ensure uniqueness of those
tags.protected Interview(Interview parent, java.lang.String baseTag)
parent
- The parent interview of which this is a part.baseTag
- A name that will be used to qualify the tags of any
questions in this interview, to help ensure uniqueness of those
tags. It will be combined with the parent's tag if that has been
specified.public Interview getParent()
public java.lang.String getTag()
protected void setTitle(java.lang.String title)
title
- A short descriptive title.getTitle()
public java.lang.String getTitle()
title
.
of the interview.setTitle(java.lang.String)
protected void setDefaultImage(java.net.URL u)
u
- A URL for the imageQuestion.setImage(java.lang.String)
,
Question.getImage()
,
getDefaultImage()
public java.net.URL getDefaultImage()
setDefaultImage(java.net.URL)
protected void setResourceBundle(java.lang.String name) throws java.util.MissingResourceException
name
- The name of the resource bundle used to look
up internationalized strings.java.util.MissingResourceException
- if the resource bundle
cannot be found.getResourceBundle()
protected void setResourceBundle(java.lang.String name, java.io.File file) throws java.util.MissingResourceException
name
- The name of the resource bundle used to look
up internationalized strings.file
- The directory to find name.java.util.MissingResourceException
- if the resource bundle
cannot be found.getResourceBundle()
public java.util.ResourceBundle getResourceBundle()
setResourceBundle(java.lang.String)
protected void setHelpSet(java.lang.String name) throws Interview.Fault
name
- The name of the help set containing the "more info"
for each question.Interview.HelpNotFoundFault
- if the help set could not be locatedInterview.BadHelpFault
- if some problem occurred while opening the help setInterview.Fault
getHelpSet()
,
setHelpSet(Object)
protected void setHelpSet(java.lang.Object hs)
hs
- The help set containing the "more info" for each question
in this interview.getHelpSet()
,
setHelpSet(String)
protected void setHelpSet(java.lang.String name, java.io.File file) throws Interview.Fault
name
- The name of the help set containing the "more info"
for each question.file
- The directory to find help set.Interview.HelpNotFoundFault
- if the help set could not be locatedInterview.BadHelpFault
- if some problem occurred while opening the help setInterview.Fault
getHelpSet()
,
setHelpSet(Object)
,
setHelpSet(String)
public java.lang.Object getHelpSet()
setHelpSet(java.lang.String)
public void setEdited(boolean edited)
edited
- whether or not this interview is marked as editedpublic boolean isEdited()
public Question getFirstQuestion()
setFirstQuestion(com.sun.interview.Question)
protected void setFirstQuestion(Question q)
q
- The initial questionjava.lang.IllegalStateException
- if it is too late to change the
initial question.getFirstQuestion()
public Interview getInterview(java.lang.String tag) throws Interview.Fault
tag
- The tag of the interview to be found.Interview.Fault
- if no interview is found with the given name.public boolean isFirst(Question q)
q
- the question to checkpublic boolean isLast(Question q)
q
- the question to checkpublic boolean hasNext(Question q)
q
- the question to checkpublic boolean hasValidNext(Question q)
q
- the question to checkpublic void reset()
public void next() throws Interview.Fault
disabled
will
be skipped over.Interview.Fault
- if there are no more questionspublic void prev() throws Interview.Fault
disabled
will
be skipped over.Interview.Fault
- if there is no previous question.public void last() throws Interview.Fault
disabled
will
be skipped over.Interview.Fault
- if there are no more questionspublic boolean isStarted()
information-only
questions.public boolean isFinishable()
FinalQuestion
.protected boolean isInterviewFinishable()
public void setCurrentQuestion(Question q) throws Interview.Fault
q
- The question which is to become the current
question in the interview.Interview.Fault
- if the question given is not on the current path.getCurrentQuestion()
public Question getCurrentQuestion()
setCurrentQuestion(com.sun.interview.Question)
public Question[] getPath()
FinalQuestion
,
never returns a successor.
Within a particular interview, a question may refer to a
nested interview, before continuing within the original interview.
Any such references to nested interviews are automatically
expanded by this method, leaving just the complete set of basic
questions on the path.setFirstQuestion(com.sun.interview.Question)
,
Question.getNext()
,
getPathToCurrent()
public Question[] getPathToCurrent()
getPath()
public Question[] getRawPath(boolean includeFinals)
includeFinals
- Should FinalQuestions be included.public java.util.Iterator iteratePath(boolean flattenNestedInterviews)
FinalQuestion
,
never returns a successor.
Within a particular interview, a question may refer to a
nested interview, before continuing within the original interview.
Such nested interviews may optionally be expanded by this method,
depending on the arguments.flattenNestedInterviews
- If true, any nested interviews will
be expanded in place and returned via the iterator; otherwise, the
the nested interview will be returned instead.iteratePathToCurrent(boolean)
public java.util.Iterator iteratePathToCurrent(boolean flattenNestedInterviews)
flattenNestedInterviews
- If true, any nested interviews will
be expanded in place and returned via the iterator; otherwise, the
the nested interview will be returned instead.iteratePath(boolean)
public void verifyPathContains(Question q) throws Interview.NotOnPathFault
q
- the question to be checkedInterview.NotOnPathFault
- if the current path does not contain
the specified question.public boolean pathContains(Question q)
q
- The question for which to check.public boolean pathContains(Interview i)
i
- The interview for which to check.public java.util.Set getQuestions()
public java.util.Map getAllQuestions()
public boolean isChecklistEmpty()
public Checklist createChecklist()
getPath()
,
Question.getChecklistItems()
public Checklist.Item createChecklistItem(java.lang.String sectionKey, java.lang.String textKey)
sectionKey
- A key to identify the section name within the interview's resource bundletextKey
- A key to identify the checklist item text within the interview's resource bundlepublic Checklist.Item createChecklistItem(java.lang.String sectionKey, java.lang.String textKey, java.lang.Object textArg)
sectionKey
- A key to identify the section name within the interview's resource bundletextKey
- A key to identify the checklist item text within the interview's resource bundletextArg
- a single argument to be formatted into the checklist item textpublic Checklist.Item createChecklistItem(java.lang.String sectionKey, java.lang.String textKey, java.lang.Object[] textArgs)
sectionKey
- A key to identify the section name within the interview's resource bundletextKey
- A key to identify the checklist item text within the interview's resource bundletextArgs
- an array of arguments to be formatted into the checklist item textpublic void removeMarkers(java.lang.String name)
name
- The name of the markers to be removedpublic void removeAllMarkers()
public void clearMarkedResponses(java.lang.String name)
name
- The name of the markers for the questions to be cleared.protected Question callInterview(Interview i, Question q)
i
- The nested interview to be called nextq
- The next question to be asked when the nested
interview has completes with a final question
.public void clear()
public void load(java.util.Map data) throws Interview.Fault
load
its state, according to its tag.
The data must normally contain a valid checksum, generated during save(java.util.Map)
.data
- The archive map from which the state should be loaded.Interview.Fault
- if the checksum is found to be incorrect.public void load(java.util.Map data, boolean checkChecksum) throws Interview.Fault
load
its state, according to its tag.
The data must normally contain a valid checksum, generated during save(java.util.Map)
.data
- The archive map from which the state should be loaded.checkChecksum
- If true, the checksum in the data will be checked.Interview.Fault
- if the checksum is found to be incorrect.public static boolean isChecksumValid(java.util.Map data, boolean okIfOmitted)
data
- The set of responses to be checked.okIfOmitted
- A boolean determining the response if
there is no checksum available in the datapublic void save(java.util.Map data)
save
its state, according to its tag.data
- The archive in which the values should be saved.protected static void writeLocale(java.util.Map data)
data
- target map to write data toLOCALE
,
readLocale(Map)
protected static java.util.Locale readLocale(java.util.Map data)
LOCALE
and then
tries to decode it to valid locale object.data
- map with interview valuesLOCALE
,
writeLocale(Map)
public void export(java.util.Map data)
Question.export(java.util.Map)
for each question returned by getPath()
.
It should be called on the root interview to export the values for all
questions on the current path, or it can be called on a sub-interview
to export just the values from the question in that sub-interview (and in turn,
in any further sub-interviews for which there are questions on the path.)
Unchecked exceptions that arise from each question's export method are treated
according to the policy set by setExportIgnoreExceptionPolicy for the interview
for which export was called.
It may be convenient to ignore runtime exceptions during export, if exceptions
may be thrown when the interview is incomplete. It may be preferred not
to ignore any exceptions, if no exceptions are expected.data
- The map in which the values will be placed.getPath()
,
setExportIgnoreExceptionPolicy(int)
,
EXPORT_IGNORE_ALL_EXCEPTIONS
,
EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,
EXPORT_IGNORE_NO_EXCEPTIONS
public int getExportIgnoreExceptionPolicy()
setExportIgnoreExceptionPolicy(int)
,
export(java.util.Map)
,
EXPORT_IGNORE_ALL_EXCEPTIONS
,
EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,
EXPORT_IGNORE_NO_EXCEPTIONS
public void setExportIgnoreExceptionPolicy(int policy)
policy
- a value representing the policy regarding how to treat exceptions that may arise during exportgetExportIgnoreExceptionPolicy()
,
export(java.util.Map)
,
EXPORT_IGNORE_ALL_EXCEPTIONS
,
EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,
EXPORT_IGNORE_NO_EXCEPTIONS
public void addObserver(Interview.Observer o)
o
- an observer to be notified as changes occurpublic void removeObserver(Interview.Observer o)
o
- the observer to be removed from the list taht are notifiedpublic boolean containsObserver(Interview.Observer o)
protected void setBaseTag(java.lang.String newBaseTag)
newBaseTag
- the new value for the base tag.public void setInterviewSemantics(int value)
value
- Which semantics the interview should use.SEMANTIC_PRE_32
,
SEMANTIC_VERSION_32
,
SEMANTIC_MAX_VERSION
,
getInterviewSemantics()
public int getInterviewSemantics()
setInterviewSemantics(int)
public java.lang.String storeProperty(java.lang.String key, java.lang.String value)
key
- The name of the key to store.value
- The value associated with the given key. Null to remove
the property from the current set of properties for this interview.retrieveProperty(java.lang.String)
public java.lang.String storeTemplateProperty(java.lang.String key, java.lang.String value)
key
- The name of the key to store.value
- The value associated with the given key.public void storeTemplateProperties(java.util.Properties props)
props
- The properties to store.public java.lang.String retrieveProperty(java.lang.String key)
key
- The key which identifies the property to retrieve.storeProperty(java.lang.String, java.lang.String)
public java.lang.String retrieveTemplateProperty(java.lang.String key)
key
- The key which identifies the property to retrieve.public java.util.Set retrieveTemplateKeys()
public java.util.Set getPropertyKeys()
storeProperty(java.lang.String, java.lang.String)
,
retrieveProperty(java.lang.String)
public java.util.Map<java.lang.String,java.lang.String> getExternalProperties()
storeProperty(java.lang.String, java.lang.String)
,
retrieveProperty(java.lang.String)
public void propagateTemplateForAll()
public boolean isRoot()
public Interview getRoot()
getRawPath(boolean)
information.public void updatePath()
public void updatePath(Question q)
q
- The question that was changed.protected java.lang.String getResourceString(java.lang.String key)
key
- the name of the entry to be returnedprotected 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 valueCopyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.