Class ITunesLibraryDescriptor
- java.lang.Object
-
- com.tagtraum.beatunes.library.LibraryDescriptor
-
- com.tagtraum.beatunes.library.itunes.ITunesLibraryDescriptor
-
public class ITunesLibraryDescriptor extends LibraryDescriptor
iTunes library descriptor.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ITunesLibraryDescriptor.LastModificationComparator
Allows you to compare LibraryDescriptors based on their file's last modification date.
-
Field Summary
Fields Modifier and Type Field Description static Comparator<LibraryDescriptor>
LAST_MODIFICATION_COMPARATOR
Allows you to compare LibraryDescriptors based on their file's last modification date.
-
Constructor Summary
Constructors Constructor Description ITunesLibraryDescriptor(Path file)
ITunesLibraryDescriptor(Path file, String id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LibraryLoader
createLibraryLoader()
Creates a library loader appropriate for this kind of library.boolean
equals(Object o)
boolean
exists()
Indicates whether the library described by this instance actually exists.Path
getFile()
String
getIdAsString()
Library id asString
.long
getLastModified()
If this library descriptor describes a document or is capable of determining the last modification of the library as a whole, this method returns the date.String
getName()
Name.int
hashCode()
boolean
needsRefresh(long lastSync)
Indicates whether we might want to sync this library.String
readId()
void
setFile(Path file)
String
toString()
AudioSong
wrap(AudioSong audioSong)
Wraps an internal database song into anotherAudioSong
that is capable of writing/reading data to external databases or files (e.g.PlayList
wrap(PlayList playList)
Wraps an internal database playlist into anotherPlayList
that is capable of writing/reading data to external databases or files.-
Methods inherited from class com.tagtraum.beatunes.library.LibraryDescriptor
getId, getMediaLibrary, setMediaLibrary
-
-
-
-
Field Detail
-
LAST_MODIFICATION_COMPARATOR
public static final Comparator<LibraryDescriptor> LAST_MODIFICATION_COMPARATOR
Allows you to compare LibraryDescriptors based on their file's last modification date. This enables us to pick the newest one of a bunch of library descriptors with the same id. Library descriptors can have the same id, when a library has been moved and the old one is still lying around.After sorting with
Collections.sort(java.util.List, java.util.Comparator)
the newest Library descriptor is first.
-
-
Method Detail
-
getName
public String getName()
Description copied from class:LibraryDescriptor
Name. E.g. "iTunes".- Specified by:
getName
in classLibraryDescriptor
- Returns:
- library name
-
readId
public String readId() throws IOException
- Throws:
IOException
-
getFile
public Path getFile()
-
getLastModified
public long getLastModified() throws IOException
Description copied from class:LibraryDescriptor
If this library descriptor describes a document or is capable of determining the last modification of the library as a whole, this method returns the date.- Specified by:
getLastModified
in classLibraryDescriptor
- Returns:
- date of last modification or 0 if unknown
- Throws:
IOException
-
needsRefresh
public boolean needsRefresh(long lastSync) throws IOException
Description copied from class:LibraryDescriptor
Indicates whether we might want to sync this library. If this cannot determined accurately, this method returnstrue
.- Specified by:
needsRefresh
in classLibraryDescriptor
- Parameters:
lastSync
- date of last sync- Returns:
- true, if we should probably sync
- Throws:
IOException
-
setFile
public void setFile(Path file)
-
getIdAsString
public String getIdAsString()
Description copied from class:LibraryDescriptor
Library id asString
.- Specified by:
getIdAsString
in classLibraryDescriptor
- Returns:
- id
- See Also:
PersistentId.idStringToLong(String)
-
exists
public boolean exists()
Description copied from class:LibraryDescriptor
Indicates whether the library described by this instance actually exists. Defaults totrue
.- Overrides:
exists
in classLibraryDescriptor
- Returns:
- true or false
-
createLibraryLoader
public LibraryLoader createLibraryLoader()
Description copied from class:LibraryDescriptor
Creates a library loader appropriate for this kind of library.- Specified by:
createLibraryLoader
in classLibraryDescriptor
- Returns:
- library loader
-
wrap
public AudioSong wrap(AudioSong audioSong)
Description copied from class:LibraryDescriptor
Wraps an internal database song into anotherAudioSong
that is capable of writing/reading data to external databases or files (e.g.Track
orAudioMetaData
). Depending on the kind of library, this wrapper might be quite different.- Specified by:
wrap
in classLibraryDescriptor
- Parameters:
audioSong
- song object to be wrapped, e.g.Song
- Returns:
- wrapper
-
wrap
public PlayList wrap(PlayList playList)
Description copied from class:LibraryDescriptor
Wraps an internal database playlist into anotherPlayList
that is capable of writing/reading data to external databases or files. Depending on the kind of library, this wrapper might be quite different.- Specified by:
wrap
in classLibraryDescriptor
- Parameters:
playList
- song object to be wrapped, e.g.HibernatePlayList
- Returns:
- wrapper
-
-