net.sourceforge.atunes.kernel.handlers
Class RepositoryHandler

java.lang.Object
  extended by net.sourceforge.atunes.kernel.handlers.RepositoryHandler
All Implemented Interfaces:
ApplicationFinishListener, LoaderListener

public class RepositoryHandler
extends java.lang.Object
implements LoaderListener, ApplicationFinishListener

The Class RepositoryHandler.


Nested Class Summary
static class RepositoryHandler.SortType
          The Enum SortType.
 
Method Summary
 void addAndRefresh(java.util.List<java.io.File> files, java.io.File folder)
          Adds the and refresh.
 void addExternalPictureForAlbum(java.lang.String artistName, java.lang.String albumName, java.io.File picture)
          Adds the external picture for album.
 void applicationFinish()
          Finish.
 java.lang.Runnable getAfterStartActionsRunnable()
          Returns a runnable object to be executed after application start
 java.util.Map<java.lang.String,java.lang.Integer> getAlbumMostPlayed()
          Gets the album most played.
 java.util.List<Album> getAlbums()
          Gets the albums.
 java.lang.Integer getAlbumTimesPlayed(AudioFile song)
          Gets the album times played.
 java.util.Map<java.lang.String,Artist> getArtistAndAlbumStructure()
          Gets the artist and album structure.
 java.util.Map<java.lang.String,java.lang.Integer> getArtistMostPlayed()
          Gets the artist most played.
 java.util.List<Artist> getArtists()
          Gets the artists.
 java.lang.Integer getArtistTimesPlayed(AudioFile song)
          Gets the artist times played.
 int getDifferentSongsPlayed()
          Gets the different songs played.
 AudioFile getFileIfLoaded(java.lang.String fileName)
          Gets the file if loaded.
 java.util.Map<java.lang.String,Folder> getFolderStructure()
          Gets the folder structure.
 java.util.Map<java.lang.String,Genre> getGenreStructure()
          Gets the genre structure.
static RepositoryHandler getInstance()
          Gets the single instance of RepositoryHandler.
 java.util.List<Album> getMostPlayedAlbums(int n)
          Gets the most played albums.
 java.util.List<java.lang.Object[]> getMostPlayedAlbumsInRanking(int n)
          Gets the most played albums in ranking.
 java.util.List<Artist> getMostPlayedArtists(int n)
          Gets the most played artists.
 java.util.List<java.lang.Object[]> getMostPlayedArtistsInRanking(int n)
          Gets the most played artists in ranking.
 java.util.List<AudioFile> getMostPlayedSongs(int n)
          Gets the most played songs.
 java.util.List<java.lang.Object[]> getMostPlayedSongsInRanking(int n)
          Gets the most played songs in ranking.
 java.lang.String getPathForNewSongsRipped()
          Gets the path for new songs ripped.
 java.lang.Runnable getReadRepositoryFromCacheRunnable()
          Process to read repository from cache.
 Repository getRepository()
          Gets the repository.
 java.io.File getRepositoryFolderContainingFile(AudioFile file)
          Returns repository root folder that contains file.
 java.lang.String getRepositoryPath()
          Gets the repository path.
 long getRepositoryTotalSize()
          Gets the repository total size.
 java.util.Map<AudioFile,java.lang.Integer> getSongMostPlayed()
          Gets the song most played.
 java.util.List<AudioFile> getSongs()
          Gets the songs.
 java.util.List<AudioFile> getSongsForAlbums(java.util.Map<java.lang.String,Album> albums)
          Gets the songs for albums.
 java.util.List<AudioFile> getSongsForArtists(java.util.Map<java.lang.String,Artist> artists)
          Gets the songs for artists.
 java.lang.String getSongsPlayed()
          Gets the songs played.
 SongStats getSongStatistics(AudioFile song)
          Gets the song statistics.
 int getTotalSongsPlayed()
          Gets the total songs played.
 java.util.List<AudioFile> getUnplayedSongs()
          Gets the unplayed songs.
 boolean isRepository(java.io.File folder)
          Returns true if folder is in repository.
 void notifyCancel()
          Notify cancel.
 void notifyCurrentPath(java.lang.String dir)
          Notify current path.
 void notifyFileLoaded()
          Notify file loaded.
 void notifyFilesInRepository(int totalFiles)
          Notify files in repository.
 void notifyFinishRead(RepositoryLoader loader)
          Notify finish read.
 void notifyFinishRefresh(RepositoryLoader loader)
          Notify finish refresh.
 void notifyRemainingTime(long millis)
          Notify remaining time.
 void refreshFile(AudioFile file)
          Refresh file.
 void refreshRepository()
          Refresh repository.
 void removePhysically(java.util.List<AudioFile> filesToRemove)
          Removes a list of files permanently from disk.
 boolean repositoryIsNull()
          Repository is null.
 boolean retrieve(java.util.List<java.io.File> folders)
          Retrieve.
 boolean selectRepository()
          Select repository.
 boolean selectRepository(boolean repositoryNotFound)
          Select repository.
 void setRepository()
          Sets the repository.
 void setSongStatistics(AudioFile song)
          Sets the song statistics.
 java.util.List<AudioObject> sort(java.util.List<? extends AudioObject> songs)
          Sort.
 java.util.List<AudioObject> sort(java.util.List<? extends AudioObject> songs, RepositoryHandler.SortType type)
          Sort.
 void transferStatsFrom(Repository newRepository, Repository oldRepository)
          Gets stats from a repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RepositoryHandler getInstance()
