SalesPoint v3.3 API

users
Class AbstractCapability

java.lang.Object
  extended by users.AbstractCapability
All Implemented Interfaces:
Serializable, Capability
Direct Known Subclasses:
ActionCapability

public abstract class AbstractCapability
extends Object
implements Capability

Convenience class implementing basic capability behavior.

For convenience you can derive all your capability classes from AbstractCapability, which will manage names and display names.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
Serialized Form

Constructor Summary
AbstractCapability(String sName)
          Create a new capability with a given name.
 
Method Summary
 String getDisplayName()
          Get the display name of this capability using the default locale.
 String getDisplayName(Locale l)
          Get the display name of this capability according to a locale.
 String getName()
          Get the capability's name.
abstract  Capability getToggled()
          Get the capability that is the inverse to this one.
abstract  boolean isGranted()
          Return the grant state of this capability.
static void setDisplayNameResourceBundleName(String sBaseName)
          Set the base name for the resouce bundle that contains the capabilities' display names.
 String toString()
          Return a string representation of this capability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractCapability

public AbstractCapability(String sName)
Create a new capability with a given name.

Parameters:
sName - the name of the capability.
Method Detail

getName

public String getName()
Get the capability's name.

Specified by:
getName in interface Capability
Returns:
the capability's name.
Override:
Never

getDisplayName

public String getDisplayName()
Get the display name of this capability using the default locale.

This is identical to

   getDisplayName (Locale.getDefault());
 

Specified by:
getDisplayName in interface Capability
Returns:
the display name of this capability according to the default locale.
Override:
Never

getDisplayName

public String getDisplayName(Locale l)
Get the display name of this capability according to a locale. You can set the base name of the resource bundle to be used by calling setDisplayNameResourceBundleName(java.lang.String).

Specified by:
getDisplayName in interface Capability
Parameters:
l - the locale according to which to get the display name
Returns:
the display name according to the locale.
Override:
Never

isGranted

public abstract boolean isGranted()
Return the grant state of this capability. This method is abstract and you'll have to redefine it in subclasses.

Specified by:
isGranted in interface Capability
Returns:
true if this capability grants rights.
Override:
Always

getToggled

public abstract Capability getToggled()
Get the capability that is the inverse to this one. This method is abstract and you'll have to redefine it in subclasses.

Specified by:
getToggled in interface Capability
Returns:
the capability that is the inverse to this one.
Override:
Always

toString

public String toString()
Return a string representation of this capability.

The format of the returned string is:

display name <name>: grant state

Overrides:
toString in class Object
Returns:
a string representation of this capability.
Override:
Sometimes

setDisplayNameResourceBundleName

public static final void setDisplayNameResourceBundleName(String sBaseName)
Set the base name for the resouce bundle that contains the capabilities' display names. The resource must contain a String for each Capability. The key for the String must be: capabilities.display_names.capability_name


SalesPoint v3.3 API