ru.tehkode.permissions
Class PermissionBackend

java.lang.Object
  extended by ru.tehkode.permissions.PermissionBackend
Direct Known Subclasses:
FileBackend, SQLBackend

public abstract class PermissionBackend
extends Object

Author:
code

Field Summary
protected  org.bukkit.util.config.Configuration config
           
protected  boolean createUserRecords
           
protected static String defaultBackend
           
protected  PermissionManager manager
           
protected static Map<String,Class<? extends PermissionBackend>> registedAliases
          Array of backend aliases
 
Constructor Summary
protected PermissionBackend(PermissionManager manager, org.bukkit.util.config.Configuration config)
           
 
Method Summary
 PermissionGroup createGroup(String name)
           
abstract  void dumpData(OutputStreamWriter writer)
          Dump data to native backend format
static PermissionBackend getBackend(String backendName, org.bukkit.util.config.Configuration config)
          Returns new backend class instance for specified backendName
static PermissionBackend getBackend(String backendName, PermissionManager manager, org.bukkit.util.config.Configuration config)
          Returns new Backend class instance for specified backendName
static PermissionBackend getBackend(String backendName, PermissionManager manager, org.bukkit.util.config.Configuration config, String fallBackBackend)
          Returns new Backend class instance for specified backendName
static String getBackendAlias(Class<? extends PermissionBackend> backendClass)
          Return alias for specified backend class If there is no such class registered the fullname of this class would be returned using backendClass.getName();
static Class<? extends PermissionBackend> getBackendClass(String alias)
          Returns Class object for specified alias, if there is no alias registered then try to find it using Class.forName(alias)
static String getBackendClassName(String alias)
          Return class name for alias
abstract  PermissionGroup getDefaultGroup(String worldName)
          Returns default group, a group that is assigned to a user without a group set
abstract  PermissionGroup getGroup(String name)
          Returns new PermissionGroup object for specified group name
abstract  PermissionGroup[] getGroups()
          Return all registered groups
 PermissionGroup[] getGroups(String groupName)
          Return child groups of specified group
 PermissionGroup[] getGroups(String groupName, boolean inheritance)
          Return child groups of specified group.
 PermissionGroup[] getGroups(String groupName, String worldName)
           
 PermissionGroup[] getGroups(String groupName, String worldName, boolean inheritance)
           
abstract  PermissionUser[] getRegisteredUsers()
          Return all registered users
abstract  PermissionUser getUser(String name)
          Returns new PermissionUser object for specified player name
 PermissionUser[] getUsers()
          Return all registered and online users
 PermissionUser[] getUsers(String groupName)
          Return users of specified group.
 PermissionUser[] getUsers(String groupName, boolean inheritance)
          Return users of specified group (and child groups)
 PermissionUser[] getUsers(String groupName, String worldName)
           
 PermissionUser[] getUsers(String groupName, String worldName, boolean inheritance)
           
abstract  String[] getWorldInheritance(String world)
          Returns an array of world names of specified world name
abstract  void initialize()
          Backend initialization should be done here
 boolean isCreateUserRecords()
           
static void registerBackendAlias(String alias, Class<? extends PermissionBackend> backendClass)
          Register new alias for specified backend class
abstract  void reload()
          Reload backend (reread permissions file, reconnect to database, etc)
 boolean removeGroup(String groupName)
          Removes the specified group
abstract  void setDefaultGroup(PermissionGroup group, String worldName)
          Set group as default group
abstract  void setWorldInheritance(String world, String[] parentWorlds)
          Set world inheritance parents for specified world
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultBackend

protected static final String defaultBackend
See Also:
Constant Field Values

manager

protected PermissionManager manager

config

protected org.bukkit.util.config.Configuration config

createUserRecords

protected boolean createUserRecords

registedAliases

protected static Map<String,Class<? extends PermissionBackend>> registedAliases
Array of backend aliases

Constructor Detail

PermissionBackend

protected PermissionBackend(PermissionManager manager,
                            org.bukkit.util.config.Configuration config)
Method Detail

initialize

public abstract void initialize()
Backend initialization should be done here


getUser

public abstract PermissionUser getUser(String name)
Returns new PermissionUser object for specified player name

Parameters:
name - Player name
Returns:
PermissionUser for specified player, or null on error.

getGroup

public abstract PermissionGroup getGroup(String name)
Returns new PermissionGroup object for specified group name

Parameters:
name - Group name
Returns:
PermissionGroup object, or null on error

createGroup

public PermissionGroup createGroup(String name)

removeGroup

public boolean removeGroup(String groupName)
Removes the specified group

