Package com.tagtraum.beatunes.library
Class PlayListFacade
- java.lang.Object
-
- com.tagtraum.beatunes.library.PlayListFacade
-
- All Implemented Interfaces:
PlayList,SyncTempoAware,ListModel
- Direct Known Subclasses:
FileSystemPlayList,ITunesPlayList
public abstract class PlayListFacade extends Object implements PlayList
PlayListFacade.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tagtraum.audiokern.PlayList
PlayList.Kind, PlayList.SortDirection, PlayList.SubstringFilterProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorServiceexecutorprotected MediaLibrarymusicLibraryprotected PlayListplayList
-
Constructor Summary
Constructors Modifier Constructor Description protectedPlayListFacade(PlayList playList, MediaLibrary musicLibrary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListDataListener(ListDataListener listener)voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener)Add a listener.voidaddPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)Add a listener for a specific property.booleancanAddItem()Indicates whether we can add items to this playlist.booleancanInsertItem()Indicates whether we can insert items into this playlist.booleancontains(Long id)intcountSongs(Collection<? extends SongFilter> filters)Returns song count from this playlist, filtered with the given filters.booleanequals(Object obj)int[]filteredIndices(int... unfilteredIndices)Returns the filtered indices (string, order) for the given unfiltered indices.PlayListIterator<AudioSong>filteredListIterator(int startIndex)Creates a dynamically updated iterator for this playlist.List<PlayList>getChildPlayLists()StringgetDescription()PlayList.KindgetDistinguishedKind()Returns the special kind of this playlist.ObjectgetElementAt(int index)longgetFileSize()Get the sum of all file sizes (with filters applied).List<Long>getFilteredSongIds()Returns song ids from this playlist, both sorted and filtered.Iterable<AudioSong>getFilteredSongs()Returns songs from this playlist, both sorted and filtered.intgetGeniusTrackID()LonggetId()This list's id.LonggetIdAt(int index)Returns id of the song at the given index, taking sorting and filtering into account.IndexedId[]getIndexedSongIds()A complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()).AudioSong.LikinggetLiking()StringgetName()LonggetParentId()If this is a sub-folder/playlist, this returns the parent id.PlayListgetParentPlayList()PlayListgetPlayList()Gets thePlayListthis playlist is a facade for.PlayList[]getPlayListPath()Returns path leading to this playlist and ending with it.intgetSize()StringgetSmartCriteria()StringgetSmartInfo()AudioSonggetSong(int index)Returns song from the given index, taking sorting and filtering into account.List<Long>getSongIds()Returns song ids from this playlist, neither sorted not filtered.List<Long>getSongIds(Set<? extends SongFilter> filters)Returns song ids from this playlist, filtered with the given filters.Iterable<AudioSong>getSongs()Returns songs from this playlist, neither sorted nor filtered.List<AudioSong>getSongs(Collection<? extends SongFilter> filters, int limit)Returns songs from this playlist, filtered with the given filters.Iterable<AudioSong>getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)Returns songs from this playlist, sorted by the given property.Iterable<AudioSong>getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)Returns songs from this playlist, sorted by the given property.StringgetSortColumnProperty()Returns the name of the single property the playlist is sorted by.PlayList.SortDirectiongetSortDirection()Return sort direction.String[]getSortProperties()Actual sort properties, used inORDER BYHQL/SQL clauses.StringgetSortProperty(int index)Actual sort property, used inORDER BYSQL clauses.SpecialPlayListInfogetSpecialPlayListInfo()LonggetSpecialPlayListInfoId()StringgetSubstringFilter()Current substring filter.PlayList.SubstringFilterPropertygetSubstringFilterProperty()Current property to filter.com.tagtraum.audiokern.bpm.TempogetSyncTempo()When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo.longgetTotalTime()Get time with filters applied.intgetUnfilteredSize()Unfiltered number of songs in playlist.longgetUnfilteredTime()Get time without any filters applied.inthashCode()intindexOf(Long id)Returns the first index of the given song.booleanisAggregateDataAvailable()Indicates whether we currently have valid aggregate (total size, duration, etc.) data.booleanisAllItems()booleanisAudiobooks()booleanisEditable()Is this playlist editable? Only playlists created by users are editable.booleanisFolder()booleanisGeniusPlaylist()booleanisItemsEditable()Are the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.booleanisLibrary()Indicates that this is a library playlist, meaning one of the top level library views (e.g.booleanisMaster()Indicates whether this playlist is a master playlist.booleanisMovies()booleanisMusic()booleanisParentAFolder()booleanisPodcasts()booleanisPurchasedMusic()booleanisSmartPlaylist()booleanisSpecialPlayList()booleanisTvShows()booleanisUserPlaylist()Indicates that the playlist is just a regular user playlist.booleanisVideos()iTunes 6 playlist attribute.voidremoveAllSongs()Removes all songs from this playlist.voidremoveListDataListener(ListDataListener listener)voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener)Remove a listener.voidsetSongIds(List<Long> songIds)Removes all songs from this playlist and replaces them with song connected to the given ids.voidsetSortColumnProperty(String property)Sets "visual/semantic" sort property.voidsetSortDirection(PlayList.SortDirection sortDirection)Sort direction.voidsetSortProperties(String... properties)Sets sort properties.voidsetSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)Sets the filter and which property to filter in one swoop.voidsetSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)When set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo.StringtoString()int[]unfilteredIndices(int... indices)Returns the unfiltered indices for the given filtered (string, order) indices.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tagtraum.audiokern.PlayList
addSongIds, addSongIds, addSongs, addSongs, contains, getImplementation, getSongsOrderedBy, indexOf, moveSongs, removeSongs, removeSongs, removeSongs, setAllItems, setAudiobooks, setChildPlayLists, setDescription, setDistinguishedKind, setFolder, setGeniusTrackID, setId, setLiking, setMaster, setMovies, setMusic, setName, setParentId, setParentPlayList, setPodcasts, setPurchasedMusic, setSmartCriteria, setSmartInfo, setSongs, setSpecialPlayListInfo, setTvShows, setVideos
-
-
-
-
Field Detail
-
playList
protected PlayList playList
-
musicLibrary
protected MediaLibrary musicLibrary
-
executor
protected ExecutorService executor
-
-
Constructor Detail
-
PlayListFacade
protected PlayListFacade(PlayList playList, MediaLibrary musicLibrary)
-
-
Method Detail
-
getPlayList
public PlayList getPlayList()
Gets thePlayListthis playlist is a facade for.- Returns:
- wrapped playlist
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayListRemove a listener.- Specified by:
removePropertyChangeListenerin interfacePlayList- Parameters:
propertyChangeListener- listener
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayListAdd a listener.- Specified by:
addPropertyChangeListenerin interfacePlayList- Parameters:
propertyChangeListener- listener
-
addPropertyChangeListener
public void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayListAdd a listener for a specific property.- Specified by:
addPropertyChangeListenerin interfacePlayListpropertyChangeListener- listener
-
getElementAt
public Object getElementAt(int index)
- Specified by:
getElementAtin interfaceListModel
-
addListDataListener
public void addListDataListener(ListDataListener listener)
- Specified by:
addListDataListenerin interfaceListModel
-
removeListDataListener
public void removeListDataListener(ListDataListener listener)
- Specified by:
removeListDataListenerin interfaceListModel
-
getParentId
public Long getParentId()
Description copied from interface:PlayListIf this is a sub-folder/playlist, this returns the parent id.- Specified by:
getParentIdin interfacePlayList- Returns:
- id
-
getSpecialPlayListInfo
public SpecialPlayListInfo getSpecialPlayListInfo()
- Specified by:
getSpecialPlayListInfoin interfacePlayList
-
getSpecialPlayListInfoId
public Long getSpecialPlayListInfoId()
- Specified by:
getSpecialPlayListInfoIdin interfacePlayList
-
getLiking
public AudioSong.Liking getLiking()
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin interfacePlayList
-
isSpecialPlayList
public boolean isSpecialPlayList()
- Specified by:
isSpecialPlayListin interfacePlayList
-
getDistinguishedKind
public PlayList.Kind getDistinguishedKind()
Description copied from interface:PlayListReturns the special kind of this playlist.- Specified by:
getDistinguishedKindin interfacePlayList- Returns:
nullif unknown
-
isAudiobooks
public boolean isAudiobooks()
Description copied from interface:PlayList- Specified by:
isAudiobooksin interfacePlayList
-
isMovies
public boolean isMovies()
Description copied from interface:PlayList
-
isMusic
public boolean isMusic()
Description copied from interface:PlayList
-
isTvShows
public boolean isTvShows()
Description copied from interface:PlayList
-
isPodcasts
public boolean isPodcasts()
Description copied from interface:PlayList- Specified by:
isPodcastsin interfacePlayList
-
getChildPlayLists
public List<PlayList> getChildPlayLists()
- Specified by:
getChildPlayListsin interfacePlayList
-
getParentPlayList
public PlayList getParentPlayList()
- Specified by:
getParentPlayListin interfacePlayList
-
getPlayListPath
public PlayList[] getPlayListPath()
Description copied from interface:PlayListReturns path leading to this playlist and ending with it. I.e., the path has at least the length 1.- Specified by:
getPlayListPathin interfacePlayList- Returns:
- path of playlists
-
isMaster
public boolean isMaster()
Description copied from interface:PlayListIndicates whether this playlist is a master playlist. E.g. the (invisible list) Library is typically the master playlist.- Specified by:
isMasterin interfacePlayList- Returns:
- true or false
- See Also:
PlayList.isLibrary()
-
isLibrary
public boolean isLibrary()
Description copied from interface:PlayListIndicates that this is a library playlist, meaning one of the top level library views (e.g. Music, AudioBooks, etc.).- Specified by:
isLibraryin interfacePlayList- Returns:
- true or false
- See Also:
PlayList.isMaster()
-
getGeniusTrackID
public int getGeniusTrackID()
- Specified by:
getGeniusTrackIDin interfacePlayList
-
isGeniusPlaylist
public boolean isGeniusPlaylist()
- Specified by:
isGeniusPlaylistin interfacePlayList
-
isAllItems
public boolean isAllItems()
- Specified by:
isAllItemsin interfacePlayList
-
getSmartInfo
public String getSmartInfo()
- Specified by:
getSmartInfoin interfacePlayList
-
isSmartPlaylist
public boolean isSmartPlaylist()
- Specified by:
isSmartPlaylistin interfacePlayList
-
getSmartCriteria
public String getSmartCriteria()
- Specified by:
getSmartCriteriain interfacePlayList
-
isVideos
public boolean isVideos()
Description copied from interface:PlayListiTunes 6 playlist attribute.
-
getFilteredSongIds
public List<Long> getFilteredSongIds()
Description copied from interface:PlayListReturns song ids from this playlist, both sorted and filtered.- Specified by:
getFilteredSongIdsin interfacePlayList- Returns:
- song ids
-
getIndexedSongIds
public IndexedId[] getIndexedSongIds()
Description copied from interface:PlayListA complete list of sorted ids along with their natural order indices (viaIndexedId.getIndex()). Natural indices of filtered out objects are flipped:-(index+1)- Specified by:
getIndexedSongIdsin interfacePlayList- Returns:
- a complete list of persistent ids along with their natural indices
-
getSongIds
public List<Long> getSongIds()
Description copied from interface:PlayListReturns song ids from this playlist, neither sorted not filtered.- Specified by:
getSongIdsin interfacePlayList- Returns:
- song ids
-
getSongIds
public List<Long> getSongIds(Set<? extends SongFilter> filters)
Description copied from interface:PlayListReturns song ids from this playlist, filtered with the given filters.- Specified by:
getSongIdsin interfacePlayList- Returns:
- song ids
- See Also:
PlayList.getSongs(Collection, int)
-
getSongs
public Iterable<AudioSong> getSongs()
Description copied from interface:PlayListReturns songs from this playlist, neither sorted nor filtered.
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Description copied from interface:PlayListReturns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedByin interfacePlayList- Parameters:
sortProperty- propertydirection- direction- Returns:
- songs
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Description copied from interface:PlayListReturns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedByin interfacePlayList- Parameters:
sortProperty- propertydirection- directionlimit- max number of songs to return- Returns:
- songs
-
getSongs
public List<AudioSong> getSongs(Collection<? extends SongFilter> filters, int limit)
Description copied from interface:PlayListReturns songs from this playlist, filtered with the given filters.- Specified by:
getSongsin interfacePlayList- Parameters:
filters- filterslimit- limit, -1 for no limit- Returns:
- songs
- See Also:
PlayList.getSongIds(Set)
-
getFilteredSongs
public Iterable<AudioSong> getFilteredSongs()
Description copied from interface:PlayListReturns songs from this playlist, both sorted and filtered.- Specified by:
getFilteredSongsin interfacePlayList- Returns:
- songs
-
filteredListIterator
public PlayListIterator<AudioSong> filteredListIterator(int startIndex)
Description copied from interface:PlayListCreates a dynamically updated iterator for this playlist. This iterator will adjust to sort/filter changes to the underlying playlist.
The iterator does not support mutable operations.- Specified by:
filteredListIteratorin interfacePlayList- Parameters:
startIndex- index to start iterating from, first call toListIterator.next()orListIterator.previous()will produce the song at the given index- Returns:
- read-only, dynamically adjusting list iterator
-
countSongs
public int countSongs(Collection<? extends SongFilter> filters)
Description copied from interface:PlayListReturns song count from this playlist, filtered with the given filters.- Specified by:
countSongsin interfacePlayList- Returns:
- song count
- See Also:
PlayList.getSongIds(Set)
-
getUnfilteredSize
public int getUnfilteredSize()
Description copied from interface:PlayListUnfiltered number of songs in playlist. May return-1, if the number is unknown- Specified by:
getUnfilteredSizein interfacePlayList- Returns:
- number of songs in playlist
- See Also:
PlayList.setSubstringFilter(String, PlayList.SubstringFilterProperty)
-
indexOf
public int indexOf(Long id)
Description copied from interface:PlayListReturns the first index of the given song.
-
setSongIds
public void setSongIds(List<Long> songIds)
Description copied from interface:PlayListRemoves all songs from this playlist and replaces them with song connected to the given ids.- Specified by:
setSongIdsin interfacePlayList- Parameters:
songIds- song ids
-
removeAllSongs
public void removeAllSongs()
Description copied from interface:PlayListRemoves all songs from this playlist.- Specified by:
removeAllSongsin interfacePlayList
-
unfilteredIndices
public int[] unfilteredIndices(int... indices)
Description copied from interface:PlayListReturns the unfiltered indices for the given filtered (string, order) indices.- Specified by:
unfilteredIndicesin interfacePlayList- Parameters:
indices- filtered indices- Returns:
- unfiltered equivalents
-
filteredIndices
public int[] filteredIndices(int... unfilteredIndices)
Description copied from interface:PlayListReturns the filtered indices (string, order) for the given unfiltered indices.- Specified by:
filteredIndicesin interfacePlayList- Parameters:
unfilteredIndices- unfiltered indices- Returns:
- filtered equivalents or
-1, if that does not exist, because the index was filtered out
-
getSong
public AudioSong getSong(int index)
Description copied from interface:PlayListReturns song from the given index, taking sorting and filtering into account. This method may returnnulleven if a corresponding song exists, because it is loaded asynchronously.
UsePlayList.getIdAt(int), if you need a synchronous result.- Specified by:
getSongin interfacePlayList- Parameters:
index- index- Returns:
- song or
null, if not in the cache or the index is bad - See Also:
PlayList.getIdAt(int)
-
getIdAt
public Long getIdAt(int index)
Description copied from interface:PlayListReturns id of the song at the given index, taking sorting and filtering into account. Other thanPlayList.getSong(int), this method always returns an id, if the index is valid.- Specified by:
getIdAtin interfacePlayList- Parameters:
index- index- Returns:
- id or null, if the index it not valid
- See Also:
PlayList.getSong(int)
-
isParentAFolder
public boolean isParentAFolder()
- Specified by:
isParentAFolderin interfacePlayList
-
isUserPlaylist
public boolean isUserPlaylist()
Description copied from interface:PlayListIndicates that the playlist is just a regular user playlist. Note that Matchlists are not considered regular user playlists.- Specified by:
isUserPlaylistin interfacePlayList- Returns:
- true or false.
-
isPurchasedMusic
public boolean isPurchasedMusic()
Description copied from interface:PlayList- Specified by:
isPurchasedMusicin interfacePlayList
-
isItemsEditable
public boolean isItemsEditable()
Description copied from interface:PlayListAre the contained items editable? E.g., items are not editable, if they are only available online, as the metadata of some stream or online database cannot be changed locally.- Specified by:
isItemsEditablein interfacePlayList- Returns:
- true or false
-
canInsertItem
public boolean canInsertItem()
Description copied from interface:PlayListIndicates whether we can insert items into this playlist.- Specified by:
canInsertItemin interfacePlayList- Returns:
- true or false, typically false for generated lists like "Music"
-
canAddItem
public boolean canAddItem()
Description copied from interface:PlayListIndicates whether we can add items to this playlist.- Specified by:
canAddItemin interfacePlayList- Returns:
- true or false, typically false for generated lists like "Music"
-
isEditable
public boolean isEditable()
Description copied from interface:PlayListIs this playlist editable? Only playlists created by users are editable.- Specified by:
isEditablein interfacePlayList- Returns:
- true or false
-
getTotalTime
public long getTotalTime()
Description copied from interface:PlayListGet time with filters applied.- Specified by:
getTotalTimein interfacePlayList- Returns:
- time
-
getUnfilteredTime
public long getUnfilteredTime()
Description copied from interface:PlayListGet time without any filters applied.- Specified by:
getUnfilteredTimein interfacePlayList- Returns:
- time
-
getFileSize
public long getFileSize()
Description copied from interface:PlayListGet the sum of all file sizes (with filters applied).- Specified by:
getFileSizein interfacePlayList- Returns:
- sum of file sizes
-
isAggregateDataAvailable
public boolean isAggregateDataAvailable()
Description copied from interface:PlayListIndicates whether we currently have valid aggregate (total size, duration, etc.) data. If the data is not available, the asynchronous computation is triggered.- Specified by:
isAggregateDataAvailablein interfacePlayList- Returns:
- true or false
-
getSyncTempo
public com.tagtraum.audiokern.bpm.Tempo getSyncTempo()
Description copied from interface:PlayListWhen set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
getSyncTempoin interfacePlayList- Returns:
- sync tempo
- See Also:
PlayList.setSortProperties(String...)
-
setSyncTempo
public void setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
Description copied from interface:PlayListWhen set to a non-nullvalue,Keyvalues are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
setSyncTempoin interfacePlayList- Specified by:
setSyncTempoin interfaceSyncTempoAware- Parameters:
syncTempo- sync tempo
-
getSortColumnProperty
public String getSortColumnProperty()
Description copied from interface:PlayListReturns the name of the single property the playlist is sorted by. Note that for special properties likenamethis may not be the same properties as the ones we use forORDER BYSQL clauses. But, it's the property that should be highlighted in a UI.- Specified by:
getSortColumnPropertyin interfacePlayList- Returns:
- column
-
setSortColumnProperty
public void setSortColumnProperty(String property)
Description copied from interface:PlayListSets "visual/semantic" sort property.- Specified by:
setSortColumnPropertyin interfacePlayList- Parameters:
property- name of the property that is marked as sorted-by in the UI- See Also:
PlayList.getSortColumnProperty()
-
getSortProperty
public String getSortProperty(int index)
Description copied from interface:PlayListActual sort property, used inORDER BYSQL clauses.- Specified by:
getSortPropertyin interfacePlayList- Parameters:
index- index- Returns:
- property or
null
-
getSortProperties
public String[] getSortProperties()
Description copied from interface:PlayListActual sort properties, used inORDER BYHQL/SQL clauses.- Specified by:
getSortPropertiesin interfacePlayList- Returns:
- sort properties
-
getSubstringFilter
public String getSubstringFilter()
Description copied from interface:PlayListCurrent substring filter.- Specified by:
getSubstringFilterin interfacePlayList- Returns:
- filter string
-
getSubstringFilterProperty
public PlayList.SubstringFilterProperty getSubstringFilterProperty()
Description copied from interface:PlayListCurrent property to filter.- Specified by:
getSubstringFilterPropertyin interfacePlayList- Returns:
- which property to filter (substring)
- See Also:
PlayList.setSubstringFilter(String, SubstringFilterProperty)
-
setSortProperties
public void setSortProperties(String... properties)
Description copied from interface:PlayListSets sort properties.- Specified by:
setSortPropertiesin interfacePlayList- Parameters:
properties- sort properties
-
setSortDirection
public void setSortDirection(PlayList.SortDirection sortDirection)
Description copied from interface:PlayListSort direction.- Specified by:
setSortDirectionin interfacePlayList- Parameters:
sortDirection- sort direction
-
getSortDirection
public PlayList.SortDirection getSortDirection()
Description copied from interface:PlayListReturn sort direction.- Specified by:
getSortDirectionin interfacePlayList- Returns:
- sort direction
-
setSubstringFilter
public void setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Description copied from interface:PlayListSets the filter and which property to filter in one swoop.- Specified by:
setSubstringFilterin interfacePlayList- Parameters:
substring- filter stringsubstringFilterProperty- property to filter
-
-