Last update: 2011-06-23

org.proteios.core
Class Setting<D extends SettingData>

java.lang.Object
  extended by org.proteios.core.BasicItem<D>
      extended by org.proteios.core.Setting<D>
All Implemented Interfaces:
AccessControlled, Identifiable
Direct Known Subclasses:
GlobalDefaultSetting

public abstract class Setting<D extends SettingData>
extends BasicItem<D>

This is the base class for all setting items. There are four types of settings:

Version:
2.0
Author:
Nicklas

Field Summary
static int MAX_NAME_LENGTH
          The maximum length of the name that can be stored in the database.
static int MAX_VALUE_LENGTH
          The maximum length of the value that can be stored in the database.
static Item TYPE
          The type of item represented by this class.
 
Method Summary
static Setting getById(DbControl dc, int id)
          Get a Setting item when you know the ID.
 String getName()
          Get the name of this setting.
 String getValue()
          Get the value of this setting.
 boolean isUsed()
          Settings are never linked to other items.
 void setName(String name)
          Set the name for this setting.
 void setValue(String value)
          Set the value for this setting.
 
Methods inherited from class org.proteios.core.BasicItem
checkPermission, equals, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.proteios.core.Identifiable
getType
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.SETTING, Identifiable.getType()

MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
The maximum length of the name that can be stored in the database. Check the length against this value before calling the setName(String) method to avoid exceptions.


MAX_VALUE_LENGTH

public static final int MAX_VALUE_LENGTH
The maximum length of the value that can be stored in the database. Check the length against this value before calling the setValue(String) method to avoid exceptions.

Method Detail

getById

public static Setting getById(DbControl dc,
                              int id)
                       throws ItemNotFoundException,
                              PermissionDeniedException,
                              BaseException
Get a Setting item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The Setting item
Throws:
ItemNotFoundException - If an item with the specified ID is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

isUsed

public boolean isUsed()
               throws BaseException
Settings are never linked to other items.

Specified by:
isUsed in class BasicItem<D extends SettingData>
Returns:
FALSE
Throws:
BaseException

getName

public String getName()
Get the name of this setting.


setName

public void setName(String name)
             throws PermissionDeniedException,
                    InvalidDataException
Set the name for this setting.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the new name is longer than MAX_NAME_LENGTH

getValue

public String getValue()
Get the value of this setting.


setValue

public void setValue(String value)
              throws PermissionDeniedException,
                     InvalidDataException
Set the value for this setting.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the new value is longer than MAX_VALUE_LENGTH

Last update: 2011-06-23