cbr.service
Class ResourceStoreDelegate

java.lang.Object
  extended bycbr.service.ResourceStoreDelegate
All Implemented Interfaces:
StoreDelegate

public class ResourceStoreDelegate
extends Object
implements StoreDelegate

This delegate handles thumbnails on behalf of the PicsStore. It cuts thumbnails out of the picture entries when entries are inserted into an index, and pastes them back in when entries are retrieved. Additionally, a delegate can be instructed to delete thumbnails e. g. when entries are deleted from an index.

This delegate manages thumbnails in a Resource. Thumbnails are saved to this resource when cut() is called. The names of thumbnails are normalized as follows: each slash ('/') in the name is replaced with 'X', and each dot ('.') is replaced with a 'Y'. Each thumbnail is stored in a subfolder whose name is the name of the host in the thumbnail's PictureEntry.

Version:
"$Id: ResourceStoreDelegate.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth

Field Summary
private  Resource store_
          The Resource in which thumbnails are stored.
 
Constructor Summary
ResourceStoreDelegate(Resource store)
          Creates an instance that stores thumbnails to the given Resource..
 
Method Summary
 void cut(PictureEntry entry)
          Deletes the thumbnail from the given entry.
 void delete(PictureEntry entry)
          Does nothing.
private  String getHost(String url)
          Extracts the host portion of an URL string.
private  String normalize(PictureEntry entry)
          Normalizes the name.
 void paste(PictureEntry entry)
          Retrieves the thumbnail with the name found in the given entry from the Resource of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store_

private Resource store_
The Resource in which thumbnails are stored.

Constructor Detail

ResourceStoreDelegate

public ResourceStoreDelegate(Resource store)
Creates an instance that stores thumbnails to the given Resource..

Parameters:
store - The Resource in which thumbnails are stored.
Method Detail

cut

public void cut(PictureEntry entry)
         throws IOException
Deletes the thumbnail from the given entry. The thumbnail is recreated later by means of a PicsSource.

Specified by:
cut in interface StoreDelegate
Parameters:
entry - The entry from which the thumbnail is removed and stored away.
Throws:
IOException - if an I/O error occurs.

paste

public void paste(PictureEntry entry)
           throws IOException
Retrieves the thumbnail with the name found in the given entry from the Resource of this instance. The Resource must be based on a storage for which input streams support method available() .

Specified by:
paste in interface StoreDelegate
Parameters:
entry - The picture entry whose thumbnail shall be restored.
Throws:
IOException - if an I/O error occurs.

delete

public void delete(PictureEntry entry)
            throws IOException
Does nothing.

Specified by:
delete in interface StoreDelegate
Parameters:
entry - The picture entry whose thumbnail shall be deleted.
Throws:
IOException - if an I/O error occurs.

getHost

private String getHost(String url)
Extracts the host portion of an URL string.

Returns:
The host portion.

normalize

private String normalize(PictureEntry entry)
Normalizes the name.

Parameters:
entry - The entry.
Returns:
The normalized name for the thumbnail.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.