org.salespointframework.core.users
Class AbstractCapability

java.lang.Object
  extended by org.salespointframework.core.users.AbstractCapability
All Implemented Interfaces:
Capability
Direct Known Subclasses:
ActionCapability, NameCapability

public abstract class AbstractCapability
extends java.lang.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
Version:
2.0 05/05/1999
Author:
Steffen Zschaler

Constructor Summary
AbstractCapability(java.lang.String sName)
          Create a new capability with a given name.
 
Method Summary
 java.lang.String getDisplayName()
          Get the display name of this capability using the default locale.
 java.lang.String getDisplayName(java.util.Locale l)
          Get the display name of this capability according to a locale.
 java.lang.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(java.lang.String sBaseName)
          Set the base name for the resouce bundle that contains the capabilities' display names.
 java.lang.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(java.lang.String sName)
Create a new capability with a given name.

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

getName

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

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

getDisplayName

public java.lang.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.

getDisplayName

public java.lang.String getDisplayName(java.util.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.

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.

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.

toString

public java.lang.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 java.lang.Object
Returns:
a string representation of this capability.

setDisplayNameResourceBundleName

public static final void setDisplayNameResourceBundleName(java.lang.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