ru.tehkode.permissions
Class PermissionGroup

java.lang.Object
  extended by ru.tehkode.permissions.PermissionEntity
      extended by ru.tehkode.permissions.PermissionGroup
All Implemented Interfaces:
Comparable<PermissionGroup>
Direct Known Subclasses:
ProxyPermissionGroup

public abstract class PermissionGroup
extends PermissionEntity
implements Comparable<PermissionGroup>

Author:
t3hk0d3

Field Summary
protected  boolean dirtyWeight
           
protected  int weight
           
 
Fields inherited from class ru.tehkode.permissions.PermissionEntity
debugMode, manager, patternCache, rangeExpression, timedPermissions, timedPermissionsTime, virtual
 
Constructor Summary
PermissionGroup(String groupName, PermissionManager manager)
           
 
Method Summary
 void addPermission(String permission, String worldName)
          Add permissions for specified world
 void addTimedPermission(String permission, String world, int lifeTime)
          Adds timed permission to specified world in seconds
protected  void clearMembersCache()
           
 int compareTo(PermissionGroup o)
           
 Map<String,PermissionGroup[]> getAllParentGroups()
           
 PermissionGroup[] getChildGroups()
           
 PermissionGroup[] getChildGroups(String worldName)
          Return array of direct child group objects
 PermissionGroup[] getDescendantGroups()
           
 PermissionGroup[] getDescendantGroups(String worldName)
          Return array of descendant group objects
protected  void getInheritedPermissions(String worldName, List<String> permissions, boolean groupInheritance, boolean worldInheritance)
           
 String getOption(String optionName, String worldName, String defaultValue)
          Get option in world
 String getOwnOption(String option)
           
 String getOwnOption(String option, String world)
           
abstract  String getOwnOption(String option, String world, String defaultValue)
          Returns option value in specified world without inheritance This mean option value wouldn't be inherited from parent groups
 boolean getOwnOptionBoolean(String optionName, String world, boolean defaultValue)
           
 double getOwnOptionDouble(String optionName, String world, double defaultValue)
           
 int getOwnOptionInteger(String optionName, String world, int defaultValue)
           
abstract  String[] getOwnPermissions(String world)
          Returns own (without inheritance) permissions of group for world
 String getOwnPrefix()
          Return non-inherited group prefix.
abstract  String getOwnPrefix(String worldName)
           
 String getOwnSuffix()
          Return non-inherited suffix prefix.
abstract  String getOwnSuffix(String worldName)
           
 PermissionGroup[] getParentGroups()
           
 PermissionGroup[] getParentGroups(String worldName)
          Returns array of parent groups objects
 String[] getParentGroupsNames()
           
 String[] getParentGroupsNames(String worldName)
          Returns direct parents names of this group
protected abstract  String[] getParentGroupsNamesImpl(String worldName)
           
 String[] getPermissions(String world)
          Return all entity permissions in specified world
 String getPrefix(String worldName)
          Overriden methods
 int getRank()
          Returns rank in ranking system.
 String getRankLadder()
          Returns ranking ladder where this group is participating in
 String getSuffix(String worldName)
          Return entity suffix
 PermissionUser[] getUsers()
           
 PermissionUser[] getUsers(String worldName)
          Return array of direct members (users) of this group
 int getWeight()
           
protected  PermissionGroup[] getWorldGroups(String worldName)
           
 boolean isChildOf(PermissionGroup group)
           
 boolean isChildOf(PermissionGroup group, boolean checkInheritance)
           
 boolean isChildOf(PermissionGroup group, String worldName)
           
 boolean isChildOf(PermissionGroup group, String worldName, boolean checkInheritance)
          Check if this group is descendant of specified group
 boolean isChildOf(String groupName)
           
 boolean isChildOf(String groupName, boolean checkInheritance)
           
 boolean isChildOf(String groupName, String worldName)
          Check if specified group is direct parent of this group
 boolean isChildOf(String groupName, String worldName, boolean checkInheritance)
          Check if this group is descendant of specified group
 boolean isDefault(String worldName)
           
 boolean isRanked()
          Checks if group is participating in ranking system
 void remove()
          Remove entity data from backend
protected abstract  void removeGroup()
           
 void removePermission(String permission, String worldName)
          Remove permission in world
 void removeTimedPermission(String permission, String world)
          Removes specified timed permission for world
 void setParentGroups(PermissionGroup[] parentGroups)
           
 void setParentGroups(PermissionGroup[] parentGroups, String worldName)
          Set parent groups
 void setParentGroups(String[] parentGroups)
           
