|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<MimeTypeData> net.sf.basedb.core.MimeType
public class MimeType
This class is used to represent mime types. The mime types are important for file handling, for example when downloading a file on the web.
Field Summary | |
---|---|
static int |
MAX_EXTENSION_LENGTH
The maximum length of the extension variable that can be stored in the database. |
static Item |
TYPE
The type of item represented by this class. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
Constructor Summary | |
---|---|
MimeType(MimeTypeData data)
Creates a new mimetype item from the given data. |
Method Summary | |
---|---|
boolean |
getAutoCompress()
If files of this MIME type should automatically be compressed when they are uploaded to BASE. |
static MimeType |
getByExtension(DbControl dc,
String extension)
Get a MimeType item when you know the file extension. |
static MimeType |
getById(DbControl dc,
int id)
Get a MimeType object when you know the ID. |
String |
getDescription()
Get the description for the item. |
Date |
getEntryDate()
Get the date that the item was registered in the database. |
String |
getExtension()
Get the extension for this MimeType item. |
FileType |
getFileType()
Get the associated FileType item. |
static String |
getMimeType(DbControl dc,
String name,
String defaultMimeType)
Get the MIME type of a given file name or extension. |
String |
getName()
Get the name of the item. |
static MimeType |
getNew(DbControl dc)
Create a new MimeType item. |
static ItemQuery<MimeType> |
getQuery()
Get a query configured to retrieve MIME types. |
Item |
getType()
Get the type of item represented by the object. |
boolean |
isRemoved()
Check if the removed flag is set for this item. |
void |
setAutoCompress(boolean autoCompress)
Set if files of this MIME type should automatically be compressed when they are uploaded to BASE. |
void |
setDescription(String description)
Set the description for the item. |
void |
setExtension(String extension)
Set the extension variable for this MimeType item. |
void |
setFileType(FileType filetype)
Set the filetype of this item. |
void |
setName(String name)
Set the name of the item. |
void |
setRemoved(boolean removed)
Set the removed flag for this item. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, initPermissions, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Field Detail |
---|
public static final Item TYPE
Item.MIMETYPE
,
getType()
public static final int MAX_EXTENSION_LENGTH
setExtension(String)
method to avoid
exceptions.
Constructor Detail |
---|
MimeType(MimeTypeData data)
data
- the data.Method Detail |
---|
public static MimeType getNew(DbControl dc) throws BaseException
MimeType
item.
dc
- The DbControl
which will be used for
permission checking and database access
MimeType
item
BaseException
- If there is an errorpublic static MimeType getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
MimeType
object when you know the ID.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to load
MimeType
item
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 items
BaseException
- If there is another errorpublic static MimeType getByExtension(DbControl dc, String extension) throws PermissionDeniedException, ItemNotFoundException, BaseException
MimeType
item when you know the file extension.
dc
- The DbControl
which will be used for
permission checking and database access.extension
- The extension of the mime type, do not include the
dot in the extension
MimeType
item
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 items
BaseException
- If there is another errorpublic static ItemQuery<MimeType> getQuery() throws BaseException
ItemQuery
object
BaseException
- If the query could not be created.public static String getMimeType(DbControl dc, String name, String defaultMimeType) throws BaseException
dc
- The DbControl to use for database accessname
- The file name or extension, if a dot exists in the name only
the last part will be used for MIME type lookupdefaultMimeType
- A default MIME type to return if none is found
BaseException
- If there is an errorpublic Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public String getName()
Nameable
getName
in interface Nameable
String
with the name of the itempublic void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.
setName
in interface Nameable
name
- The new name for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException
- If the logged in user doesn't
have Permission.DELETE
permission for setting the flag
to TRUE or Permission.WRITE
permission for setting the
flag to FALSEpublic Date getEntryDate()
Registered
getEntryDate
in interface Registered
public void setExtension(String extension) throws PermissionDeniedException, InvalidDataException
MimeType
item.
extension
- A string with the extension of this item. Note that this
extension should be without leading dot.
PermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permission to the mimetype.
InvalidDataException
- If the new value is null or longer than
MAX_EXTENSION_LENGTH
public String getExtension()
MimeType
item.
public FileType getFileType() throws PermissionDeniedException, BaseException
FileType
item.
FileType
item, or null if no type has been specified
PermissionDeniedException
- This exception is thrown if
the logged in user doesn't have read
permission to the item
BaseException
- If there is another errorpublic void setFileType(FileType filetype) throws PermissionDeniedException
filetype
- The new FileType
, or null
PermissionDeniedException
- If the logged in user doesn't have
write permissionpublic boolean getAutoCompress()
Application.autoCompressionEnabled()
.
public void setAutoCompress(boolean autoCompress) throws PermissionDeniedException
Application.autoCompressionEnabled()
.
autoCompress
- TRUE to enable auto-compression
PermissionDeniedException
- If the logged in user doesn't have
write permission
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |