ca.bc.webarts.widgets
Class PlayList

java.lang.Object
  |
  +--ca.bc.webarts.widgets.PlayList

public class PlayList
extends java.lang.Object

A simple class to encapsulate the storage of references to Ogg files in a Playlist style.

Author:
Tom Gutwin P.Eng

Field Summary
private static java.lang.String className_
          A Class holder for its name (used in Logging).
protected static Log log_
          The Log that will get used.
private static java.lang.String logFile_
          The Log Filename.
private  java.util.Vector songs
          This is the meat of the class; it holds OggFileRef objects.*
private static java.lang.String SYSTEM_FILE_SEPERATOR
          Description of the Field
 
Constructor Summary
PlayList()
          basic constructor to initialize things.
PlayList(java.net.URL[] urls)
          Constructor to get things init and load up an initial list of URLs *
 
Method Summary
 java.lang.String addSong(java.net.URL url)
          Adds the specified song to the playlist.
 boolean contains(java.lang.String songName)
          Validates/checks if the requested song is in the list.
 javax.swing.JCheckBox createSongCheckBox(int index)
          Creates and returns a small JCheckBox with the selected song name and a small checkbox indicating if the song is selected.
 javax.swing.JCheckBox createSongCheckBox(java.lang.String songName)
          Creates and returns a small JCheckBox with the selected song name and a small checkbox indicating if the song is selected.
 javax.swing.JPanel createSongPanel(int index)
          Creates and returns a small JPanel with the selected song name and a small checkbox indicating if the song is selected.
 javax.swing.JPanel createSongPanel(java.lang.String song)
          Creates and returns a small JPanel with the selected song name and a small checkbox indicating if the song is selected.
 int findSong(java.lang.String songName)
          Finds the song in the playlist with the requested name and returns the index.
static java.lang.String[] getPlaylistArray(java.lang.String[] fileNames)
          Parses the passed filenames looking for OGG files.
 java.util.Vector getPlaylistVector(java.lang.String fileName)
          Parses the passed filename looking for OGG files.
static java.util.Vector getPlaylistVector(java.lang.String[] fileNames)
          Parses the passed filenames looking for OGG files.
 java.lang.String[] getSongNames()
          Gets the SongNames attribute of the PlayList object
 java.util.Vector getSongNamesVector()
          Gets the SongNamesVector attribute of the PlayList object
protected  java.net.URL[] getSongUrls()
          Gets the SongUrls attribute of the PlayList object
 java.net.URL getURL(java.lang.String songName)
          Gets the URL attribute of the PlayList object
 boolean isEmpty()
          Checks to see if the list of songs in this playlist is empty.
 boolean isSongSelected(int songIndex)
          Gets the SongSelected attribute of the PlayList object
 boolean isSongSelected(java.lang.String songName)
          Gets the SongSelected attribute of the PlayList object
 void loadPlaylist(java.net.URL filenameURL)
          Loads a playlist from the playlist file specified in the playListFilename_ field.
private  java.lang.String readline(java.io.InputStream is)
          Reads a single line from the InputStream.
 boolean removeSong(java.lang.String songName)
          Description of the Method
 void savePlaylistFile(java.lang.String filename)
          Saves the playlist to the file specified in the playListFilename_ field.
 void selectSong(int songIndex, boolean select)
          Sets the song 'selected' according to the passed boolean param.
 int size()
          The number of entries in the PlayList.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SYSTEM_FILE_SEPERATOR

private static final java.lang.String SYSTEM_FILE_SEPERATOR
Description of the Field

songs

private java.util.Vector songs
This is the meat of the class; it holds OggFileRef objects.*

className_

private static java.lang.String className_
A Class holder for its name (used in Logging).

logFile_

private static java.lang.String logFile_
The Log Filename.

log_

protected static Log log_
The Log that will get used.
Constructor Detail

PlayList

public PlayList()
basic constructor to initialize things. *

PlayList

public PlayList(java.net.URL[] urls)
Constructor to get things init and load up an initial list of URLs *
Parameters:
urls - Description of Parameter
Method Detail

getPlaylistArray

public static java.lang.String[] getPlaylistArray(java.lang.String[] fileNames)
Parses the passed filenames looking for OGG files. It will recurse directories if a dir is in the passed array.
Parameters:
fileNames - an array containg files and/or dir names to parse for OGG files.
Returns:
an array of OGG files that have been found within the passed in array of filenames.

getPlaylistVector

public static java.util.Vector getPlaylistVector(java.lang.String[] fileNames)
Parses the passed filenames looking for OGG files. It will recurse directories if a dir is in the passed array.
Parameters:
fileNames - an array containg files and/or dir names to parse for OGG files.
Returns:
a vector of OGG files that have been found within the passed in array of filenames.