Gets the single instance of RepositoryHandler.

Returns:
single instance of RepositoryHandler

getAfterStartActionsRunnable

public java.lang.Runnable getAfterStartActionsRunnable()
Returns a runnable object to be executed after application start


addAndRefresh

public void addAndRefresh(java.util.List<java.io.File> files,
                          java.io.File folder)
Adds the and refresh.

Parameters:
files - the files
folder - the folder

addExternalPictureForAlbum

public void addExternalPictureForAlbum(java.lang.String artistName,
                                       java.lang.String albumName,
                                       java.io.File picture)
Adds the external picture for album.

Parameters:
artistName - the artist name
albumName - the album name
picture - the picture

applicationFinish

public void applicationFinish()
Finish.

Specified by:
applicationFinish in interface ApplicationFinishListener

getAlbumMostPlayed

public java.util.Map<java.lang.String,java.lang.Integer> getAlbumMostPlayed()
Gets the album most played.

Returns:
the album most played

getAlbums

public java.util.List<Album> getAlbums()
Gets the albums.

Returns:
the albums

getAlbumTimesPlayed

public java.lang.Integer getAlbumTimesPlayed(AudioFile song)
Gets the album times played.

Parameters:
song - the song
Returns:
the album times played

getArtistAndAlbumStructure

public java.util.Map<java.lang.String,Artist> getArtistAndAlbumStructure()
Gets the artist and album structure.

Returns:
the artist and album structure

getArtistMostPlayed

public java.util.Map<java.lang.String,java.lang.Integer> getArtistMostPlayed()
Gets the artist most played.

Returns:
the artist most played

getArtists

public java.util.List<Artist> getArtists()
Gets the artists.

Returns:
the artists

getArtistTimesPlayed

public java.lang.Integer getArtistTimesPlayed(AudioFile song)
Gets the artist times played.

Parameters:
song - the song
Returns:
the artist times played

getDifferentSongsPlayed

public int getDifferentSongsPlayed()
Gets the different songs played.

Returns:
the different songs played

getFileIfLoaded

public AudioFile getFileIfLoaded(java.lang.String fileName)
Gets the file if loaded.

Parameters:
fileName - the file name
Returns:
the file if loaded

getFolderStructure

public java.util.Map<java.lang.String,Folder> getFolderStructure()
Gets the folder structure.

Returns:
the folder structure

getGenreStructure

public java.util.Map<java.lang.String,Genre> getGenreStructure()
Gets the genre structure.

Returns:
the genre structure

getMostPlayedAlbums

public java.util.List<Album> getMostPlayedAlbums(int n)
Gets the most played albums.

Parameters:
n - the n
Returns:
the most played albums

getMostPlayedAlbumsInRanking

public java.util.List<java.lang.Object[]> getMostPlayedAlbumsInRanking(int n)
Gets the most played albums in ranking.

Parameters:
n - the n
Returns:
the most played albums in ranking

getMostPlayedArtists

public java.util.List<Artist> getMostPlayedArtists(int n)
Gets the most played artists.

Parameters:
n - the n
Returns:
the most played artists

getMostPlayedArtistsInRanking

public java.util.List<java.lang.Object[]> getMostPlayedArtistsInRanking(int n)
Gets the most played artists in ranking.

Parameters:
n - the n
Returns:
the most played artists in ranking

getMostPlayedSongs

public java.util.List<AudioFile> getMostPlayedSongs(int n)
Gets the most played songs.

Parameters:
n - the n
Returns:
the most played songs

getMostPlayedSongsInRanking

public java.util.List<java.lang.Object[]> getMostPlayedSongsInRanking(int n)
Gets the most played songs in ranking.

Parameters:
n - the n
Returns:
the most played songs in ranking

getPathForNewSongsRipped

public java.lang.String getPathForNewSongsRipped()
Gets the path for new songs ripped.

Returns:
the path for new songs ripped

getRepository

public Repository getRepository()
Gets the repository.

Returns:
the repository

getRepositoryFolderContainingFile

public java.io.File getRepositoryFolderContainingFile(AudioFile file)
Returns repository root folder that contains file.

Parameters:
file - the file
Returns:
the repository folder containing file

getRepositoryPath

public java.lang.String getRepositoryPath()
Gets the repository path.

