Class PropertiesQuestion
java.lang.Object
com.sun.interview.Question
com.sun.interview.CompositeQuestion
com.sun.interview.PropertiesQuestion
A
question which consists of many key-value pairs. The
values are altered by the user, the key is immutable. The output of this
question is a Properties object. The key in the properties object is always
the internal name, not the internationalized name. If internationalized
key names are supplied, they are used only for presentation.
The presentation info is store here instead of in a renderer class because multiple clients need to render this question.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConstraints allowing a value to be either a boolean or Yes/No response.static classConstrains the response to filenames or paths, and allows chooser widgets to be rendered for the user when appropriate.static classConstraints specifying a floating point type.static classstatic classValue restrictions for string type responses.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropertiesThe current (default or latest) response to this question. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPropertiesQuestion(Interview interview, String tag) Create a question with a nominated tag.protectedPropertiesQuestion(Interview interview, String tag, String... keys) Create a question with a nominated tag.protectedPropertiesQuestion(Interview interview, String tag, Properties props) Create a question with a nominated tag. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear any response to this question, resetting the value back to its initial state.voidcreateGroup(String name) Create a new group.getConstraintKeyFromRow(Object... values) Calculates constraint key for table row.getConstraints(String key) Get the default response for this question.String[][]Get the keys which are registered with the given group.getGroupDisplayName(String group) Get the display (localized) name of the group.String[]Get the names of the groups being used by the current set of values.String[][]Get the keys which are currently invalid and blocking the question (getNext() returning null).Get the header string for the column in the table that contains the key names.getKeyPropertyName(String key) Get the property name for displayed key value in the tableEnumeration<?> getKeys()Get the set of keys currently used this question.Returns the localized key values to displayGet the response to this question as a string.String[][]getValue()Get the current (default or latest) response to this question.Get the header string for the column in the table that contains the value names.Verify this question is on the current path, and if it is, return the current value.booleanisEntryVisible(String key) Determine if the given property is visible to the user.booleanisReadOnlyValue(String key) Determine if a value is read-only.booleanCheck if the question always has a valid response.booleanCheck if the question currently has a valid response.final StringisValueValid(String key) Convenience method for finding out the status of a particular value.protected static Propertiesprotected voidLoad the value for this question from a dictionary, using the tag as the key.protected voidSave the value for this question in a dictionary, using the tag as the key.voidApply constraints to a value.voidsetDefaultValue(Properties props) Set the default response for this question, used by the clear method.voidSet the presentation group to which the key(s) should belong.voidprotected voidSet the keys to be shown in the properties table.protected voidsetProperties(Properties props) The current value will be set to all false;voidSet the current value.voidSet a specific property within this question.voidsetValue(Properties props) Private because we need to maintain internal consistency, especially with the i18n info.voidupdateProperties(String[]... props) Update the given properties.voidupdateProperty(String key, String val) Update the given property.Methods inherited from class 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
-
Field Details
-
value
The current (default or latest) response to this question.
-
-
Constructor Details
-
PropertiesQuestion
-
PropertiesQuestion
Create a question with a nominated tag. Not recommended since this is not internationalized.- Parameters:
interview- The interview containing this question.tag- A unique tag to identify this specific question.props- The literal keys and values. A shallow copy of this is used.- Throws:
NullPointerException- if choices is null
-
PropertiesQuestion
Create a question with a nominated tag. The keys must be registered in the resource bundle for this question for internationalization purposes. They will be looked up by this questions tag, plus each of the key values.- Parameters:
interview- The interview containing this question.tag- A unique tag to identify this specific question.keys- Internal name of the keys- Throws:
NullPointerException- if choices is null
-
-
Method Details
-
load
-
setProperties
The current value will be set to all false;- Parameters:
props- The set of names for the choices for this question.- Throws:
NullPointerException- if choices is null- See Also:
-
setKeys
Set the keys to be shown in the properties table. Previous properties are removed, and the new values are all the empty string. The current value will be set to an empty string.- Parameters:
keys- The set of names of the choices for this question.localize- if false, the choices will be used directly as the display choices; otherwise the choices will be used to construct keys to get localized values from the interview's resource bundle.- Throws:
NullPointerException- if choices is null- See Also:
-
getKeys
Get the set of keys currently used this question. Includes all hidden and read-only values as well.- Returns:
- The set of keys (internal non-i18n value)
- See Also:
-
getDefaultValue
Get the default response for this question.- Returns:
- the default response for this question.
- See Also:
-
setDefaultValue
Set the default response for this question, used by the clear method.- Parameters:
props- the default response for this question.- See Also:
-
getValue
Get the current (default or latest) response to this question.- Returns:
- The current value - a cloned copy.
- Throws:
IllegalStateException- if no choices have been set, defining the set of responses to this question- See Also:
-
setValue
-
setValue
Private because we need to maintain internal consistency, especially with the i18n info. -
getValueOnPath
Verify 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:
-
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:
-
setValue
Set a specific property within this question. The property must exist before it can be set, else a Fault is thrown to prevent unauthorized additions of properties to the question value.- Specified by:
setValuein classCompositeQuestion- Parameters:
key- the key of the property to set, must not be nullv- the new value for the property, must not be null- Throws:
Interview.Fault- if the key does not already exist in the question's value.NullPointerException- if either parameter is nullInterview.Fault- if the specified key does not exist in the question- See Also:
-
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.
-
clear
-
load
-
save
-
isReadOnlyValue
Determine if a value is read-only. -
isEntryVisible
Determine if the given property is visible to the user. If it is not, the value is not presented in the GUI for editing and is hidden in any reports which show the state of the interview. Nonetheless, it is still present and can be altered manually on the command line or by editing the configuration file. So it is truly invisible, yet real.- Returns:
- True if the entry is visible (default), false otherwise.
-
getInvalidKeys
Get the keys which are currently invalid and blocking the question (getNext() returning null). It is recommended but not required that this method return null if the question is not blocked (getNext() != null). This default implementation of this method is to check any ValueConstraint objects for each key and return those results. If you override this method, it is highly recommended that you allow this to take place, then add in any additional checking to the results provided by this base implementation.- Returns:
- Invalid key in index zero, localized explanation in index one. Null means there are no invalid keys.
-
isValueValid
Convenience method for finding out the status of a particular value. This method is final because subclasses should implement getInvalidKeys().- Parameters:
key- The key to query. Must not be null.- Returns:
- The explanation for the value being invalid. Null if the value is reported as valid.
- See Also:
-
updateProperties
Update the given properties. New properties cannot be added this way.- Parameters:
props- Properties to update, keys in first index, values in the second.- Throws:
IllegalArgumentException- If a property inpropsdoes not exist.
-
updateProperty
Update the given property. New properties cannot be added this way.- Parameters:
key- Property to update.val- Value for the property.- Throws:
IllegalArgumentException- If the property does not exist.
-
createGroup
Create a new group.- Throws:
IllegalStateException- If the group requested already exists.
-
setGroup
Set the presentation group to which the key(s) should belong. If the key is in another group, it will be removed from that one. The- Parameters:
group- internal name for the group. Internationalized version must be available in the resource bundle as tag+group.key- Which keys to add to the group.- Throws:
IllegalArgumentException- If an attempt is made to add to a group which does not exist.IllegalStateException- If an attempt is made to group a key which is not present.- See Also:
-
setGroup
-
getGroups
Get the names of the groups being used by the current set of values. Groups which are empty are not listed; groups may become empty if client code attempts to put a key in more than one group.- Returns:
- Group names, null if no grouping is in use.
- See Also:
-
getGroup
-
getUngrouped
- Returns:
- The keys and values which are not allocated to any group. Null if there are no ungrouped values.
- See Also:
-
getGroupDisplayName
Get the display (localized) name of the group. The resource necessary is the question tag, with the group name and ".group" appended. That isjck.qTable.basic.groupandjck.qTable.advanced.group.- Parameters:
group- The internal group name, as is used in the rest of this API.- Returns:
- The localized group name, the generated bundle key if that cannot be found.
-
getKeyHeaderName
Get the header string for the column in the table that contains the key names. A short name is recommended for onscreen space considerations.- Returns:
- A string describing the key column in the table.
-
getValueHeaderName
Get the header string for the column in the table that contains the value names. A short name is recommended for onscreen space considerations.- Returns:
- A string describing the value column in the table.
-
setConstraints
Apply constraints to a value.- Throws:
IllegalArgumentException- If the key supplied does not exist in the current data.- See Also:
-
getConstraintKeyFromRow
-
getKeyPropertyName
-
getPresentationKeys
-
getConstraints
- Parameters:
key- The key for the value to get constraints for.- Returns:
- Constraints object for the specified key, null if there are no known constraints.
-