|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
net.shredzone.ifish.db
Class Playlist
java.lang.Objectjavax.swing.AbstractListModel
net.shredzone.ifish.db.Playlist
- All Implemented Interfaces:
- Serializable, Comparable<Playlist>, ListModel
public class Playlist
- extends AbstractListModel
- implements Comparable<Playlist>
- extends AbstractListModel
This class represents a single playlist. A playlist can contain a number of Entry elements, which are kept in sequence.
- Version:
- $Id: Playlist.java 291 2009-04-28 21:29:27Z shred $
- See Also:
- Serialized Form
| Field Summary |
|---|
| Fields inherited from class javax.swing.AbstractListModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
Playlist(String name)
Create a new, empty playlist. |
|
| Method Summary | |
|---|---|
void |
addEntry(Entry entry)
Add an Entry to the bottom of the playlist. |
int |
compareTo(Playlist o)
Compares this Playlist to another playlist. |
boolean |
contains(Entry entry)
Check if this Playlist contains an Entry. |
boolean |
equals(Object obj)
Compare this playlist to another playlist. |
Object |
getElementAt(int index)
Get an Entry element at a certain index. |
List<Entry> |
getEntries()
Get all entries in a unmodifiable List. |
File |
getFile(File base,
String pldir)
Get the file that holds the playlist. |
String |
getInternalName()
Get the internal, case insensitive name. |
String |
getName()
Get the name of the playlist. |
int |
getSize()
Get the number of entries. |
int |
hashCode()
Calculate the hashCode of this playlist. |
int |
insertEntry(int index,
Entry entry)
Insert an Entry to a certain position. |
static String |
internalName(String name)
Converts a name to an internal name. |
boolean |
isCustomer()
Set if this is a customer playlist. |
boolean |
isEmpty()
Check if the playlist is empty. |
boolean |
isStatic()
Check if this is a static playlist. |
void |
mark()
Mark the current ending position. |
void |
readPlaylist(File base,
String pldir,
NaviDb navi,
String charset)
Read the playlist from the jukebox. |
void |
removeEntry(Entry entry)
Remove an Entry from the playlist. |
void |
setCustomer(boolean b)
Set if this is a customer playlist. |
void |
setStatic(boolean b)
Set if this is a static playlist. |
void |
shuffle()
Shuffle the entire playlist. |
void |
shuffle(int first,
int last)
Shuffle a sublist of this playlist. |
void |
sort(boolean desc)
Sort the entire playlist. |
void |
sort(int first,
int last,
boolean desc)
Sort a sublist of this playlist. |
void |
sortMark()
Sort everything starting from the marked position to the end of the list. |
String |
toString()
A String representation of the Playlist. |
void |
writePlaylist(File base,
String pldir,
String charset)
Write the playlist to the jukebox harddisk. |
| Methods inherited from class javax.swing.AbstractListModel |
|---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
Playlist
public Playlist(String name)
- Create a new, empty playlist.
- Parameters:
name- Name of the playlist.
| Method Detail |
|---|
internalName
public static String internalName(String name)
- Converts a name to an internal name.
Currently this method just returns the playlist name converted to lower case. This might change in future releases though.
- Parameters:
name- Name of the playlist- Returns:
- Internal name of the playlist.
getName
public String getName()
- Get the name of the playlist.
- Returns:
- Playlist name
getInternalName
public String getInternalName()
- Get the internal, case insensitive name. A playlist is considered
to be equal to another playlist, if both have the same internal
name.
- Returns:
- Internal playlist name.
- See Also:
internalName(java.lang.String)
setStatic
public void setStatic(boolean b)
- Set if this is a static playlist. Static playlists are just generated
once, from statical data, and won't be changed on subsequent
synchronisations.
By default, playlists are not static.
- Parameters:
b- true: static playlist.
isStatic
public boolean isStatic()
- Check if this is a static playlist. Static playlists are just generated
once, from statical data, and won't be changed on subsequent
synchronisations.
E.g. a playlist about new entries is static, since it is created once and won't change after that. A comment playlist is not static, since it may chance on every synchronisation.
Static playlists can be deleted by the user, since they won't be recreated on the next synchronisation.
- Returns:
- true: static playlist, false: dynamic playlist
setCustomer
public void setCustomer(boolean b)
- Set if this is a customer playlist. A customer playlist was generated
by a customer himself.
By default, playlists are not made by customers.
- Parameters:
b- true: customer playlist.
isCustomer
public boolean isCustomer()
- Set if this is a customer playlist. A customer playlist was generated
by a customer himself.
Customer playlists are always static playlists, but the static flag is not automatically set!
- Returns:
- true: customer playlist
getFile
public File getFile(File base, String pldir)
- Get the file that holds the playlist. The physical file does
not necessarily need to exist if the playlist has not been
written yet.
The file is always located in the pldir directory, and is named like the playlist name with ".m3u" appended to it.
- Parameters:
base- iHP base directorypldir- Playlist directory, null means root- Returns:
- Playlist file
addEntry
public void addEntry(Entry entry)
- Add an Entry to the bottom of the playlist.
- Parameters:
entry- Entry to be added.
removeEntry
public void removeEntry(Entry entry)
- Remove an Entry from the playlist. If the playlist did not contain
the Entry, nothing will happen.
- Parameters:
entry- Entry to be removed.
insertEntry
public int insertEntry(int index, Entry entry)
- Insert an Entry to a certain position.
If the playlist already contains the Entry, it will be moved to the new position (i.e. it will still only be listed once).
- Parameters:
index- Index to move the entry to.entry- Entry to be added.
contains
public boolean contains(Entry entry)
- Check if this Playlist contains an Entry.
- Parameters:
entry- Entry to check for- Returns:
- true if this Entry is part of the playlist.
mark
public void mark()
- Mark the current ending position.
sortMark
public void sortMark()
- Sort everything starting from the marked position to the end of the list.
The purpose is to sort new entries by their file name. First use
mark()to mark the current state, then useadd()to add new entries to the end of the list. After that, usesortMark()to sort those new entries.
sort
public void sort(boolean desc)
- Sort the entire playlist. If
descis set to true, the entries will be sorted in a descending order.- Parameters:
desc- true: descending order
sort
public void sort(int first, int last, boolean desc)
- Sort a sublist of this playlist. The entries between
first(including) andlast(excluding) will be sorted according to their file names. Ifdescis set to true, the entries will be sorted in a descending order.- Parameters:
first- First index, includinglast- Last index, excludingdesc- true: descending order
shuffle
public void shuffle()
- Shuffle the entire playlist.
shuffle
public void shuffle(int first, int last)
- Shuffle a sublist of this playlist. The entries between
first(including) andlast(excluding) will be brought into a random order.- Parameters:
first- First index, includinglast- Last index, excluding
isEmpty
public boolean isEmpty()
- Check if the playlist is empty.
- Returns:
- true: empty, false: at least one entry
getEntries
public List<Entry> getEntries()
- Get all entries in a unmodifiable List.
- Returns:
- List of all entries
getSize
public int getSize()
getElementAt
public Object getElementAt(int index)
- Get an Entry element at a certain index. The purpose of this
method is solely to fulfil the ListModel interface.
- Specified by:
getElementAtin interfaceListModel
- Parameters:
index- Index to fetch- Returns:
- The Entry object at this index
readPlaylist
public void readPlaylist(File base, String pldir, NaviDb navi, String charset) throws IOException, UnsupportedEncodingException
- Read the playlist from the jukebox. If there is no playlist file
with that name, nothing will happen. Note: the files from this
playlist are appended to this playlist object.
- Parameters:
base- iHP base directorypldir- Name of the playlist directorynavi- NaviDb that is used to find the Entry for each file of this playlistcharset- Charset to write the playlist in- Throws:
IOExceptionUnsupportedEncodingException
writePlaylist
public void writePlaylist(File base, String pldir, String charset) throws IOException, UnsupportedEncodingException
- Write the playlist to the jukebox harddisk. If the playlist
file already exists, it will be overwritten.
- Parameters:
base- iHP base directorypldir- Name of the playlist directorycharset- Charset to write the playlist in- Throws:
IOExceptionUnsupportedEncodingException
toString
public String toString()
- A String representation of the Playlist. It will return the name.
- Returns:
- String representation
hashCode
public int hashCode()
equals
public boolean equals(Object obj)
- Compare this playlist to another playlist. Two playlists are
considered being equal if their internal names are equal. If
the passed obj is null or is not a Playlist object, false will
be returned.
- Parameters:
obj- Object to compare this Playlist with.- Returns:
- true: equal, false: not equal
compareTo
public int compareTo(Playlist o)
- Compares this Playlist to another playlist. The internal names will
be compared.
- Specified by:
compareToin interfaceComparable<Playlist>
- Parameters:
o- Object to compare this Playlist with.- Returns:
- negative, zero or positive integer.
- Throws:
ClassCastException- See Also:
Comparable.compareTo(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 2007-2011 shredzone.org. All Rights Reserved.