Returns:
the repository path

getRepositoryTotalSize

public long getRepositoryTotalSize()
Gets the repository total size.

Returns:
the repository total size

getSongMostPlayed

public java.util.Map<AudioFile,java.lang.Integer> getSongMostPlayed()
Gets the song most played.

Returns:
the song most played

getSongs

public java.util.List<AudioFile> getSongs()
Gets the songs.

Returns:
the songs

getSongsForAlbums

public java.util.List<AudioFile> getSongsForAlbums(java.util.Map<java.lang.String,Album> albums)
Gets the songs for albums.

Parameters:
albums - the albums
Returns:
the songs for albums

getSongsForArtists

public java.util.List<AudioFile> getSongsForArtists(java.util.Map<java.lang.String,Artist> artists)
Gets the songs for artists.

Parameters:
artists - the artists
Returns:
the songs for artists

getSongsPlayed

public java.lang.String getSongsPlayed()
Gets the songs played.

Returns:
the songs played

getSongStatistics

public SongStats getSongStatistics(AudioFile song)
Gets the song statistics.

Parameters:
song - the song
Returns:
the song statistics

getTotalSongsPlayed

public int getTotalSongsPlayed()
Gets the total songs played.

Returns:
the total songs played

getUnplayedSongs

public java.util.List<AudioFile> getUnplayedSongs()
Gets the unplayed songs.

Returns:
the unplayed songs

isRepository

public boolean isRepository(java.io.File folder)
Returns true if folder is in repository.

Parameters:
folder - the folder
Returns:
true, if checks if is repository

notifyCancel

public void notifyCancel()
Notify cancel.


notifyCurrentPath

public void notifyCurrentPath(java.lang.String dir)
Description copied from interface: LoaderListener
Notify current path.

Specified by:
notifyCurrentPath in interface LoaderListener
Parameters:
dir - the path

notifyFileLoaded

public void notifyFileLoaded()
Description copied from interface: LoaderListener
Notify file loaded.

Specified by:
notifyFileLoaded in interface LoaderListener

notifyFilesInRepository

public void notifyFilesInRepository(int totalFiles)
Description copied from interface: LoaderListener
Notify files in repository.

Specified by:
notifyFilesInRepository in interface LoaderListener
Parameters:
totalFiles - the files

notifyFinishRead

public void notifyFinishRead(RepositoryLoader loader)
Description copied from interface: LoaderListener
Notify finish read.

Specified by:
notifyFinishRead in interface LoaderListener
Parameters:
loader - the loader

notifyFinishRefresh

public void notifyFinishRefresh(RepositoryLoader loader)
Description copied from interface: LoaderListener
Notify finish refresh.

Specified by:
notifyFinishRefresh in interface LoaderListener
Parameters:
loader - the loader

notifyRemainingTime

public void notifyRemainingTime(long millis)
Description copied from interface: LoaderListener
Notify remaining time.

Specified by:
notifyRemainingTime in interface LoaderListener
Parameters:
millis - the time

getReadRepositoryFromCacheRunnable

public java.lang.Runnable getReadRepositoryFromCacheRunnable()
Process to read repository from cache.

Returns:
the read repository from cache runnable

setRepository

public void setRepository()
Sets the repository.


refreshFile

public void refreshFile(AudioFile file)
Refresh file.

Parameters:
file - the file

refreshRepository

public void refreshRepository()
Refresh repository.


removePhysically

public void removePhysically(java.util.List<AudioFile> filesToRemove)
Removes a list of files permanently from disk.

Parameters:
filesToRemove - Files that should be removed

repositoryIsNull

public boolean repositoryIsNull()
Repository is null.

Returns:
true, if successful

retrieve

public boolean retrieve(java.util.List<java.io.File> folders)
Retrieve.

Parameters:
folders - the folders
Returns:
true, if successful

selectRepository

public boolean selectRepository()
Select repository.

Returns:
true, if successful

selectRepository

public boolean selectRepository(boolean repositoryNotFound)
Select repository.

Parameters:
repositoryNotFound - the repository not found
Returns:
true, if successful

setSongStatistics

public void setSongStatistics(AudioFile song)
Sets the song statistics.

Parameters:
song - the new song statistics

sort

public java.util.List<AudioObject> sort(java.util.List<? extends AudioObject> songs)
Sort.

Parameters:
songs - the songs
Returns:
the list< audio object>

sort

public java.util.List<AudioObject> sort(java.util.List<? extends AudioObject> songs,
                                        RepositoryHandler.SortType type)
Sort.

Parameters:
songs - the songs
type - the type
Returns:
the list< audio object>

transferStatsFrom

public void transferStatsFrom(Repository newRepository,
                              Repository oldRepository)
Gets stats from a repository.

Parameters:
oldRepository - the old repository
newRepository - the new repository


Copyright © 2006-2008 The aTunes Team. All Rights Reserved.