Package org.osgi.service.condpermadmin
Class ConditionInfo
- java.lang.Object
-
- org.osgi.service.condpermadmin.ConditionInfo
-
public class ConditionInfo extends java.lang.Object
Condition representation used by the Conditional Permission Admin service.This class encapsulates two pieces of information: a Condition type (class name), which must implement
Condition
, and the arguments passed to its constructor.In order for a Condition represented by a
ConditionInfo
to be instantiated and considered during a permission check, its Condition class must be available from the system classpath.The Condition class must either:
- Declare a public static
getCondition
method that takes aBundle
object and aConditionInfo
object as arguments. That method must return an object that implements theCondition
interface. - Implement the
Condition
interface and define a public constructor that takes aBundle
object and aConditionInfo
object as arguments.
- Declare a public static
-
-
Constructor Summary
Constructors Constructor Description ConditionInfo(java.lang.String encodedCondition)
Constructs aConditionInfo
object from the specified encodedConditionInfo
string.ConditionInfo(java.lang.String type, java.lang.String[] args)
Constructs aConditionInfo
from the specified type and args.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Determines the equality of twoConditionInfo
objects.java.lang.String[]
getArgs()
Returns arguments of thisConditionInfo
.java.lang.String
getEncoded()
Returns the string encoding of thisConditionInfo
in a form suitable for restoring thisConditionInfo
.java.lang.String
getType()
Returns the fully qualified class name of the condition represented by thisConditionInfo
.int
hashCode()
Returns the hash code value for this object.java.lang.String
toString()
Returns the string representation of thisConditionInfo
.
-
-
-
Constructor Detail
-
ConditionInfo
public ConditionInfo(java.lang.String type, java.lang.String[] args)
Constructs aConditionInfo
from the specified type and args.- Parameters:
type
- The fully qualified class name of the Condition represented by thisConditionInfo
.args
- The arguments for the Condition. These arguments are available to the newly created Condition by calling thegetArgs()
method.- Throws:
java.lang.NullPointerException
- Iftype
isnull
.
-
ConditionInfo
public ConditionInfo(java.lang.String encodedCondition)
Constructs aConditionInfo
object from the specified encodedConditionInfo
string. White space in the encodedConditionInfo
string is ignored.- Parameters:
encodedCondition
- The encodedConditionInfo
.- Throws:
java.lang.IllegalArgumentException
- If the specifiedencodedCondition
is not properly formatted.- See Also:
getEncoded()
-
-
Method Detail
-
getEncoded
public final java.lang.String getEncoded()
Returns the string encoding of thisConditionInfo
in a form suitable for restoring thisConditionInfo
.The encoded format is:
[type "arg0" "arg1" ...]
where argN are strings that must be encoded for proper parsing. Specifically, the"
,\
, carriage return, and line feed characters must be escaped using\"
,\\
,\r
, and\n
, respectively.The encoded string contains no leading or trailing whitespace characters. A single space character is used between type and "arg0" and between the arguments.
- Returns:
- The string encoding of this
ConditionInfo
.
-
toString
public java.lang.String toString()
Returns the string representation of thisConditionInfo
. The string is created by calling thegetEncoded
method on thisConditionInfo
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation of this
ConditionInfo
.
-
getType
public final java.lang.String getType()
Returns the fully qualified class name of the condition represented by thisConditionInfo
.- Returns:
- The fully qualified class name of the condition represented by
this
ConditionInfo
.
-
getArgs
public final java.lang.String[] getArgs()
Returns arguments of thisConditionInfo
.- Returns:
- The arguments of this
ConditionInfo
. An empty array is returned if theConditionInfo
has no arguments.
-
equals
public boolean equals(java.lang.Object obj)
Determines the equality of twoConditionInfo
objects. This method checks that specified object has the same type and args as thisConditionInfo
object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to test for equality with thisConditionInfo
object.- Returns:
true
ifobj
is aConditionInfo
, and has the same type and args as thisConditionInfo
object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code value for this object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code value for this object.
-
-