ca.bc.webarts.widgets
Class PlayList

java.lang.Object
  extended byca.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:
unknown

Field Summary
private  java.util.Vector songs
          This is the meat of the class; it holds OggFileRef objects.*
private static java.lang.String SYSTEM_FILE_SEPERATOR
           
 
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)
          Tells you if the Playlist contains a certain song.
 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 a song in the playlist and returns the index to it.
 int findSong(java.net.URL songUrl)
          Finds a song in the playlist and returns the index to it.
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 getSongName(int songIndex)
          Gets the songName attribute of the selected Song object
 java.lang.String[] getSongNames()
          Gets the songNames attribute of the PlayList object
 java.util.Vector getSongNamesVector()
          Gets the songNamesVector attribute of the PlayList object
 java.net.URL getSongUrl(int songIndex)
          Gets the URL attribute of the selected Song 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)
          Marks the OggFileRef as selected
 int size()
          The number of entries in the PlayList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

songs

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


SYSTEM_FILE_SEPERATOR

private static final java.lang.String SYSTEM_FILE_SEPERATOR
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 the Parameter
Method Detail

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

getSongName

public java.lang.String getSongName(int songIndex)
Gets the songName attribute of the selected Song object

Parameters:
songIndex - The index for the songname to retrieve
Returns:
The songName value

getSongUrl

public java.net.URL getSongUrl(int songIndex)
Gets the URL attribute of the selected Song object

Parameters:
songIndex - The index for the song to retrieve
Returns:
The URL for the spec'd song value

getSongUrls

protected java.net.URL[] getSongUrls()
Gets the songUrls attribute of the PlayList object

Returns:
The songUrls value

getURL

public java.net.URL getURL(java.lang.String songName)
Gets the uRL attribute of the PlayList object

Parameters:
songName - Description of the Parameter
Returns:
The uRL value

findSong

public int findSong(java.lang.String songName)
Finds a song in the playlist and returns the index to it.

Parameters:
songName - The Songname to look for
Returns:
the index postion of the found song in the playlist (-1 if not found)

findSong

public int findSong(java.net.URL songUrl)
Finds a song in the playlist and returns the index to it.

Returns:
the index postion of the found song in the playlist (-1 if not found)

contains

public boolean contains(java.lang.String songName)
Tells you if the Playlist contains a certain song.

Parameters:
songName - The Songname to look for
Returns:
True if the song was found

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.

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.

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.

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 the 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.

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.

size

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

Returns:
The number of entries in the PlayList.

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.

selectSong

public void selectSong(int songIndex,
                       boolean select)
Marks the OggFileRef as selected

Parameters:
songIndex - The song to select
select - for select or de-select

isSongSelected

public boolean isSongSelected(java.lang.String songName)
Gets the songSelected attribute of the PlayList object

Parameters:
songName - Description of the Parameter
Returns:
The songSelected value

isSongSelected

public boolean isSongSelected(int songIndex)
Gets the songSelected attribute of the PlayList object

Parameters:
songIndex - Description of the Parameter
Returns:
The songSelected value

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

readline

private java.lang.String readline(java.io.InputStream is)
Reads a single line from the InputStream.

Parameters:
is - Description of the Parameter
Returns:
the line read as a String

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 the Parameter

removeSong

public boolean removeSong(java.lang.String songName)
Description of the Method

Parameters:
songName - Description of the Parameter
Returns:
Description of the Return Value