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 ExecutorService
executor
protected MediaLibrary
musicLibrary
protected PlayList
playList
-
Constructor Summary
Constructors Modifier Constructor Description protected
PlayListFacade(PlayList playList, MediaLibrary musicLibrary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListDataListener(ListDataListener listener)
void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Add a listener.void
addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Add a listener for a specific property.boolean
canAddItem()
Indicates whether we can add items to this playlist.boolean
canInsertItem()
Indicates whether we can insert items into this playlist.boolean
contains(Long id)
int
countSongs(Collection<? extends SongFilter> filters)
Returns song count from this playlist, filtered with the given filters.boolean
equals(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()
String
getDescription()
PlayList.Kind
getDistinguishedKind()
Returns the special kind of this playlist.Object
getElementAt(int index)
long
getFileSize()
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.int
getGeniusTrackID()
Long
getId()
This list's id.Long
getIdAt(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.Liking
getLiking()
String
getName()
Long
getParentId()
If this is a sub-folder/playlist, this returns the parent id.PlayList
getParentPlayList()
PlayList
getPlayList()
Gets thePlayList
this playlist is a facade for.PlayList[]
getPlayListPath()
Returns path leading to this playlist and ending with it.int
getSize()
String
getSmartCriteria()
String
getSmartInfo()
AudioSong
getSong(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.String
getSortColumnProperty()
Returns the name of the single property the playlist is sorted by.PlayList.SortDirection
getSortDirection()
Return sort direction.String[]
getSortProperties()
Actual sort properties, used inORDER BY
HQL/SQL clauses.String
getSortProperty(int index)
Actual sort property, used inORDER BY
SQL clauses.SpecialPlayListInfo
getSpecialPlayListInfo()
Long
getSpecialPlayListInfoId()
String
getSubstringFilter()
Current substring filter.PlayList.SubstringFilterProperty
getSubstringFilterProperty()
Current property to filter.com.tagtraum.audiokern.bpm.Tempo
getSyncTempo()
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.long
getTotalTime()
Get time with filters applied.int
getUnfilteredSize()
Unfiltered number of songs in playlist.long
getUnfilteredTime()
Get time without any filters applied.int
hashCode()
int
indexOf(Long id)
Returns the first index of the given song.boolean
isAggregateDataAvailable()
Indicates whether we currently have valid aggregate (total size, duration, etc.) data.boolean
isAllItems()
boolean
isAudiobooks()
boolean
isEditable()
Is this playlist editable? Only playlists created by users are editable.boolean
isFolder()
boolean
isGeniusPlaylist()
boolean
isItemsEditable()
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.boolean
isLibrary()
Indicates that this is a library playlist, meaning one of the top level library views (e.g.boolean
isMaster()
Indicates whether this playlist is a master playlist.boolean
isMovies()
boolean
isMusic()
boolean
isParentAFolder()
boolean
isPodcasts()
boolean
isPurchasedMusic()
boolean
isSmartPlaylist()
boolean
isSpecialPlayList()
boolean
isTvShows()
boolean
isUserPlaylist()
Indicates that the playlist is just a regular user playlist.boolean
isVideos()
iTunes 6 playlist attribute.void
removeAllSongs()
Removes all songs from this playlist.void
removeListDataListener(ListDataListener listener)
void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Remove a listener.void
setSongIds(List<Long> songIds)
Removes all songs from this playlist and replaces them with song connected to the given ids.void
setSortColumnProperty(String property)
Sets "visual/semantic" sort property.void
setSortDirection(PlayList.SortDirection sortDirection)
Sort direction.void
setSortProperties(String... properties)
Sets sort properties.void
setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Sets the filter and which property to filter in one swoop.void
setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo.String
toString()
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 thePlayList
this playlist is a facade for.- Returns:
- wrapped playlist
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Remove a listener.- Specified by:
removePropertyChangeListener
in interfacePlayList
- Parameters:
propertyChangeListener
- listener
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Add a listener.- Specified by:
addPropertyChangeListener
in interfacePlayList
- Parameters:
propertyChangeListener
- listener
-
addPropertyChangeListener
public void addPropertyChangeListener(String property, PropertyChangeListener propertyChangeListener)
Description copied from interface:PlayList
Add a listener for a specific property.- Specified by:
addPropertyChangeListener
in interfacePlayList
propertyChangeListener
- listener
-
getElementAt
public Object getElementAt(int index)
- Specified by:
getElementAt
in interfaceListModel
-
addListDataListener
public void addListDataListener(ListDataListener listener)
- Specified by:
addListDataListener
in interfaceListModel
-
removeListDataListener
public void removeListDataListener(ListDataListener listener)
- Specified by:
removeListDataListener
in interfaceListModel
-
getParentId
public Long getParentId()
Description copied from interface:PlayList
If this is a sub-folder/playlist, this returns the parent id.- Specified by:
getParentId
in interfacePlayList
- Returns:
- id
-
getSpecialPlayListInfo
public SpecialPlayListInfo getSpecialPlayListInfo()
- Specified by:
getSpecialPlayListInfo
in interfacePlayList
-
getSpecialPlayListInfoId
public Long getSpecialPlayListInfoId()
- Specified by:
getSpecialPlayListInfoId
in interfacePlayList
-
getLiking
public AudioSong.Liking getLiking()
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfacePlayList
-
isSpecialPlayList
public boolean isSpecialPlayList()
- Specified by:
isSpecialPlayList
in interfacePlayList
-
getDistinguishedKind
public PlayList.Kind getDistinguishedKind()
Description copied from interface:PlayList
Returns the special kind of this playlist.- Specified by:
getDistinguishedKind
in interfacePlayList
- Returns:
null
if unknown
-
isAudiobooks
public boolean isAudiobooks()
Description copied from interface:PlayList
- Specified by:
isAudiobooks
in 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:
isPodcasts
in interfacePlayList
-
getChildPlayLists
public List<PlayList> getChildPlayLists()
- Specified by:
getChildPlayLists
in interfacePlayList
-
getParentPlayList
public PlayList getParentPlayList()
- Specified by:
getParentPlayList
in interfacePlayList
-
getPlayListPath
public PlayList[] getPlayListPath()
Description copied from interface:PlayList
Returns path leading to this playlist and ending with it. I.e., the path has at least the length 1.- Specified by:
getPlayListPath
in interfacePlayList
- Returns:
- path of playlists
-
isMaster
public boolean isMaster()
Description copied from interface:PlayList
Indicates whether this playlist is a master playlist. E.g. the (invisible list) Library is typically the master playlist.- Specified by:
isMaster
in interfacePlayList
- Returns:
- true or false
- See Also:
PlayList.isLibrary()
-
isLibrary
public boolean isLibrary()
Description copied from interface:PlayList
Indicates that this is a library playlist, meaning one of the top level library views (e.g. Music, AudioBooks, etc.).- Specified by:
isLibrary
in interfacePlayList
- Returns:
- true or false
- See Also:
PlayList.isMaster()
-
getGeniusTrackID
public int getGeniusTrackID()
- Specified by:
getGeniusTrackID
in interfacePlayList
-
isGeniusPlaylist
public boolean isGeniusPlaylist()
- Specified by:
isGeniusPlaylist
in interfacePlayList
-
isAllItems
public boolean isAllItems()
- Specified by:
isAllItems
in interfacePlayList
-
getSmartInfo
public String getSmartInfo()
- Specified by:
getSmartInfo
in interfacePlayList
-
isSmartPlaylist
public boolean isSmartPlaylist()
- Specified by:
isSmartPlaylist
in interfacePlayList
-
getSmartCriteria
public String getSmartCriteria()
- Specified by:
getSmartCriteria
in interfacePlayList
-
isVideos
public boolean isVideos()
Description copied from interface:PlayList
iTunes 6 playlist attribute.
-
getFilteredSongIds
public List<Long> getFilteredSongIds()
Description copied from interface:PlayList
Returns song ids from this playlist, both sorted and filtered.- Specified by:
getFilteredSongIds
in interfacePlayList
- Returns:
- song ids
-
getIndexedSongIds
public IndexedId[] getIndexedSongIds()
Description copied from interface:PlayList
A 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:
getIndexedSongIds
in interfacePlayList
- Returns:
- a complete list of persistent ids along with their natural indices
-
getSongIds
public List<Long> getSongIds()
Description copied from interface:PlayList
Returns song ids from this playlist, neither sorted not filtered.- Specified by:
getSongIds
in interfacePlayList
- Returns:
- song ids
-
getSongIds
public List<Long> getSongIds(Set<? extends SongFilter> filters)
Description copied from interface:PlayList
Returns song ids from this playlist, filtered with the given filters.- Specified by:
getSongIds
in interfacePlayList
- Returns:
- song ids
- See Also:
PlayList.getSongs(Collection, int)
-
getSongs
public Iterable<AudioSong> getSongs()
Description copied from interface:PlayList
Returns songs from this playlist, neither sorted nor filtered.
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction)
Description copied from interface:PlayList
Returns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedBy
in interfacePlayList
- Parameters:
sortProperty
- propertydirection
- direction- Returns:
- songs
-
getSongsOrderedBy
public Iterable<AudioSong> getSongsOrderedBy(String sortProperty, PlayList.SortDirection direction, int limit)
Description copied from interface:PlayList
Returns songs from this playlist, sorted by the given property.- Specified by:
getSongsOrderedBy
in 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:PlayList
Returns songs from this playlist, filtered with the given filters.- Specified by:
getSongs
in 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:PlayList
Returns songs from this playlist, both sorted and filtered.- Specified by:
getFilteredSongs
in interfacePlayList
- Returns:
- songs
-
filteredListIterator
public PlayListIterator<AudioSong> filteredListIterator(int startIndex)
Description copied from interface:PlayList
Creates 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:
filteredListIterator
in 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:PlayList
Returns song count from this playlist, filtered with the given filters.- Specified by:
countSongs
in interfacePlayList
- Returns:
- song count
- See Also:
PlayList.getSongIds(Set)
-
getUnfilteredSize
public int getUnfilteredSize()
Description copied from interface:PlayList
Unfiltered number of songs in playlist. May return-1
, if the number is unknown- Specified by:
getUnfilteredSize
in interfacePlayList
- Returns:
- number of songs in playlist
- See Also:
PlayList.setSubstringFilter(String, PlayList.SubstringFilterProperty)
-
indexOf
public int indexOf(Long id)
Description copied from interface:PlayList
Returns the first index of the given song.
-
setSongIds
public void setSongIds(List<Long> songIds)
Description copied from interface:PlayList
Removes all songs from this playlist and replaces them with song connected to the given ids.- Specified by:
setSongIds
in interfacePlayList
- Parameters:
songIds
- song ids
-
removeAllSongs
public void removeAllSongs()
Description copied from interface:PlayList
Removes all songs from this playlist.- Specified by:
removeAllSongs
in interfacePlayList
-
unfilteredIndices
public int[] unfilteredIndices(int... indices)
Description copied from interface:PlayList
Returns the unfiltered indices for the given filtered (string, order) indices.- Specified by:
unfilteredIndices
in interfacePlayList
- Parameters:
indices
- filtered indices- Returns:
- unfiltered equivalents
-
filteredIndices
public int[] filteredIndices(int... unfilteredIndices)
Description copied from interface:PlayList
Returns the filtered indices (string, order) for the given unfiltered indices.- Specified by:
filteredIndices
in 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:PlayList
Returns song from the given index, taking sorting and filtering into account. This method may returnnull
even if a corresponding song exists, because it is loaded asynchronously.
UsePlayList.getIdAt(int)
, if you need a synchronous result.- Specified by:
getSong
in 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:PlayList
Returns 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:
getIdAt
in 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:
isParentAFolder
in interfacePlayList
-
isUserPlaylist
public boolean isUserPlaylist()
Description copied from interface:PlayList
Indicates that the playlist is just a regular user playlist. Note that Matchlists are not considered regular user playlists.- Specified by:
isUserPlaylist
in interfacePlayList
- Returns:
- true or false.
-
isPurchasedMusic
public boolean isPurchasedMusic()
Description copied from interface:PlayList
- Specified by:
isPurchasedMusic
in interfacePlayList
-
isItemsEditable
public boolean isItemsEditable()
Description copied from interface:PlayList
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.- Specified by:
isItemsEditable
in interfacePlayList
- Returns:
- true or false
-
canInsertItem
public boolean canInsertItem()
Description copied from interface:PlayList
Indicates whether we can insert items into this playlist.- Specified by:
canInsertItem
in interfacePlayList
- Returns:
- true or false, typically false for generated lists like "Music"
-
canAddItem
public boolean canAddItem()
Description copied from interface:PlayList
Indicates whether we can add items to this playlist.- Specified by:
canAddItem
in interfacePlayList
- Returns:
- true or false, typically false for generated lists like "Music"
-
isEditable
public boolean isEditable()
Description copied from interface:PlayList
Is this playlist editable? Only playlists created by users are editable.- Specified by:
isEditable
in interfacePlayList
- Returns:
- true or false
-
getTotalTime
public long getTotalTime()
Description copied from interface:PlayList
Get time with filters applied.- Specified by:
getTotalTime
in interfacePlayList
- Returns:
- time
-
getUnfilteredTime
public long getUnfilteredTime()
Description copied from interface:PlayList
Get time without any filters applied.- Specified by:
getUnfilteredTime
in interfacePlayList
- Returns:
- time
-
getFileSize
public long getFileSize()
Description copied from interface:PlayList
Get the sum of all file sizes (with filters applied).- Specified by:
getFileSize
in interfacePlayList
- Returns:
- sum of file sizes
-
isAggregateDataAvailable
public boolean isAggregateDataAvailable()
Description copied from interface:PlayList
Indicates whether we currently have valid aggregate (total size, duration, etc.) data. If the data is not available, the asynchronous computation is triggered.- Specified by:
isAggregateDataAvailable
in interfacePlayList
- Returns:
- true or false
-
getSyncTempo
public com.tagtraum.audiokern.bpm.Tempo getSyncTempo()
Description copied from interface:PlayList
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
getSyncTempo
in interfacePlayList
- Returns:
- sync tempo
- See Also:
PlayList.setSortProperties(String...)
-
setSyncTempo
public void setSyncTempo(com.tagtraum.audiokern.bpm.Tempo syncTempo)
Description copied from interface:PlayList
When set to a non-null
value,Key
values are displayed as if the song was played back at the given tempo. This has consequences for the sort order.- Specified by:
setSyncTempo
in interfacePlayList
- Specified by:
setSyncTempo
in interfaceSyncTempoAware
- Parameters:
syncTempo
- sync tempo
-
getSortColumnProperty
public String getSortColumnProperty()
Description copied from interface:PlayList
Returns the name of the single property the playlist is sorted by. Note that for special properties likename
this may not be the same properties as the ones we use forORDER BY
SQL clauses. But, it's the property that should be highlighted in a UI.- Specified by:
getSortColumnProperty
in interfacePlayList
- Returns:
- column
-
setSortColumnProperty
public void setSortColumnProperty(String property)
Description copied from interface:PlayList
Sets "visual/semantic" sort property.- Specified by:
setSortColumnProperty
in 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:PlayList
Actual sort property, used inORDER BY
SQL clauses.- Specified by:
getSortProperty
in interfacePlayList
- Parameters:
index
- index- Returns:
- property or
null
-
getSortProperties
public String[] getSortProperties()
Description copied from interface:PlayList
Actual sort properties, used inORDER BY
HQL/SQL clauses.- Specified by:
getSortProperties
in interfacePlayList
- Returns:
- sort properties
-
getSubstringFilter
public String getSubstringFilter()
Description copied from interface:PlayList
Current substring filter.- Specified by:
getSubstringFilter
in interfacePlayList
- Returns:
- filter string
-
getSubstringFilterProperty
public PlayList.SubstringFilterProperty getSubstringFilterProperty()
Description copied from interface:PlayList
Current property to filter.- Specified by:
getSubstringFilterProperty
in interfacePlayList
- Returns:
- which property to filter (substring)
- See Also:
PlayList.setSubstringFilter(String, SubstringFilterProperty)
-
setSortProperties
public void setSortProperties(String... properties)
Description copied from interface:PlayList
Sets sort properties.- Specified by:
setSortProperties
in interfacePlayList
- Parameters:
properties
- sort properties
-
setSortDirection
public void setSortDirection(PlayList.SortDirection sortDirection)
Description copied from interface:PlayList
Sort direction.- Specified by:
setSortDirection
in interfacePlayList
- Parameters:
sortDirection
- sort direction
-
getSortDirection
public PlayList.SortDirection getSortDirection()
Description copied from interface:PlayList
Return sort direction.- Specified by:
getSortDirection
in interfacePlayList
- Returns:
- sort direction
-
setSubstringFilter
public void setSubstringFilter(String substring, PlayList.SubstringFilterProperty substringFilterProperty)
Description copied from interface:PlayList
Sets the filter and which property to filter in one swoop.- Specified by:
setSubstringFilter
in interfacePlayList
- Parameters:
substring
- filter stringsubstringFilterProperty
- property to filter
-
-