Parameters:
groupName - Name of the group which should be removed
Returns:
true if group was removed, false if group has child groups

getDefaultGroup

public abstract PermissionGroup getDefaultGroup(String worldName)
Returns default group, a group that is assigned to a user without a group set

Returns:
Default group instance

setDefaultGroup

public abstract void setDefaultGroup(PermissionGroup group,
                                     String worldName)
Set group as default group

Parameters:
group -

getWorldInheritance

public abstract String[] getWorldInheritance(String world)
Returns an array of world names of specified world name

Parameters:
world - world name
Returns:
Array of parent worlds. If there is no parent world return empty array

setWorldInheritance

public abstract void setWorldInheritance(String world,
                                         String[] parentWorlds)
Set world inheritance parents for specified world

Parameters:
world - world name which inheritance should be set
parentWorlds - array of parent world names

getGroups

public abstract PermissionGroup[] getGroups()
Return all registered groups

Returns:

getGroups

public PermissionGroup[] getGroups(String groupName)
Return child groups of specified group

Parameters:
groupName -
Returns:
empty array if group has no children, empty or not exist

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   String worldName)

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   boolean inheritance)
Return child groups of specified group.

Parameters:
groupName -
inheritance - - If true a full list of descendants will be returned
Returns:
empty array if group has no children, empty or not exist

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   String worldName,
                                   boolean inheritance)

getUsers

public PermissionUser[] getUsers()
Return all registered and online users

Returns:

getRegisteredUsers

public abstract PermissionUser[] getRegisteredUsers()
Return all registered users

Returns:

getUsers

public PermissionUser[] getUsers(String groupName)
Return users of specified group.

Parameters:
groupName -
Returns:
null if there is no such group

getUsers

public PermissionUser[] getUsers(String groupName,
                                 String worldName)

getUsers

public PermissionUser[] getUsers(String groupName,
                                 boolean inheritance)
Return users of specified group (and child groups)

Parameters:
groupName -
inheritance - - If true return users list of descendant groups too
Returns:

getUsers

public PermissionUser[] getUsers(String groupName,
                                 String worldName,
                                 boolean inheritance)

reload

public abstract void reload()
Reload backend (reread permissions file, reconnect to database, etc)


dumpData

public abstract void dumpData(OutputStreamWriter writer)
                       throws IOException
Dump data to native backend format

Parameters:
writer - Writer where dumped data should be written to
Throws:
IOException

getBackendClassName

public static String getBackendClassName(String alias)
Return class name for alias

Parameters:
alias -
Returns:
Class name if found or alias if there is no such class name present

getBackendClass

public static Class<? extends PermissionBackend> getBackendClass(String alias)
                                                          throws ClassNotFoundException
Returns Class object for specified alias, if there is no alias registered then try to find it using Class.forName(alias)

Parameters:
alias -
Returns:
Throws:
ClassNotFoundException

registerBackendAlias

public static void registerBackendAlias(String alias,
                                        Class<? extends PermissionBackend> backendClass)
Register new alias for specified backend class

Parameters:
alias -
backendClass -

getBackendAlias

public static String getBackendAlias(Class<? extends PermissionBackend> backendClass)
Return alias for specified backend class If there is no such class registered the fullname of this class would be returned using backendClass.getName();

Parameters:
backendClass -
Returns:
alias or class fullname when not found using backendClass.getName()

getBackend

public static PermissionBackend getBackend(String backendName,
                                           org.bukkit.util.config.Configuration config)
Returns new backend class instance for specified backendName

Parameters:
backendName - Class name or alias of backend
config - Configuration object to access backend settings
Returns:
new instance of PermissionBackend object

getBackend

public static PermissionBackend getBackend(String backendName,
                                           PermissionManager manager,
                                           org.bukkit.util.config.Configuration config)
Returns new Backend class instance for specified backendName

Parameters:
backendName - Class name or alias of backend
manager - PermissionManager object
config - Configuration object to access backend settings
Returns:
new instance of PermissionBackend object

getBackend

public static PermissionBackend getBackend(String backendName,
                                           PermissionManager manager,
                                           org.bukkit.util.config.Configuration config,
                                           String fallBackBackend)
Returns new Backend class instance for specified backendName

Parameters:
backendName - Class name or alias of backend
manager - PermissionManager object
config - Configuration object to access backend settings
fallBackBackend - name of backend that should be used if specified backend was not found or failed to initialize
Returns:
new instance of PermissionBackend object

isCreateUserRecords

public boolean isCreateUserRecords()


Copyright © 2011. All Rights Reserved.