org.varienaja.util.coverart
Class CoverArtManager

java.lang.Object
  extended by org.varienaja.util.coverart.CoverArtManager

public class CoverArtManager
extends java.lang.Object

This class manages a store of cover art pictures in different sizes. It hides the details of the file system handling from the users of the storage. The class uses long-typed keys to identify the different covers.

Version:
$Id: CoverArtManager.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
Author:
Hans Drexler

Constructor Summary
CoverArtManager()
           
 
Method Summary
static void add(long id, java.io.InputStream in)
          Add cover art picture from the InputStream to the storage.
static boolean contains(long id, int size)
          Tests the existence of a cover art picture for the specified id and size.
static java.io.File get(long id, int size)
          Returns the file containing the cover art of the specified id and size.
static void purge(long id)
          Deletes all entries for this id.
static void scale(long id, int size)
          Scales the original image of the specified id to the specified size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoverArtManager

public CoverArtManager()
Method Detail

add

public static void add(long id,
                       java.io.InputStream in)
                throws java.io.IOException
Add cover art picture from the InputStream to the storage. Use the specified size. This will overwrite a previous picture with the same id and size.

Parameters:
id - The id of the added cover.
in - The input stream containing the picture.
size - The size of the picture.
Throws:
java.io.IOException - An error occured when reading the input stream or during writing the picture.

get

public static java.io.File get(long id,
                               int size)
Returns the file containing the cover art of the specified id and size.

Parameters:
id - The requested cover art id.
size - The requested cover art size.
Returns:
A file containing the cover art of the requested id and size. This method allways returns a File object (possibly to a non-existent file) and never returns NULL.

purge

public static void purge(long id)
Deletes all entries for this id.

Parameters:
id - The id to delete.

contains

public static boolean contains(long id,
                               int size)
Tests the existence of a cover art picture for the specified id and size.

Parameters:
id - The id of the cover art.
size - The size of the cover art.
Returns:
True if the storage contains a picture of the specified id and size, otherwise false.

scale

public static void scale(long id,
                         int size)
                  throws java.io.FileNotFoundException
Scales the original image of the specified id to the specified size. Does nothing if the original version of the specified id is not present.

Parameters:
id - The cover art id.
size - The requested picture size to create.
Throws:
java.io.FileNotFoundException


Copyright © 2010 A.J.V.. All Rights Reserved.