getSongNamesVector

public java.util.Vector getSongNamesVector()
Gets the SongNamesVector attribute of the PlayList object
Returns:
The SongNamesVector value

getSongNames

public java.lang.String[] getSongNames()
Gets the SongNames attribute of the PlayList object
Returns:
The SongNames value

getURL

public java.net.URL getURL(java.lang.String songName)
Gets the URL attribute of the PlayList object
Parameters:
songName - Description of Parameter
Returns:
The URL value

isEmpty

public boolean isEmpty()
Checks to see if the list of songs in this playlist is empty.
Returns:
true if the list of songs in this playlist is empty, false if not.

getPlaylistVector

public java.util.Vector getPlaylistVector(java.lang.String fileName)
Parses the passed filename looking for OGG files. It will recurse directories if a dir is in the passed String.
Parameters:
fileName - an String (a file or dir name) to parse for OGG files.
Returns:
a vector of OGG files that have been found within the passed in String.

isSongSelected

public boolean isSongSelected(java.lang.String songName)
Gets the SongSelected attribute of the PlayList object
Parameters:
songName - Description of Parameter
Returns:
The SongSelected value

isSongSelected

public boolean isSongSelected(int songIndex)
Gets the SongSelected attribute of the PlayList object
Parameters:
songIndex - Description of Parameter
Returns:
The SongSelected value

findSong

public int findSong(java.lang.String songName)
Finds the song in the playlist with the requested name and returns the index.
Parameters:
songName - Description of Parameter
Returns:
Description of the Returned Value

contains

public boolean contains(java.lang.String songName)
Validates/checks if the requested song is in the list.
Parameters:
songName - Description of Parameter
Returns:
Description of the Returned Value

addSong

public java.lang.String addSong(java.net.URL url)
Adds the specified song to the playlist.
Parameters:
url - the specification for the song to add.
Returns:
the OggFileRef name of the added song.

createSongCheckBox

public javax.swing.JCheckBox createSongCheckBox(java.lang.String songName)
Creates and returns a small JCheckBox with the selected song name and a small checkbox indicating if the song is selected.
Parameters:
songName - Description of Parameter
Returns:
a JCheckBox containing a checkbox and Name of the song.

createSongCheckBox

public javax.swing.JCheckBox createSongCheckBox(int index)
Creates and returns a small JCheckBox with the selected song name and a small checkbox indicating if the song is selected.
Parameters:
index - the song num to look up
Returns:
a JCheckBox containing a checkbox and Name of the song.

createSongPanel

public javax.swing.JPanel createSongPanel(int index)
Creates and returns a small JPanel with the selected song name and a small checkbox indicating if the song is selected. This Panel is suitable to use a as a JComboBox Item.
Parameters:
index - the song num to look up
Returns:
a JPanel containing a checkbox and Name of the song.

createSongPanel

public javax.swing.JPanel createSongPanel(java.lang.String song)
Creates and returns a small JPanel with the selected song name and a small checkbox indicating if the song is selected. This Panel is suitable to use a as a JComboBox Item.
Parameters:
song - the song name to look up
Returns:
a JPanel containing a checkbox and Name of the song.

size

public int size()
The number of entries in the PlayList.
Returns:
The number of entries in the PlayList.

selectSong

public void selectSong(int songIndex,
                       boolean select)
Sets the song 'selected' according to the passed boolean param.
Parameters:
songIndex - Description of Parameter
select - Description of Parameter

loadPlaylist

public void loadPlaylist(java.net.URL filenameURL)
Loads a playlist from the playlist file specified in the playListFilename_ field. It first trys to load each line as a URL; if that fails it loads them as files. It simply adds the songs listed to the playList.
Parameters:
filenameURL - the filename to use as the playlist - specified as a URL

savePlaylistFile

public void savePlaylistFile(java.lang.String filename)
Saves the playlist to the file specified in the playListFilename_ field.
[playlist]
 File1=H:\MP3s\U2\October\02 - I Fall Down.mp3
 File2=H:\MP3s\Leonard Cohen\01 - Suzanne.mp3
 NumberOfEntries=2
 
Parameters:
filename - Description of Parameter

removeSong

public boolean removeSong(java.lang.String songName)
Description of the Method
Parameters:
songName - Description of Parameter
Returns:
Description of the Returned Value

getSongUrls

protected java.net.URL[] getSongUrls()
Gets the SongUrls attribute of the PlayList object
Returns:
The SongUrls value

readline

private java.lang.String readline(java.io.InputStream is)
Reads a single line from the InputStream.
Parameters:
is - Description of Parameter
Returns:
the line read as a String