Class Interview
- java.lang.Object
-
- com.sun.interview.Interview
-
- Direct Known Subclasses:
ConcurrencyInterview
,EnvironmentInterview
,ExcludeListInterview
,InterviewParameters
,InterviewSet
,KeywordsInterview
,KnownFailuresListInterview
,ListQuestion.Body
,PriorStatusInterview
,TestsInterview
,TimeoutFactorInterview
public class Interview extends java.lang.Object
The base class for an interview: a series ofquestions
, 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 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.
-
Field Summary
Fields Modifier and Type Field 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.static int
SEMANTIC_VERSION_50
Where necessary, the harness interview should behave as it did for the 4.3 release.protected static java.lang.String
TEMPLATE_PREF
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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<java.lang.String,java.lang.String> data)
Export values for questions on the current path, by callingQuestion.export(java.util.Map<java.lang.String, java.lang.String>)
for each question returned bygetPath()
.java.util.Map<java.lang.String,Question>
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<java.lang.String>
getPropertyKeys()
Retrieve set of keys for the "external" values being stored in the configuration.java.util.Set<Question>
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<java.lang.String,java.lang.String> data, boolean okIfOmitted)
Deprecated.As of version 4.4.1, checksums are no longer calculated or checked.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<Question>
iteratePath(boolean flattenNestedInterviews)
Get an iterator for the set of questions on the current path.java.util.Iterator<Question>
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<java.lang.String,java.lang.String> data)
Load the state for questions from an archive map.void
load(java.util.Map<java.lang.String,java.lang.String> 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<java.lang.String>
retrieveTemplateKeys()
java.lang.String
retrieveTemplateProperty(java.lang.String key)
Retrieve a template property.void
save(java.util.Map<java.lang.String,java.lang.String> 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.Map<java.lang.String,java.lang.String> 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<java.lang.String,java.lang.String> data)
Writes information about current locale to the given map.
-
-
-
Field Detail
-
EXPORT_IGNORE_ALL_EXCEPTIONS
public static final int EXPORT_IGNORE_ALL_EXCEPTIONS
A value indicating that export should ignore all exceptions that arise while calling each question's export method.
-
EXPORT_IGNORE_RUNTIME_EXCEPTIONS
public static final int EXPORT_IGNORE_RUNTIME_EXCEPTIONS
A value indicating that export should ignore runtime exceptions that arise while calling each question's export method.
-
EXPORT_IGNORE_NO_EXCEPTIONS
public static final int EXPORT_IGNORE_NO_EXCEPTIONS
A value indicating that export should not ignore any exceptions that arise while calling each question's export method.
-
SEMANTIC_PRE_32
public static final int SEMANTIC_PRE_32
Where necessary, the harness interview should behave as it did before the 3.2 release. This does not control every single possible change in behavior, but does control certain behaviors which may cause problems with interview code written against an earlier version of the harness.- See Also:
setInterviewSemantics(int)
, Constant Field Values
-
SEMANTIC_VERSION_32
public static final int SEMANTIC_VERSION_32
Where necessary, the harness interview should behave as it did for the 3.2 release. This does not control every single possible change in behavior, but does control certain behaviors which may cause problems with interview code written against an earlier version of the harness.- See Also:
setInterviewSemantics(int)
, Constant Field Values
-
SEMANTIC_VERSION_43
public static final int SEMANTIC_VERSION_43
Where necessary, the harness interview should behave as it did for the 4.3 release. This does not control every single possible change in behavior, but does control certain behaviors which may cause problems with interview code written against an earlier version of the harness.- See Also:
setInterviewSemantics(int)
, Constant Field Values
-
SEMANTIC_VERSION_50
public static final int SEMANTIC_VERSION_50
Where necessary, the harness interview should behave as it did for the 4.3 release. This does not control every single possible change in behavior, but does control certain behaviors which may cause problems with interview code written against an earlier version of the harness.- See Also:
setInterviewSemantics(int)
, Constant Field Values
-
SEMANTIC_MAX_VERSION
public static final int SEMANTIC_MAX_VERSION
The highest version number currently in use. Note that the compiler will probably inline this during compilation, so you will be locked at the version which you compile against. This is probably a useful behavior in this case.- See Also:
setInterviewSemantics(int)
, Constant Field Values
-
helpSetFactory
protected static final HelpSetFactory helpSetFactory
-
QUESTION
protected static final java.lang.String QUESTION
- See Also:
- Constant Field Values
-
INTERVIEW
protected static final java.lang.String INTERVIEW
- See Also:
- Constant Field Values
-
LOCALE
protected static final java.lang.String LOCALE
- See Also:
- Constant Field Values
-
MARKERS
protected static final java.lang.String MARKERS
- See Also:
- Constant Field Values
-
MARKERS_PREF
protected static final java.lang.String MARKERS_PREF
- See Also:
- Constant Field Values
-
EXTERNAL_PREF
protected static final java.lang.String EXTERNAL_PREF
- See Also:
- Constant Field Values
-
TEMPLATE_PREF
protected static final java.lang.String TEMPLATE_PREF
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Interview
protected Interview(java.lang.String tag)
Create a top-level interview.- Parameters:
tag
- A tag that will be used to qualify the tags of any questions in this interview, to help ensure uniqueness of those tags.
-
Interview
protected Interview(Interview parent, java.lang.String baseTag)
Create an interview to be used as part of another interview.- Parameters:
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.
-
-
Method Detail
-
isChecksumValid
@Deprecated public static boolean isChecksumValid(java.util.Map<java.lang.String,java.lang.String> data, boolean okIfOmitted)
Deprecated.As of version 4.4.1, checksums are no longer calculated or checked. True is always returned.Check if the checksum is valid for a set of responses. When responses are saved to a map, they are checksummed, so that they can be checked for validity when reloaded. This method verifies that a set of responses are acceptable for loading.- Parameters:
data
- The set of responses to be checked.okIfOmitted
- A boolean determining the response if there is no checksum available in the data- Returns:
- Always true.
-
writeLocale
protected static void writeLocale(java.util.Map<java.lang.String,java.lang.String> data)
Writes information about current locale to the given map.
This information is used later to properly restore locale-sensitive values, like numerics.- Parameters:
data
- target map to write data to- See Also:
LOCALE
,readLocale(Map)
-
readLocale
protected static java.util.Locale readLocale(java.util.Map<?,?> data)
Reads information about locale from the given map.
Implementation looks for the string keyed byLOCALE
and then tries to decode it to valid locale object.- Parameters:
data
- map with interview values- Returns:
- locale, decoded from value taken from map; or default (current) locale
- See Also:
LOCALE
,writeLocale(Map)
-
getParent
public Interview getParent()
Get the parent interview for which this is a child.- Returns:
- the parent interview, or null if no parent has been specified.
-
getTag
public java.lang.String getTag()
Get a tag used to qualify the tags of questions in this interview.- Returns:
- the title
-
getTitle
public java.lang.String getTitle()
Get a descriptive title associated with this interview. If not specified, the system will try and locate the title in the interview's resource bundle, using the resource nametitle
. of the interview.- Returns:
- the title
- See Also:
setTitle(java.lang.String)
-
setTitle
protected void setTitle(java.lang.String title)
Set a descriptive title to be used to annotate this interview.- Parameters:
title
- A short descriptive title.- See Also:
getTitle()
-
getDefaultImage
public java.net.URL getDefaultImage()
Get a default image to be used for the questions of an interview. If no default has been set for this interview, the parent's default image (if any) is used instead.- Returns:
- a URL for the default image to be used
- See Also:
setDefaultImage(java.net.URL)
-
setDefaultImage
protected void setDefaultImage(java.net.URL u)
Set a default image to be used for the questions of an interview.- Parameters:
u
- A URL for the image- See Also:
Question.setImage(java.lang.String)
,Question.getImage()
,getDefaultImage()
-
setResourceBundle
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. If the name is treated as filename of file which is located in directory file. The default is the interview tag name if this is a root interview. If this is a child interview, there is no default resource bundle.- Parameters:
name
- The name of the resource bundle used to look up internationalized strings.file
- The directory to find name.- Throws:
java.util.MissingResourceException
- if the resource bundle cannot be found.- See Also:
getResourceBundle()
-
getResourceBundle
public 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. If the bundle has not been set explicitly, it defaults to the parent's resource bundle; the root interview has a default resource bundle based on the interview tag name.- Returns:
- the resource bundle for this interview.
- See Also:
setResourceBundle(java.lang.String, java.io.File)
-
setResourceBundle
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. If the name starts with '/', it will be treated as an absolute resource name, and used "as is"; otherwise it will be treated as relative to the package in which the actual interview class is defined. The default is the interview tag name if this is a root interview. If this is a child interview, there is no default resource bundle.- Parameters:
name
- The name of the resource bundle used to look up internationalized strings.- Throws:
java.util.MissingResourceException
- if the resource bundle cannot be found.- See Also:
getResourceBundle()
-
setHelpSet
protected void setHelpSet(java.lang.String name, java.io.File file) throws Interview.Fault
Set the name of the help set used to locate the "more info" for each question. The name should identify a resource containing a JavaHelp helpset file. If the name is treated as filename of file which is located in directory file. If help sets are specified for child interviews, they will automatically be added into the help set for the root interview.- Parameters:
name
- The name of the help set containing the "more info" for each question.file
- The directory to find help set.- Throws:
Interview.HelpNotFoundFault
- if the help set could not be locatedInterview.BadHelpFault
- if some problem occurred while opening the help setInterview.Fault
- See Also:
getHelpSet()
,setHelpSet(Object)
,setHelpSet(String)
-
getHelpSet
public java.lang.Object getHelpSet()
Get the help set used to locate the "more info" for each question. If the help set has not been set explicitly, it defaults to the parent's help set.- Returns:
- the help set used to locate "more info" for questions in this interview.
- See Also:
setHelpSet(java.lang.String, java.io.File)
-
setHelpSet
protected void setHelpSet(java.lang.String name) throws Interview.Fault
Set the name of the help set used to locate the "more info" for each question. The name should identify a resource containing a JavaHelp helpset file. If the name starts with '/', it will be treated as an absolute resource name, and used "as is"; otherwise it will be treated as relative to the package in which the actual interview class is defined. If help sets are specified for child interviews, they will automatically be added into the help set for the root interview.- Parameters:
name
- The name of the help set containing the "more info" for each question.- Throws:
Interview.HelpNotFoundFault
- if the help set could not be locatedInterview.BadHelpFault
- if some problem occurred while opening the help setInterview.Fault
- See Also:
getHelpSet()
,setHelpSet(Object)
-
setHelpSet
protected void setHelpSet(java.lang.Object hs)
Set the help set used to locate the "more info" for each question. If help sets are specified for child interviews, they will automatically be added into the help set for the root interview.- Parameters:
hs
- The help set containing the "more info" for each question in this interview.- See Also:
getHelpSet()
,setHelpSet(String)
-
isEdited
public boolean isEdited()
Determine if this interview as having been edited or not.- Returns:
- true if this interview is marked as having been edited
-
setEdited
public void setEdited(boolean edited)
Mark this interview as having been edited or not.- Parameters:
edited
- whether or not this interview is marked as edited
-
getFirstQuestion
public Question getFirstQuestion()
Get the first question of the interview.- Returns:
- the first question of the interview
- See Also:
setFirstQuestion(com.sun.interview.Question)
-
setFirstQuestion
protected void setFirstQuestion(Question q)
Set the first question for an interview. This may be called more than once, but only while the interview is being constructed. Once any method has been called that refers to the interview path, the initial question may not be changed.- Parameters:
q
- The initial question- Throws:
java.lang.IllegalStateException
- if it is too late to change the initial question.- See Also:
getFirstQuestion()
-
getInterview
public Interview getInterview(java.lang.String tag) throws Interview.Fault
Get a sub-interview with a given tag name. All descendents are searched (i.e. all children, all their children, etc.)- Parameters:
tag
- The tag of the interview to be found.- Returns:
- the sub-interview with the specified name.
- Throws:
Interview.Fault
- if no interview is found with the given name.
-
isFirst
public boolean isFirst(Question q)
Determine if a question is the first question of the interview.- Parameters:
q
- the question to check- Returns:
- true if this is the first question.
-
isLast
public boolean isLast(Question q)
Determine if a question is the last question of the interview.- Parameters:
q
- the question to check- Returns:
- true if this is the last question.
-
hasNext
public boolean hasNext(Question q)
Determine if a question has a non-null successor.- Parameters:
q
- the question to check- Returns:
- true if this question has a non-null successor.
-
hasValidNext
public boolean hasValidNext(Question q)
Determine if a question has a successor which is neither null nor an ErrorQuestion.- Parameters:
q
- the question to check- Returns:
- true if this question has a successor which is neither null nor an ErrorQuestion
-
reset
public void reset()
Start (or restart) the interview. The current question is reset to the first question, and the current path is evaluated from there.
-
next
public void next() throws Interview.Fault
Advance to the next question in the interview. Questions that have beendisabled
will be skipped over.- Throws:
Interview.Fault
- if there are no more questions
-
prev
public void prev() throws Interview.Fault
Back up to the previous question in the interview. Questions that have beendisabled
will be skipped over.- Throws:
Interview.Fault
- if there is no previous question.
-
last
public void last() throws Interview.Fault
Advance to the last question in the interview. Questions that have beendisabled
will be skipped over.- Throws:
Interview.Fault
- if there are no more questions
-
isStarted
public boolean isStarted()
Check if the interview has been started. An interview is considered to be at the beginning if there is only one question on the current path of a type that requires a response. This indirectly implies it must be the last question on the current path, and must only be preceded byinformation-only
questions.- Returns:
- true if the first answerable question is unanswered.
-
isFinishable
public boolean isFinishable()
Check if the interview has been completed. An interview is considered to have been completed if the final question on the current path is of typeFinalQuestion
.- Returns:
- true if the interview has been completed.
-
isInterviewFinishable
protected boolean isInterviewFinishable()
Check if this subinterview has been completed. A subinterview is considered to have been completed if none of the questions from this subinterview on the current path return null as the result of getNext(). Note:compare this to isFinishable() which checks that the entire interview (of which this subinterview may be a part) is complete.- Returns:
- true is this subinterview has been completed.
-
getCurrentQuestion
public Question getCurrentQuestion()
Get the current question in the interview.- Returns:
- The current question.
- See Also:
setCurrentQuestion(com.sun.interview.Question)
-
setCurrentQuestion
public void setCurrentQuestion(Question q) throws Interview.Fault
Jump to a specific question in the interview. The question must be on the current path, but can be either before or after the current position at the time this is called.- Parameters:
q
- The question which is to become the current question in the interview.- Throws:
Interview.Fault
- if the question given is not on the current path.- See Also:
getCurrentQuestion()
-
getPath
public Question[] getPath()
Get the set of questions on the current path. The first question is determined by the interview; after that, each question in turn determines its successor. The path ends when a question indicates no successor (or erroneously returns a question that is already on the path, that would otherwise form a cycle). The special type of question,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.- Returns:
- an array containing the list of questions on the current path.
- See Also:
setFirstQuestion(com.sun.interview.Question)
,Question.getNext()
,getPathToCurrent()
-
getPathToCurrent
public Question[] getPathToCurrent()
Get the set of questions on the current path up to and including the current question.- Returns:
- an array containing the list of questions on the current path up to and including the current question
- See Also:
getPath()
-
getRawPath
public Question[] getRawPath(boolean includeFinals)
Get the current set path of questions, including some things normally hidden. Hidden, disabled and final questions are included upon demand. The list of questions is flattened to only include questions, no representation of the interview structure is given.- Parameters:
includeFinals
- Should FinalQuestions be included.- Returns:
- The current active path of questions, based on the requested options. Returns null if no path information is available.
-
iteratePath
public java.util.Iterator<Question> iteratePath(boolean flattenNestedInterviews)
Get an iterator for the set of questions on the current path. The first question is determined by the interview; after that, each question in turn determines its successor. The path ends when a question indicates no successor (or erroneously returns a question that is already on the path, that would otherwise form a cycle). The special type of question,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.- Parameters:
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.- Returns:
- an Iterator for the questions on the current path
- See Also:
iteratePathToCurrent(boolean)
-
iteratePathToCurrent
public java.util.Iterator<Question> iteratePathToCurrent(boolean flattenNestedInterviews)
Get an iterator for the set of questions on the current path up to and including the current question.- Parameters:
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.- Returns:
- an Iterator for the questions on the current path up to and including the current question
- See Also:
iteratePath(boolean)
-
verifyPathContains
public void verifyPathContains(Question q) throws Interview.NotOnPathFault
Verify that the current path contains a specified question, and throw an exception if it does not.- Parameters:
q
- the question to be checked- Throws:
Interview.NotOnPathFault
- if the current path does not contain the specified question.
-
pathContains
public boolean pathContains(Question q)
Check if the path contains a specific question.- Parameters:
q
- The question for which to check.- Returns:
- true if the question is found on the current path.
-
pathContains
public boolean pathContains(Interview i)
Check if the path contains questions from a specific interview.- Parameters:
i
- The interview for which to check.- Returns:
- true if the interview is found on the current path.
-
getQuestions
public java.util.Set<Question> getQuestions()
Get the complete set of questions in this interview and recursively, in all child interviews.- Returns:
- a set of all questions in this and every child interview.
-
getAllQuestions
public java.util.Map<java.lang.String,Question> getAllQuestions()
Get all questions in this interview and recursively, in all child interviews.- Returns:
- a map containing all questions in this and every child interview.
-
isChecklistEmpty
public boolean isChecklistEmpty()
Check whether any questions on the current path have any associated checklist items.- Returns:
- true if no questions have any corresponding checklist items, and false otherwise.
-
createChecklist
public Checklist createChecklist()
Create a checklist composed of all checklist items for questions on the current path.- Returns:
- a checklist composed of all checklist items for questions on the current path.
- See Also:
getPath()
,Question.getChecklistItems()
-
createChecklistItem
public Checklist.Item createChecklistItem(java.lang.String sectionKey, java.lang.String textKey)
Create a checklist item based on entries in the interview's resource bundle.- Parameters:
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 bundle- Returns:
- a Checklist.Item object composed from the appropriate entries in the interview's resource bundle
-
createChecklistItem
public 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.- Parameters:
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 text- Returns:
- a Checklist.Item object composed from the appropriate entries in the interview's resource bundle and the specified argument value
-
createChecklistItem
public 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.- Parameters:
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 text- Returns:
- a Checklist.Item object composed from the appropriate entries in the interview's resource bundle and the specified argument values
-
removeMarkers
public void removeMarkers(java.lang.String name)
Remove all the markers with a specified name.- Parameters:
name
- The name of the markers to be removed
-
removeAllMarkers
public void removeAllMarkers()
Remove all the markers, whatever their name.
-
clearMarkedResponses
public void clearMarkedResponses(java.lang.String name)
Clear the response to marked questions.- Parameters:
name
- The name of the markers for the questions to be cleared.
-
callInterview
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.- Parameters:
i
- The nested interview to be called nextq
- The next question to be asked when the nested interview has completes with afinal question
.- Returns:
- a pseudo-question that will call a nested interview before continuing with the specified follow-on question.
-
clear
public void clear()
Clear any responses to all the questions in this interview, and then recursively, in its child interviews.
-
load
public void load(java.util.Map<java.lang.String,java.lang.String> data) throws Interview.Fault
Load the state for questions from an archive map. The map will be passed to each question in this interview and in any child interviews, and each question shouldload
its state, according to its tag. The data must normally contain a valid checksum, generated duringsave(java.util.Map<java.lang.String, java.lang.String>)
.- Parameters:
data
- The archive map from which the state should be loaded.- Throws:
Interview.Fault
- if the checksum is found to be incorrect.
-
load
public void load(java.util.Map<java.lang.String,java.lang.String> data, boolean checkChecksum) throws Interview.Fault
Load the state for questions from an archive map. The map will be passed to each question in this interview and in any child interviews, and each question shouldload
its state, according to its tag. The data must normally contain a valid checksum, generated duringsave(java.util.Map<java.lang.String, java.lang.String>)
.- Parameters:
data
- The archive map from which the state should be loaded.checkChecksum
- If true, the checksum in the data will be checked.- Throws:
Interview.Fault
- if the checksum is found to be incorrect.
-
save
public void save(java.util.Map<java.lang.String,java.lang.String> data)
Save the state for questions in an archive map. The map will be passed to each question in this interview and in any child interviews, and each question shouldsave
its state, according to its tag.- Parameters:
data
- The archive in which the values should be saved.
-
export
public void export(java.util.Map<java.lang.String,java.lang.String> data)
Export values for questions on the current path, by callingQuestion.export(java.util.Map<java.lang.String, java.lang.String>)
for each question returned bygetPath()
. 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.- Parameters:
data
- The map in which the values will be placed.- See Also:
getPath()
,setExportIgnoreExceptionPolicy(int)
,EXPORT_IGNORE_ALL_EXCEPTIONS
,EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,EXPORT_IGNORE_NO_EXCEPTIONS
-
getExportIgnoreExceptionPolicy
public int getExportIgnoreExceptionPolicy()
Get a value representing the policy regarding how to treat exceptions that may arise during export.- Returns:
- a value representing the policy regarding how to treat exceptions that may arise during export.
- See Also:
setExportIgnoreExceptionPolicy(int)
,export(java.util.Map<java.lang.String, java.lang.String>)
,EXPORT_IGNORE_ALL_EXCEPTIONS
,EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,EXPORT_IGNORE_NO_EXCEPTIONS
-
setExportIgnoreExceptionPolicy
public void setExportIgnoreExceptionPolicy(int policy)
Set the policy regarding how to treat exceptions that may arise during export. The default value is to ignore runtime exceptions.- Parameters:
policy
- a value representing the policy regarding how to treat exceptions that may arise during export- See Also:
getExportIgnoreExceptionPolicy()
,export(java.util.Map<java.lang.String, java.lang.String>)
,EXPORT_IGNORE_ALL_EXCEPTIONS
,EXPORT_IGNORE_RUNTIME_EXCEPTIONS
,EXPORT_IGNORE_NO_EXCEPTIONS
-
addObserver
public void addObserver(Interview.Observer o)
Add an observer to monitor updates to the interview.- Parameters:
o
- an observer to be notified as changes occur
-
removeObserver
public void removeObserver(Interview.Observer o)
Remove an observer previously registered to monitor updates to the interview.- Parameters:
o
- the observer to be removed from the list taht are notified
-
containsObserver
public boolean containsObserver(Interview.Observer o)
-
setBaseTag
protected void setBaseTag(java.lang.String newBaseTag)
Change the base tag for this interview. This should not be done for most interviews, since the base tag is the basis for storing loading and storing values, and changing the base tag may lead to unexpected results. Changing the base tag will caused the tags in all statically nested interviews and questions to be updated as well. This method is primarily intended to be used when renaming dynamically allocated loop bodies in ListQuestion.- Parameters:
newBaseTag
- the new value for the base tag.
-
getInterviewSemantics
public int getInterviewSemantics()
Determine which semantics are being used for interview and question behavior. This is important because new behavior in future versions can cause unanticipated code flow, resulting in incorrect behavior of existing code.- Returns:
- The semantics that the interview is currently using.
- Since:
- 3.2
- See Also:
setInterviewSemantics(int)
-
setInterviewSemantics
public void setInterviewSemantics(int value)
This method is being used to toggle changes which are not backwards compatible with existing interviews. Changing this value after you first initialize the top-level interview object is not recommended or supported. This method should be called as soon as possible during construction. It is recommended that you select the most recent version possible when developing a new interview. As this interview ages and the harness libraries progress, the interview should remain locked at the current behavior. Each subsequent version works under the assumption that the behavior of all previous versions is also enabled, there is no way to select individual behaviors.The version numbers are effectively an indication of the harness version where the behavior was added (32 = 3.2, 50 = 5.0). Gaps in numbering would indicate that no incompatible behavior changes occurred.
Select PRE_32 behavior to select behaviors prior to 3.2.
In Version 32, the first versioned semantic change was introduced. Interviews will generally request SEMANTIC_PRE_32 for old semantics. This version has the behavioral changes:- ChoiceQuestion
- If the value is reset to null, resulting in the value being
"cleared", new behavior simply calls
clear()
to do this. Old behavior was to select either the last value or first possible choice (from the array of possible choices) THEN callupdatePath()
andsetEdited()
. - FileListQuestion
- During construction,
clear()
will be called before the default value is set, in older implementations it was not called. - FileQuestion
- During construction,
clear()
will be called before the default value is set, in older implementations it was not called.
In Version 43 changes to the way in which
export()
works were introduced. Earlier than this version, the list of questions to callexport()
upon with pre-generated as a flattened list of Questions (with all sub-interviews removed). In 43 and later, the structure is NOT flattened, but instead exporting will recurse into sub-interviews by calling its (the Interview)export()
. Additionally, questions which are on the path but hidden will be exported. Note that being hidden is not the same at being disabled.In Version 50, FileListQuestion has significantly altered processing of filters. See the
FileListQuestion.isValueValid()
for an explanation.- Parameters:
value
- Which semantics the interview should use.- Since:
- 3.2
- See Also:
SEMANTIC_PRE_32
,SEMANTIC_VERSION_32
,SEMANTIC_VERSION_43
,SEMANTIC_VERSION_50
,SEMANTIC_MAX_VERSION
,getInterviewSemantics()
-
storeProperty
public java.lang.String storeProperty(java.lang.String key, java.lang.String value)
Store an "external" value into the configuration. This is a value not associated with any interview question and in a separate namespace than all the question keys.- Parameters:
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.- Returns:
- The old value of this property, null if not previously set.
- See Also:
retrieveProperty(java.lang.String)
-
storeTemplateProperty
public java.lang.String storeTemplateProperty(java.lang.String key, java.lang.String value)
Store a template value into the configuration.- Parameters:
key
- The name of the key to store.value
- The value associated with the given key.- Returns:
- The old value of this property, null if not previously set.
-
storeTemplateProperties
public void storeTemplateProperties(java.util.Map<java.lang.String,java.lang.String> props)
Clear a previous template properties and store the new into the configuration.- Parameters:
props
- The properties to store.
-
retrieveProperty
public java.lang.String retrieveProperty(java.lang.String key)
Retrieve a property from the collection of "external" values being stored in the configuration.- Parameters:
key
- The key which identifies the property to retrieve.- Returns:
- The value associated with the given key, or null if it is not found.
- See Also:
storeProperty(java.lang.String, java.lang.String)
-
retrieveTemplateProperty
public java.lang.String retrieveTemplateProperty(java.lang.String key)
Retrieve a template property.- Parameters:
key
- The key which identifies the property to retrieve.- Returns:
- The value associated with the given key, or null if it is not found.
-
retrieveTemplateKeys
public java.util.Set<java.lang.String> retrieveTemplateKeys()
-
getPropertyKeys
public java.util.Set<java.lang.String> getPropertyKeys()
Retrieve set of keys for the "external" values being stored in the configuration.- Returns:
- The set of keys currently available. Null if there are none. All values in the Set are Strings.
- See Also:
storeProperty(java.lang.String, java.lang.String)
,retrieveProperty(java.lang.String)
-
getExternalProperties
public java.util.Map<java.lang.String,java.lang.String> getExternalProperties()
Get a (shallow) copy of the current "external" values.- Returns:
- The copy of the properties, null if there are none.
- See Also:
storeProperty(java.lang.String, java.lang.String)
,retrieveProperty(java.lang.String)
-
propagateTemplateForAll
public void propagateTemplateForAll()
-
isRoot
public boolean isRoot()
Determine if this is the root interview.- Returns:
- True if this is the root interview.
-
getRoot
public Interview getRoot()
Get the root interview object for an interview series. Some parts of the data are associated only with the root interview, such as tags, external values and thegetRawPath(boolean)
information.
-
updatePath
public void updatePath()
Update the current path, typically because a response to a question has changed.
-
updatePath
public void updatePath(Question q)
Update the current path, typically because a response to a question has changed.- Parameters:
q
- The question that was changed.
-
getResourceString
protected java.lang.String getResourceString(java.lang.String key)
Get an entry from the resource bundle. The parent and other ancestors bundles will be checked first before this interview's bundle, allowing the root interview a chance to override the default value provided by this interview.- Parameters:
key
- the name of the entry to be returned- Returns:
- the value of the resource, or null if not found
-
getResourceString
protected java.lang.String getResourceString(java.lang.String key, boolean checkAncestorsFirst)
Get an entry from the resource bundle. If checkAncestorsFirst is true, then the parent and other ancestors bundles will be checked first before this interview's bundle, allowing the root interview a chance to override the default value provided by this interview. Otherwise, the parent bundles will only be checked if this bundle does not provide a value.- Parameters:
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 value- Returns:
- the value of the resource, or null if not found
-
-