abstract  void setParentGroups(String[] parentGroups, String worldName)
          Set parent groups
 void setRank(int rank)
          Set rank for this group
 void setRankLadder(String rankLadder)
          Set rank ladder for this group
 void setWeight(int weight)
           
 
Methods inherited from class ru.tehkode.permissions.PermissionEntity
addPermission, callEvent, callEvent, equals, explainExpression, getAllOptions, getAllPermissions, getMatchingExpression, getMatchingExpression, getName, getOption, getOption, getOptionBoolean, getOptionDouble, getOptionInteger, getOptions, getPrefix, getSuffix, getTimedPermissionLifetime, getTimedPermissions, getWorlds, has, has, hashCode, initialize, isDebug, isMatches, isVirtual, prepareRegexp, removePermission, save, setDebug, setName, setOption, setOption, setPermissions, setPermissions, setPrefix, setSuffix, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

weight

protected int weight

dirtyWeight

protected boolean dirtyWeight
Constructor Detail

PermissionGroup

public PermissionGroup(String groupName,
                       PermissionManager manager)
Method Detail

getOwnPrefix

public String getOwnPrefix()
Return non-inherited group prefix. This means if a group don't have has own prefix then empty string or null would be returned

Returns:
prefix as string

getOwnPrefix

public abstract String getOwnPrefix(String worldName)

getOwnSuffix

public final String getOwnSuffix()
Return non-inherited suffix prefix. This means if a group don't has own suffix then empty string or null would be returned

Returns:
suffix as string

getOwnSuffix

public abstract String getOwnSuffix(String worldName)

getOwnPermissions

public abstract String[] getOwnPermissions(String world)
Returns own (without inheritance) permissions of group for world

Parameters:
world - world's world name
Returns:
Array of permissions for world

getOwnOption

public abstract String getOwnOption(String option,
                                    String world,
                                    String defaultValue)
Returns option value in specified world without inheritance This mean option value wouldn't be inherited from parent groups

Parameters:
option -
world -
defaultValue -
Returns:
option value or defaultValue if option was not found in own options

getOwnOption

public String getOwnOption(String option)

getOwnOption

public String getOwnOption(String option,
                           String world)

getOwnOptionBoolean

public boolean getOwnOptionBoolean(String optionName,
                                   String world,
                                   boolean defaultValue)

getOwnOptionInteger

public int getOwnOptionInteger(String optionName,
                               String world,
                               int defaultValue)

getOwnOptionDouble

public double getOwnOptionDouble(String optionName,
                                 String world,
                                 double defaultValue)

getWeight

public int getWeight()

setWeight

public void setWeight(int weight)

isRanked

public boolean isRanked()
Checks if group is participating in ranking system

Returns:

getRank

public int getRank()
Returns rank in ranking system. 0 if group is not ranked

Returns:

setRank

public void setRank(int rank)
Set rank for this group

Parameters:
rank - Rank for group. Specify 0 to remove group from ranking

getRankLadder

public String getRankLadder()
Returns ranking ladder where this group is participating in

Returns:
Name of rank ladder as String

setRankLadder

public void setRankLadder(String rankLadder)
Set rank ladder for this group

Parameters:
rankLadder - Name of rank ladder

getParentGroupsNamesImpl

protected abstract String[] getParentGroupsNamesImpl(String worldName)

getParentGroups

public PermissionGroup[] getParentGroups(String worldName)
Returns array of parent groups objects

Returns:
array of groups objects

getParentGroups

public PermissionGroup[] getParentGroups()

getAllParentGroups

public Map<String,PermissionGroup[]> getAllParentGroups()

getWorldGroups

protected PermissionGroup[] getWorldGroups(String worldName)

getParentGroupsNames

public String[] getParentGroupsNames(String worldName)
Returns direct parents names of this group

Returns:
array of parents group names

getParentGroupsNames

public String[] getParentGroupsNames()

setParentGroups

public abstract void setParentGroups(String[] parentGroups,
                                     String worldName)
Set parent groups

Parameters:
parentGroups - Array of parent groups names to set

setParentGroups

public void setParentGroups(String[] parentGroups)

setParentGroups

