net.sourceforge.atunes.kernel.handlers
Class RepositoryHandler

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

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

The Class RepositoryHandler.


Nested Class Summary
static class RepositoryHandler.SortType
          The Enum SortType.
 
Field Summary
static java.lang.String INDEX_FIELD_ALBUM
          The Constant INDEX_FIELD_ALBUM.
static java.lang.String INDEX_FIELD_ALBUM_ARTIST
          The Constant INDEX_FIELD_ALBUM_ARTIST.
static java.lang.String INDEX_FIELD_ARTIST
          The Constant INDEX_FIELD_ARTIST.
static java.lang.String INDEX_FIELD_BITRATE
          The Constant INDEX_FIELD_BITRATE.
static java.lang.String INDEX_FIELD_COMPOSER
          The Constant INDEX_FIELD_COMPOSER.
static java.lang.String INDEX_FIELD_DURATION
          The Constant INDEX_FIELD_DURATION.
static java.lang.String INDEX_FIELD_FILENAME
          The Constant INDEX_FIELD_FILENAME.
static java.lang.String INDEX_FIELD_FREQUENCY
          The Constant INDEX_FIELD_FREQUENCY.
static java.lang.String INDEX_FIELD_GENRE
          The Constant INDEX_FIELD_GENRE.
static java.lang.String INDEX_FIELD_LYRICS
          The Constant INDEX_FIELD_LYRICS.
static java.lang.String INDEX_FIELD_SCORE
          The Constant INDEX_FIELD_STARS.
static java.lang.String INDEX_FIELD_TITLE
          The Constant INDEX_FIELD_TITLE.
static java.lang.String INDEX_FIELD_TRACK_NUMBER
          The Constant INDEX_FIELD_NUMBER.
static java.lang.String INDEX_FIELD_URL
          The Constant INDEX_FIELD_URL.
static java.lang.String INDEX_FIELD_YEAR
          The Constant INDEX_FIELD_YEAR.
 
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 finish()
          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.
 Document getDocumentForElement(AudioObject audioObject)
          Builds a Lucene Document for a given AudioObject.
 java.util.List<AudioObject> getElementsToIndex()
          Returns elements to index.
 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.String getPathToIndex()
          Returns path to index.
 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.List<java.lang.String> getSearchableAttributes()
          Returns a list of attributes that can be used in queries.
 java.lang.String getSearchableObjectName()
          Returns string representation of this searchable object.
 java.util.List<SearchResult> getSearchResult(Hits hits)
          Returns result from hits.
 SearchResultTableModel getSearchResultsTableModel(java.util.List<SearchResult> results)
          Returns a table model to show search results.
 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
 

Field Detail

INDEX_FIELD_TITLE

public static final java.lang.String INDEX_FIELD_TITLE
The Constant INDEX_FIELD_TITLE.

See Also:
Constant Field Values

INDEX_FIELD_TRACK_NUMBER

public static final java.lang.String INDEX_FIELD_TRACK_NUMBER
The Constant INDEX_FIELD_NUMBER.

See Also:
Constant Field Values

INDEX_FIELD_ARTIST

public static final java.lang.String INDEX_FIELD_ARTIST
The Constant INDEX_FIELD_ARTIST.

See Also:
Constant Field Values

INDEX_FIELD_ALBUM_ARTIST

public static final java.lang.String INDEX_FIELD_ALBUM_ARTIST
The Constant INDEX_FIELD_ALBUM_ARTIST.

See Also:
Constant Field Values

INDEX_FIELD_ALBUM

public static final java.lang.String INDEX_FIELD_ALBUM
The Constant INDEX_FIELD_ALBUM.

See Also:
Constant Field Values

INDEX_FIELD_COMPOSER

public static final java.lang.String INDEX_FIELD_COMPOSER
The Constant INDEX_FIELD_COMPOSER.

See Also:
Constant Field Values

INDEX_FIELD_YEAR

public static final java.lang.String INDEX_FIELD_YEAR
The Constant INDEX_FIELD_YEAR.

See Also:
Constant Field Values

INDEX_FIELD_GENRE

public static final java.lang.String INDEX_FIELD_GENRE
The Constant INDEX_FIELD_GENRE.

See Also:
Constant Field Values

INDEX_FIELD_DURATION

public static final java.lang.String INDEX_FIELD_DURATION
The Constant INDEX_FIELD_DURATION.

See Also:
Constant Field Values

INDEX_FIELD_BITRATE

public static final java.lang.String INDEX_FIELD_BITRATE
The Constant INDEX_FIELD_BITRATE.

See Also:
Constant Field Values

INDEX_FIELD_FREQUENCY

public static final java.lang.String INDEX_FIELD_FREQUENCY
The Constant INDEX_FIELD_FREQUENCY.

See Also:
Constant Field Values

INDEX_FIELD_SCORE

public static final java.lang.String INDEX_FIELD_SCORE
The Constant INDEX_FIELD_STARS.

See Also:
Constant Field Values

INDEX_FIELD_LYRICS

public static final java.lang.String INDEX_FIELD_LYRICS
The Constant INDEX_FIELD_LYRICS.

See Also:
Constant Field Values

INDEX_FIELD_FILENAME

public static final java.lang.String INDEX_FIELD_FILENAME
The Constant INDEX_FIELD_FILENAME.

See Also:
Constant Field Values

INDEX_FIELD_URL

public static final java.lang.String INDEX_FIELD_URL
The Constant INDEX_FIELD_URL.

See Also:
Constant Field Values
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

finish

public void finish()
Finish.


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

getSearchableAttributes

public java.util.List<java.lang.String> getSearchableAttributes()
Description copied from interface: SearchableObject
Returns a list of attributes that can be used in queries.

Specified by:
getSearchableAttributes in interface SearchableObject
Returns:
the searchable attributes

getSearchableObjectName

public java.lang.String getSearchableObjectName()
Description copied from interface: SearchableObject
Returns string representation of this searchable object.

Specified by:
getSearchableObjectName in interface SearchableObject
Returns:
the searchable object name

getPathToIndex

public java.lang.String getPathToIndex()
Description copied from interface: SearchableObject
Returns path to index.

Specified by:
getPathToIndex in interface SearchableObject
Returns:
the path to index

getSearchResult

public java.util.List<SearchResult> getSearchResult(Hits hits)
                                             throws CorruptIndexException,
                                                    java.io.IOException
Description copied from interface: SearchableObject
Returns result from hits.

Specified by:
getSearchResult in interface SearchableObject
Parameters:
hits - the hits
Returns:
the search result
Throws:
CorruptIndexException - the corrupt index exception
java.io.IOException - Signals that an I/O exception has occurred.

getElementsToIndex

public java.util.List<AudioObject> getElementsToIndex()
Description copied from interface: SearchableObject
Returns elements to index.

Specified by:
getElementsToIndex in interface SearchableObject
Returns:
the elements to index

getDocumentForElement

public Document getDocumentForElement(AudioObject audioObject)
Description copied from interface: SearchableObject
Builds a Lucene Document for a given AudioObject.

Specified by:
getDocumentForElement in interface SearchableObject
Parameters:
audioObject - the audio object
Returns:
the document for element

getSearchResultsTableModel

public SearchResultTableModel getSearchResultsTableModel(java.util.List<SearchResult> results)
Description copied from interface: SearchableObject
Returns a table model to show search results.

Specified by:
getSearchResultsTableModel in interface SearchableObject
Parameters:
results - the results
Returns:
the search results table model


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