Package de.xima.fc.file
Class GenericFileDao
- java.lang.Object
 - 
- de.xima.fc.file.GenericFileDao
 
 
- 
- All Implemented Interfaces:
 IGenericFileDao
public class GenericFileDao extends Object implements IGenericFileDao
 
- 
- 
Constructor Summary
Constructors Constructor Description GenericFileDao() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>>
byte[]getFileData(IEntityContext ec, E entity, String fileKey)Returns the file data of a file belonging to the given entity with the given file key.<E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
byte[]getFileData(IEntityContext ec, Class<T> clazz, long id)Returns the file data of a file entity.<E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
byte[]getFileData(IEntityContext ec, T entity)Returns the file data of a file entity.<D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>>
DgetFileDataEntity(IEntityContext ec, E entity, String fileKey)Returns the file data entity of a file belonging to the given entity with the given file key.<E extends IFileDataEntity<?>,T extends IFileEntity<?,E>>
EgetFileDataEntity(IEntityContext ec, T entity)Get the file data entity for a given file entity.<T extends IFileEntity<?,?>>
byte[]getFileEntityData(IEntityContext ec, T fileEntity)Gets the data of the given file entity as an in-memory byte array.<T extends IFileEntity<?,?>>
InputStreamgetFileEntityStream(IEntityContext ec, T entity)Gets the data of the given file entity as an input stream.<D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>>
InputStreamgetFileStream(IEntityContext ec, E entity, String fileKey)Returns the file data of a file belonging to the given entity with the given file key, as an input stream.<E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
InputStreamgetFileStream(IEntityContext ec, T entity)<E extends IFileDataEntity<?>,T extends IFileEntity<?,E>>
TupdateFileData(IEntityContext ec, T entity, byte[] data)Replaces the data of the given file entity with the new data. 
 - 
 
- 
- 
Method Detail
- 
getFileData
public <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> byte[] getFileData(IEntityContext ec, Class<T> clazz, long id)
Description copied from interface:IGenericFileDaoReturns the file data of a file entity.Use with care! As the name suggests, this holds the entire file data in memory. Prefer
using an input streaminstead.- Specified by:
 getFileDatain interfaceIGenericFileDao- Type Parameters:
 E- Type of the entity with the file data.T- Type of the entity with the file meta data.- Parameters:
 ec- Entity context for database transactions.clazz- Type of the file entity with the file meta data.id- ID of the file entity with the file meta data.- Returns:
 - The file content as a byte array, or 
nullwhen no file content was found. 
 
- 
getFileData
public <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> byte[] getFileData(IEntityContext ec, T entity)
Description copied from interface:IGenericFileDaoReturns the file data of a file entity.Use with care! As the name suggests, this holds the entire file data in memory. Prefer
using an input streaminstead.- Specified by:
 getFileDatain interfaceIGenericFileDao- Type Parameters:
 E- Type of the entity with the file data.T- Type of the entity with the file meta data.- Parameters:
 ec- Entity context for database transactions.entity- File entity with the file meta data.- Returns:
 - The file content as a byte array.
 
 
- 
getFileData
public <D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>> byte[] getFileData(IEntityContext ec, E entity, String fileKey)
Description copied from interface:IGenericFileDaoReturns the file data of a file belonging to the given entity with the given file key.Use with care! As the name suggests, this holds the entire file data in memory. Prefer
using an input streaminstead.- Specified by:
 getFileDatain interfaceIGenericFileDao- Type Parameters:
 D- file data entity typeF- file entity typeE- file map providing base entity type- Parameters:
 ec- entity context for database transactions.entity- that owns the filefileKey- Key identifying the the file to retrieve.- Returns:
 - The file data as a byte array.
 
 
- 
getFileStream
public <D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>> InputStream getFileStream(IEntityContext ec, E entity, String fileKey)
Description copied from interface:IGenericFileDaoReturns the file data of a file belonging to the given entity with the given file key, as an input stream.- Specified by:
 getFileStreamin interfaceIGenericFileDao- Type Parameters:
 D- file data entity typeF- file entity typeE- file map providing base entity type- Parameters:
 ec- entity context for database transactions.entity- that owns the filefileKey- Key identifying the the file to retrieve.- Returns:
 - The file data as an input stream.
 
 
- 
getFileEntityData
public <T extends IFileEntity<?,?>> byte[] getFileEntityData(IEntityContext ec, T fileEntity)
Description copied from interface:IGenericFileDaoGets the data of the given file entity as an in-memory byte array.Use with care! As the name suggests, this holds the entire file data in memory. Prefer
using an input streaminstead.- Specified by:
 getFileEntityDatain interfaceIGenericFileDao- Type Parameters:
 T- Type of the file entity with the data.- Parameters:
 ec- Entity context for database transactions.fileEntity- File entity with the data.- Returns:
 - The data as a byte array, or 
nullif no data exists. 
 
- 
updateFileData
public <E extends IFileDataEntity<?>,T extends IFileEntity<?,E>> T updateFileData(IEntityContext ec, T entity, byte[] data)
Description copied from interface:IGenericFileDaoReplaces the data of the given file entity with the new data.- Specified by:
 updateFileDatain interfaceIGenericFileDao- Type Parameters:
 E- Type of the entity with the file data.T- Type of the entity with the file meta data.- Parameters:
 ec- Entity context for database transactions.entity- File entity with the file meta data.data- New data to set.- Returns:
 - The updated file entity.
 
 
- 
getFileDataEntity
public <E extends IFileDataEntity<?>,T extends IFileEntity<?,E>> E getFileDataEntity(IEntityContext ec, T entity)
Description copied from interface:IGenericFileDaoGet the file data entity for a given file entity. The entity is read from the database if it is detached.- Specified by:
 getFileDataEntityin interfaceIGenericFileDao- Type Parameters:
 E- Type of the entity with the file data.T- Type of the entity with the file meta data.- Parameters:
 ec- Entity context for database transactions.entity- File entity with the file meta data.- Returns:
 - The file data entity for the given file entity.
 
 
- 
getFileDataEntity
public <D extends IFileDataEntity<F>,F extends IKeyDependentFileEntity<E,D>,E extends IFileMapProviding<F,D>> D getFileDataEntity(IEntityContext ec, E entity, String fileKey)
Description copied from interface:IGenericFileDaoReturns the file data entity of a file belonging to the given entity with the given file key.- Specified by:
 getFileDataEntityin interfaceIGenericFileDao- Type Parameters:
 D- file data entity typeF- file entity typeE- file map providing base entity type- Parameters:
 ec- Entity context for database transactions.entity- that owns the filefileKey- key identifying the the file entity- Returns:
 - file data entity containing the data of the request file.
 
 
- 
getFileStream
public <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>> InputStream getFileStream(IEntityContext ec, T entity)
- Specified by:
 getFileStreamin interfaceIGenericFileDao- Type Parameters:
 E- Type of the entity with the file data.T- Type of the entity with the file meta data.- Parameters:
 ec- Entity context for database transactions.entity- File entity with the file meta data.- Returns:
 - The data of the file entity as an input stream, or 
nullwhen no data exists. 
 
- 
getFileEntityStream
public <T extends IFileEntity<?,?>> InputStream getFileEntityStream(IEntityContext ec, T entity)
Description copied from interface:IGenericFileDaoGets the data of the given file entity as an input stream.- Specified by:
 getFileEntityStreamin interfaceIGenericFileDao- Parameters:
 ec- Entity context for database transactions.entity- File entity with the data.- Returns:
 - The data as an input stream, or 
nullif no data exists. 
 
 - 
 
 -