public void setParentGroups(PermissionGroup[] parentGroups,
                            String worldName)
Set parent groups

Parameters:
parentGroups - Array of parent groups objects to set

setParentGroups

public void setParentGroups(PermissionGroup[] parentGroups)

removeGroup

protected abstract void removeGroup()

isChildOf

public boolean isChildOf(PermissionGroup group,
                         String worldName,
                         boolean checkInheritance)
Check if this group is descendant of specified group

Parameters:
group - group object of parent
checkInheritance - set to false to check only the direct inheritance
Returns:
true if this group is descendant or direct parent of specified group

isChildOf

public boolean isChildOf(PermissionGroup group,
                         boolean checkInheritance)

isChildOf

public boolean isChildOf(PermissionGroup group,
                         String worldName)

isChildOf

public boolean isChildOf(PermissionGroup group)

isChildOf

public boolean isChildOf(String groupName,
                         String worldName,
                         boolean checkInheritance)
Check if this group is descendant of specified group

Parameters:
groupName - name of group to check against
checkInheritance - set to false to check only the direct inheritance
Returns:

isChildOf

public boolean isChildOf(String groupName,
                         boolean checkInheritance)

isChildOf

public boolean isChildOf(String groupName,
                         String worldName)
Check if specified group is direct parent of this group

Parameters:
groupName - to check against
Returns:

isChildOf

public boolean isChildOf(String groupName)

getChildGroups

public PermissionGroup[] getChildGroups(String worldName)
Return array of direct child group objects

Returns:

getChildGroups

public PermissionGroup[] getChildGroups()

getDescendantGroups

public PermissionGroup[] getDescendantGroups(String worldName)
Return array of descendant group objects

Returns:

getDescendantGroups

public PermissionGroup[] getDescendantGroups()

getUsers

public PermissionUser[] getUsers(String worldName)
Return array of direct members (users) of this group

Returns:

getUsers

public PermissionUser[] getUsers()

isDefault

public boolean isDefault(String worldName)

getPrefix

public String getPrefix(String worldName)
Overriden methods

Specified by:
getPrefix in class PermissionEntity
Returns:
prefix

getSuffix

public String getSuffix(String worldName)
Description copied from class: PermissionEntity
Return entity suffix

Specified by:
getSuffix in class PermissionEntity
Returns:
suffix

getPermissions

public String[] getPermissions(String world)
Description copied from class: PermissionEntity
Return all entity permissions in specified world

Specified by:
getPermissions in class PermissionEntity
Parameters:
world - World name
Returns:
Array of permission expressions

addPermission

public void addPermission(String permission,
                          String worldName)
Description copied from class: PermissionEntity
Add permissions for specified world

Overrides:
addPermission in class PermissionEntity
Parameters:
permission - Permission to add
worldName - World name to add permission to

removePermission

public void removePermission(String permission,
                             String worldName)
Description copied from class: PermissionEntity
Remove permission in world

Overrides:
removePermission in class PermissionEntity
Parameters:
permission - Permission to remove

getInheritedPermissions

protected void getInheritedPermissions(String worldName,
                                       List<String> permissions,
                                       boolean groupInheritance,
                                       boolean worldInheritance)

addTimedPermission

public void addTimedPermission(String permission,
                               String world,
                               int lifeTime)
Description copied from class: PermissionEntity
Adds timed permission to specified world in seconds

Overrides:
addTimedPermission in class PermissionEntity
lifeTime - Lifetime of permission in seconds. 0 for transient permission (world disappear only after server reload)

removeTimedPermission

public void removeTimedPermission(String permission,
                                  String world)
Description copied from class: PermissionEntity
Removes specified timed permission for world

Overrides:
removeTimedPermission in class PermissionEntity

clearMembersCache

protected void clearMembersCache()

remove

public final void remove()
Description copied from class: PermissionEntity
Remove entity data from backend

Specified by:
remove in class PermissionEntity

getOption

public String getOption(String optionName,
                        String worldName,
                        String defaultValue)
Description copied from class: PermissionEntity
Get option in world

Specified by:
getOption in class PermissionEntity
Parameters:
optionName - Name of option
worldName - World to look for
defaultValue - Default value to fallback if no such option was found
Returns:
Value of option as String

compareTo

public int compareTo(PermissionGroup o)
Specified by:
compareTo in interface Comparable<PermissionGroup>


Copyright © 2011. All Rights Reserved.