ru.tehkode.permissions.backends.sql
Class SQLEntity

java.lang.Object
  extended by ru.tehkode.permissions.PermissionEntity
      extended by ru.tehkode.permissions.backends.sql.SQLEntity

public class SQLEntity
extends PermissionEntity

Author:
code

Nested Class Summary
static class SQLEntity.Type
           
 
Field Summary
protected  Map<String,String> commonOptions
           
protected  List<String> commonPermissions
           
protected  SQLConnection db
           
protected  Map<String,Set<String>> parents
           
protected  String prefix
           
protected  String suffix
           
protected  SQLEntity.Type type
           
protected  Map<String,Map<String,String>> worldsOptions
           
protected  Map<String,List<String>> worldsPermissions
           
 
Fields inherited from class ru.tehkode.permissions.PermissionEntity
debugMode, manager, patternCache, rangeExpression, timedPermissions, timedPermissionsTime, virtual
 
Constructor Summary
SQLEntity(String name, PermissionManager manager, SQLEntity.Type type, SQLConnection db)
           
 
Method Summary
protected  void fetchInfo()
           
protected  void fetchInheritance()
           
protected  void fetchPermissions()
           
 Map<String,Map<String,String>> getAllOptions()
          Return options for all worlds Common options stored as "" (empty string) as world.
 Map<String,String[]> getAllPermissions()
          Return permissions for all worlds Common permissions stored as "" (empty string) as world.
static String[] getEntitiesNames(SQLConnection sql, SQLEntity.Type type, boolean defaultOnly)
           
 String getOption(String option, String world, String defaultValue)
          Get option in world
 Map<String,String> getOptions(String world)
          Get options in world
 String[] getParentNames(String worldName)
           
 String[] getPermissions(String world)
          Return all entity permissions in specified world
 String getPrefix(String worldName)
          Returns entity prefix
 String getSuffix(String worldName)
          Return entity suffix
 String[] getWorlds()
          Return world names where entity have permissions/options/etc
 void remove()
          Remove entity data from backend
 void save()
          Save in-memory data to storage backend
 void setOption(String option, String value, String world)
          Set specified option in world
 void setParents(String[] parentGroups, String worldName)
           
 void setPermissions(String[] permissions, String world)
          Set permissions in world
 void setPrefix(String prefix, String worldName)
          Set prefix to value
 void setSuffix(String suffix, String worldName)
          Set suffix to value
protected  void updateInfo()
           
 
Methods inherited from class ru.tehkode.permissions.PermissionEntity
addPermission, addPermission, addTimedPermission, callEvent, callEvent, equals, explainExpression, getMatchingExpression, getMatchingExpression, getName, getOption, getOption, getOptionBoolean, getOptionDouble, getOptionInteger, getPrefix, getSuffix, getTimedPermissionLifetime, getTimedPermissions, has, has, hashCode, initialize, isDebug, isMatches, isVirtual, prepareRegexp, removePermission, removePermission, removeTimedPermission, setDebug, setName, setOption, setPermissions, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

db

protected SQLConnection db

worldsPermissions

protected Map<String,List<String>> worldsPermissions

worldsOptions

protected Map<String,Map<String,String>> worldsOptions

commonPermissions

protected List<String> commonPermissions

commonOptions

protected Map<String,String> commonOptions

parents

protected Map<String,Set<String>> parents

type

protected SQLEntity.Type type

prefix

protected String prefix

suffix

protected String suffix
Constructor Detail

SQLEntity

public SQLEntity(String name,
                 PermissionManager manager,
                 SQLEntity.Type type,
                 SQLConnection db)
Method Detail

getEntitiesNames

public static String[] getEntitiesNames(SQLConnection sql,
                                        SQLEntity.Type type,
                                        boolean defaultOnly)

getWorlds

public String[] getWorlds()
Description copied from class: PermissionEntity
Return world names where entity have permissions/options/etc

Specified by:
getWorlds in class PermissionEntity
Returns:

getPrefix

public String getPrefix(String worldName)
Description copied from class: PermissionEntity
Returns entity prefix

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

setPrefix

public void setPrefix(String prefix,
                      String worldName)
Description copied from class: PermissionEntity
Set prefix to value

Specified by:
setPrefix in class PermissionEntity
Parameters:
prefix - new prefix

setSuffix

public void setSuffix(String suffix,
                      String worldName)
Description copied from class: PermissionEntity
Set suffix to value

Specified by:
setSuffix in class PermissionEntity
Parameters:
suffix - new suffix

getParentNames

public String[] getParentNames(String worldName)

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

getOption

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

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

setOption

public void setOption(String option,
                      String value,
                      String world)
Description copied from class: PermissionEntity
Set specified option in world

Specified by:
setOption in class PermissionEntity
Parameters:
option - Option name
value - Value to set, null to remove
world - World name

setParents

public void setParents(String[] parentGroups,
                       String worldName)

getOptions

public Map<String,String> getOptions(String world)
Description copied from class: PermissionEntity
Get options in world

Specified by:
getOptions in class PermissionEntity
Returns:
Option value as string Map

getAllPermissions

public Map<String,String[]> getAllPermissions()
Description copied from class: PermissionEntity
Return permissions for all worlds Common permissions stored as "" (empty string) as world.

Specified by:
getAllPermissions in class PermissionEntity
Returns:
Map with world name as key and permissions array as value

getAllOptions

public Map<String,Map<String,String>> getAllOptions()
Description copied from class: PermissionEntity
Return options for all worlds Common options stored as "" (empty string) as world.

Specified by:
getAllOptions in class PermissionEntity
Returns:
Map with world name as key and map of options as value

setPermissions

public void setPermissions(String[] permissions,
                           String world)
Description copied from class: PermissionEntity
Set permissions in world

Specified by:
setPermissions in class PermissionEntity
Parameters:
permissions - Array of permissions to set
world - World to set permissions for

save

public void save()
Description copied from class: PermissionEntity
Save in-memory data to storage backend

Specified by:
save in class PermissionEntity

remove

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

Specified by:
remove in class PermissionEntity

updateInfo

protected void updateInfo()

fetchPermissions

protected final void fetchPermissions()

fetchInheritance

protected final void fetchInheritance()

fetchInfo

protected final void fetchInfo()


Copyright © 2011. All Rights Reserved.