Package org.osgi.util.mobile
Class UserPromptCondition
java.lang.Object
org.osgi.util.mobile.UserPromptCondition
- All Implemented Interfaces:
org.osgi.service.condpermadmin.Condition
Class representing a user prompt condition. Instances of this class hold two
values: a prompt string that is to be displayed to the user and the
permission level string according to MIDP2.0 (oneshot, session, blanket).
-
Field Summary
Fields inherited from interface org.osgi.service.condpermadmin.Condition
FALSE, TRUE
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.service.condpermadmin.Condition
getCondition
(org.osgi.framework.Bundle bundle, org.osgi.service.condpermadmin.ConditionInfo conditionInfo) Returns a UserPromptCondition object with the given prompt string and permission level.boolean
Checks whether the condition may change during the lifetime of the UserPromptCondition object.boolean
Checks if theisSatisfied()
method needs to prompt the user, thus cannot give results instantly.boolean
Displays the prompt string to the user and returns true if the user accepts.boolean
isSatisfied
(org.osgi.service.condpermadmin.Condition[] conds, Dictionary context) Checks an array of UserPrompt conditions.
-
Method Details
-
getCondition
public static org.osgi.service.condpermadmin.Condition getCondition(org.osgi.framework.Bundle bundle, org.osgi.service.condpermadmin.ConditionInfo conditionInfo) Returns a UserPromptCondition object with the given prompt string and permission level. The user should be given choice as to what level of permission is given. Thus, the lifetime of the permission is controlled by the user.- Parameters:
bundle
- the bundle to ask about.conditionInfo
- the conditionInfo containing the construction information. ItsConditionInfo.getArgs()
method should return a String array with 4 strings in it:- the possible permission levels. This is a comma-separated list that can contain following strings: ONESHOT SESSION BLANKET. The order is not important. This parameter is case-insensitive.
- the default permission level, one chosen from the possible permission levels. If it is an empty string, then there is no default. This parameter is case-insensitive.
- the message catalog base name. It will be loaded by a
ResourceBundle
, or equivalent from an exporting OSGi Bundle. Thus, if the catalogName is "com.provider.messages.userprompt", then there should be an OSGi Bundle exporting the "com.provider.messages" package, and inside it files like "userprompt_en_US.properties". - textual description of the condition, to be displayed to the user. If it starts with a '%' sign, then the message is looked up from the catalog specified previously. The key is the rest of the string after the '%' sign.
- Returns:
- The requested UserPromptCondition.
- Throws:
IllegalArgumentException
- if the parameters are malformed.NullPointerException
- if one of the parameters isnull
.
-
isPostponed
public boolean isPostponed()Checks if theisSatisfied()
method needs to prompt the user, thus cannot give results instantly. This depends on the permission level given ingetCondition(Bundle, ConditionInfo)
.- ONESHOT - isPostponed always returns true. The user is prompted for question every time.
- SESSION - isPostponed returns true until the user decides either yes or no for the current session.
- BLANKET - isPostponed returns true until the user decides either always or never.
isSatisfied()
returns false.
If the system supports an separately accessible permission management GUI, that may reset the condition to its initial state.- Specified by:
isPostponed
in interfaceorg.osgi.service.condpermadmin.Condition
- Returns:
- True, if user interaction is needed.
-
isMutable
public boolean isMutable()Checks whether the condition may change during the lifetime of the UserPromptCondition object. This depends on the permission level given ingetCondition(Bundle, ConditionInfo)
.- ONESHOT - true
- SESSION - true, if the application model's session lifetime is shorter than the UserPromptCondition object lifetime
- BLANKET - false
- Specified by:
isMutable
in interfaceorg.osgi.service.condpermadmin.Condition
- Returns:
- True, if the condition can change.
-
isSatisfied
public boolean isSatisfied()Displays the prompt string to the user and returns true if the user accepts. Depending on the amount of levels the condition is assigned to, the prompt may have multiple accept buttons and one of them can be selected by default (see default level parameter atgetCondition(Bundle, ConditionInfo)
). It must always be possible for the user to stop further prompting of this question, even with ONESHOT and SESSION levels. In case of BLANKET and SESSION levels, it is possible that the user has already answered the question, in this case there will be no prompting, but immediate return with the previous answer.- Specified by:
isSatisfied
in interfaceorg.osgi.service.condpermadmin.Condition
- Returns:
- True if the user accepts the prompt (or accepts any prompt in case there are multiple permission levels).
-
isSatisfied
Checks an array of UserPrompt conditions.- Specified by:
isSatisfied
in interfaceorg.osgi.service.condpermadmin.Condition
- Parameters:
conds
- The array containing the UserPrompt conditions to evaluate.context
- Storage area for evaluation. TheConditionalPermissionAdmin
may evaluate a condition several times for one permission check, so this context will be used to store results of ONESHOT questions. This way asking the same question twice in a row can be avoided. If context is null, temporary results will not be stored.- Returns:
- True, if all conditions are satisfied.
- Throws:
NullPointerException
- if conds is null.
-