Package com.sun.interview
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 class
Constraints allowing a value to be either a boolean or Yes/No response.static class
Constrains the response to filenames or paths, and allows chooser widgets to be rendered for the user when appropriate.static class
Constraints specifying a floating point type.static class
static class
Value restrictions for string type responses.static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Properties
The current (default or latest) response to this question. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PropertiesQuestion
(Interview interview, String tag) Create a question with a nominated tag.protected
PropertiesQuestion
(Interview interview, String tag, String... keys) Create a question with a nominated tag.protected
PropertiesQuestion
(Interview interview, String tag, Properties props) Create a question with a nominated tag. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear any response to this question, resetting the value back to its initial state.void
createGroup
(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.boolean
isEntryVisible
(String key) Determine if the given property is visible to the user.boolean
isReadOnlyValue
(String key) Determine if a value is read-only.boolean
Check if the question always has a valid response.boolean
Check if the question currently has a valid response.final String
isValueValid
(String key) Convenience method for finding out the status of a particular value.protected static Properties
protected void
Load the value for this question from a dictionary, using the tag as the key.protected void
Save the value for this question in a dictionary, using the tag as the key.void
Apply constraints to a value.void
setDefaultValue
(Properties props) Set the default response for this question, used by the clear method.void
Set the presentation group to which the key(s) should belong.void
protected void
Set the keys to be shown in the properties table.protected void
setProperties
(Properties props) The current value will be set to all false;void
Set the current value.void
Set a specific property within this question.void
setValue
(Properties props) Private because we need to maintain internal consistency, especially with the i18n info.void
updateProperties
(String[]... props) Update the given properties.void
updateProperty
(String key, String val) Update the given property.Methods inherited from class com.sun.interview.Question
addMarker, equals, export, getChecklistItems, getHelpID, getImage, getInterview, getKey, getNext, getResourceString, getResourceString, getSummary, getTag, getText, getTextArgs, hashCode, hasMarker, isEnabled, isHidden, reload, removeMarker, setHelpID, setImage, setImage, setSummary, setText
-
Field Details
-
value
The current (default or latest) response to this question.
-
-
Constructor Details
-
PropertiesQuestion
Create a question with a nominated tag. If this constructor is used, the choices must be supplied separately.- Parameters:
interview
- The interview containing this question.tag
- A unique tag to identify this specific question.
-
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
Set the current value. -
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:Question
Get the response to this question as a string.- Specified by:
getStringValue
in 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:
setValue
in 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:Question
Check if the question currently has a valid response.- Specified by:
isValueValid
in classQuestion
- Returns:
- true if the question currently has a valid response, and false otherwise.
-
isValueAlwaysValid
public boolean isValueAlwaysValid()Description copied from class:Question
Check if the question always has a valid response. This may be true, for example, for a choice question with a default response.- Specified by:
isValueAlwaysValid
in classQuestion
- Returns:
- true if the question always has a valid response, and false otherwise.
-
clear
public void clear()Clear any response to this question, resetting the value back to its initial state. -
load
Load the value for this question from a dictionary, using the tag as the key. -
save
Save the value for this question in a dictionary, using the tag as the key. -
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 inprops
does 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
Get the keys which are registered with the given group.- Parameters:
group
- Group name to query. Null returns the groupless keys.- Returns:
- Null if the group is empty or does not exist, else the keys and values in this array.
- See Also:
-
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.group
andjck.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
Calculates constraint key for table row. By default constraint key is a value of first column- Parameters:
values
- Array of table row data- Returns:
- a key
-
getKeyPropertyName
Get the property name for displayed key value in the table- Parameters:
key
- value of the key in the table- Returns:
- key or the property name for the key
-
getPresentationKeys
Returns the localized key values to display -
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.
-