com.neoworks.jukex.sqlimpl
Class JukeXPlaylist

java.lang.Object
  |
  +--com.neoworks.jukex.tracksource.TrackSourcePipelineElementSkeleton
        |
        +--com.neoworks.jukex.sqlimpl.JukeXPlaylist
All Implemented Interfaces:
java.util.Collection, java.util.List, Playlist, java.io.Serializable, TrackSource, TrackSourcePipelineElement

public class JukeXPlaylist
extends TrackSourcePipelineElementSkeleton
implements Playlist

Implementation of a Playlist

Author:
Nigel Atkinson (nigel@neoworks.com)
, Nick Vincent (nick@neoworks.com)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.neoworks.jukex.tracksource.TrackSourcePipelineElementSkeleton
name
 
Constructor Summary
JukeXPlaylist()
          Default constructor
JukeXPlaylist(java.lang.String name, long id)
          Creates a new instance of JukeXPlaylist
JukeXPlaylist(TrackSourcePipeline tsp)
          Public constructor
 
Method Summary
 void add(int index, java.lang.Object element)
          Add a Track to the Playlist at a specific position
 boolean add(java.lang.Object element)
          Add a Track to the Playlist
 boolean addAll(java.util.Collection c)
          Add a Collection of Tracks to the Playlist
 boolean addAll(int index, java.util.Collection c)
          Add a Collection of Tracks to the Playlist at a specific position
 void clear()
          Clear the list
 java.lang.Object clone()
          Must implement cloning
 boolean contains(java.lang.Object element)
          Check whether the Playlist contains a specific object
 boolean containsAll(java.util.Collection c)
          Check whether the List contains all of the specific objects in a Collection
 boolean equals(java.lang.Object o)
          Equality operator
 java.lang.Object get(int index)
          Get the object at a specific index from the List
 java.lang.String getDescription()
          Return a String describing what, in general terms, this TrackSource does
protected  long getId()
          Get the database id for this playlist
 Track getNextTrack()
          Get the next track from the head of the list
 java.util.Map getState()
          Get the state of this PipelineElement as a Map of Objects
 java.lang.String getSummary()
          Return a String summarising the configuration of the task the source is performing
 Track getTrack(int index)
          Get a track by index
 int indexOf(java.lang.Object o)
          Return the index of an object in the List or -1 if it does not appear in the List
 boolean isEmpty()
          Check whether the List contains any elements
 java.util.Iterator iterator()
          Get an Iterator on the List
 int lastIndexOf(java.lang.Object o)
          Return the index of the last occurence of an object in the List or -1 if it does not appear in the List
 java.util.ListIterator listIterator()
          Get a listIterator on the List
 java.util.ListIterator listIterator(int index)
          Get a listIterator on the List at a particular position
 java.util.List peekTracks(int count)
          Peek at the upcoming tracks
 java.lang.Object remove(int index)
          Remove the Object at index from the List
 boolean remove(java.lang.Object o)
          Remove an Object from the List
 boolean removeAll(java.util.Collection c)
          Remove all of the Objects in a Collection from the List
 boolean retainAll(java.util.Collection c)
          Retains only the elements in the List that are contained in a Collection
 java.lang.Object set(int index, java.lang.Object element)
          Set the contents of a position in the List
 boolean setState(java.util.Map state)
          Set the state of this PipelineElement from a Map of Objects
 int size()
          Get the size of the list
 java.util.List subList(int fromIndex, int toIndex)
          Get a sublist from the List
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in the List in proper sequence
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing all of the elements in the List in proper sequence; the runtime type of the returned array is that of the specified array.
 java.lang.String toString()
          Get a pretty String representation of the list
 
Methods inherited from class com.neoworks.jukex.tracksource.TrackSourcePipelineElementSkeleton
delegateGetNextTrack, delegatePeekTracks, disable, enable, getName, getNextTrackSource, getOwner, isEnabled, removeTrack, setName, setNextTrackSource, setOwner, storeState
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.neoworks.jukex.Playlist
getName
 
Methods inherited from interface java.util.List
hashCode
 
Methods inherited from interface com.neoworks.jukex.tracksource.TrackSourcePipelineElement
disable, enable, getNextTrackSource, removeTrack, setName, setNextTrackSource, setOwner, storeState
 
Methods inherited from interface com.neoworks.jukex.tracksource.TrackSource
isEnabled
 

Constructor Detail

JukeXPlaylist

public JukeXPlaylist()
Default constructor


JukeXPlaylist

public JukeXPlaylist(java.lang.String name,
                     long id)
Creates a new instance of JukeXPlaylist

Parameters:
name - The Playlist name
id - The database id of the Playlist

JukeXPlaylist

public JukeXPlaylist(TrackSourcePipeline tsp)
Public constructor

Parameters:
tsp - The Pipeline whose bitch this Element is
Method Detail

getId

protected long getId()
Get the database id for this playlist

Returns:
The id

getNextTrack

public Track getNextTrack()
Get the next track from the head of the list

Specified by:
getNextTrack in interface Playlist
Returns:
the next Track or null

getTrack

public Track getTrack(int index)
Get a track by index

Specified by:
getTrack in interface Playlist
Parameters:
index - The track index to get
Returns:
The Track at the specified index

peekTracks

public java.util.List peekTracks(int count)
Peek at the upcoming tracks

Specified by:
peekTracks in interface TrackSourcePipelineElement
Parameters:
count - The number of tracks to peek ahead at
Returns:
A List of Track objects

setState

public boolean setState(java.util.Map state)
Set the state of this PipelineElement from a Map of Objects

Specified by:
setState in interface TrackSourcePipelineElement
Specified by:
setState in class TrackSourcePipelineElementSkeleton
Parameters:
state - Map representing the state of this Playlist
Returns:
success

getState

public java.util.Map getState()
Get the state of this PipelineElement as a Map of Objects

Specified by:
getState in interface TrackSourcePipelineElement
Specified by:
getState in class TrackSourcePipelineElementSkeleton
Returns:
a String keyed Map of objects representing the state of this PipelineElement, e.g. for a Playlist this would be information allowing the reconstruction of the current playlist queue.

add

public void add(int index,
                java.lang.Object element)
Add a Track to the Playlist at a specific position

Specified by:
add in interface java.util.List
Parameters:
index - The position to insert at
element - The Track to add
Throws:
java.lang.ClassCastException - If the object is not a Track

add

public boolean add(java.lang.Object element)
Add a Track to the Playlist

Specified by:
add in interface java.util.List
Parameters:
element - The Track to add
Returns:
success
Throws:
java.lang.ClassCastException - If the object is not a Track

addAll

public boolean addAll(java.util.Collection c)
Add a Collection of Tracks to the Playlist

Specified by:
addAll in interface java.util.List
Parameters:
c - The Collection of Track objects
Returns:
success
Throws:
java.lang.ClassCastException - If any of the objects are not Tracks

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Add a Collection of Tracks to the Playlist at a specific position

Specified by:
addAll in interface java.util.List
Parameters:
index - The position to insert at
c - The Collection of Track objects
Returns:
success
Throws:
java.lang.ClassCastException - If any of the objects are not Tracks

clear

public void clear()
Clear the list

Specified by:
clear in interface java.util.List

size

public int size()
Get the size of the list

Specified by:
size in interface java.util.List
Returns:
the size

isEmpty

public boolean isEmpty()
Check whether the List contains any elements

Specified by:
isEmpty in interface java.util.List
Returns:
result

containsAll

public boolean containsAll(java.util.Collection c)
Check whether the List contains all of the specific objects in a Collection

Specified by:
containsAll in interface java.util.List
Parameters:
c - The Collection of objects to check for
Returns:
result

contains

public boolean contains(java.lang.Object element)
Check whether the Playlist contains a specific object

Specified by:
contains in interface java.util.List
Parameters:
element - The Object to check for
Returns:
result

equals

public boolean equals(java.lang.Object o)
Equality operator

Specified by:
equals in interface java.util.List
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare
Returns:
result

remove

public java.lang.Object remove(int index)
Remove the Object at index from the List

Specified by:
remove in interface java.util.List
Parameters:
index - The index of the comdemned object
Returns:
the removed Object

remove

public boolean remove(java.lang.Object o)
Remove an Object from the List

Specified by:
remove in interface java.util.List
Parameters:
o - The Object to remove
Returns:
success

removeAll

public boolean removeAll(java.util.Collection c)
Remove all of the Objects in a Collection from the List

Specified by:
removeAll in interface java.util.List
Parameters:
c - The Collection of condemned Objects
Returns:
success

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in the List that are contained in a Collection

Specified by:
retainAll in interface java.util.List
Parameters:
c - The Collection of objects to retain
Returns:
success

listIterator

public java.util.ListIterator listIterator(int index)
Get a listIterator on the List at a particular position

Specified by:
listIterator in interface java.util.List
Parameters:
index - The position of the Iterator in the List
Returns:
A listIterator at the position specified

listIterator

public java.util.ListIterator listIterator()
Get a listIterator on the List

Specified by:
listIterator in interface java.util.List
Returns:
A listIterator

iterator

public java.util.Iterator iterator()
Get an Iterator on the List

Specified by:
iterator in interface java.util.List
Returns:
An Iterator

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Return the index of the last occurence of an object in the List or -1 if it does not appear in the List

Specified by:
lastIndexOf in interface java.util.List
Parameters:
o - The object to get the index of
Returns:
The index of the last occurence of an Object or -1 if it does not appear in the List

indexOf

public int indexOf(java.lang.Object o)
Return the index of an object in the List or -1 if it does not appear in the List

Specified by:
indexOf in interface java.util.List
Parameters:
o - The object to get the index of
Returns:
The index of the Object or -1 if it does not appear in the List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing all of the elements in the List in proper sequence; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface java.util.List
Returns:
An array containing the elements

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in the List in proper sequence

Specified by:
toArray in interface java.util.List
Returns:
An array containing the elements

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Set the contents of a position in the List

Specified by:
set in interface java.util.List
Parameters:
index - The position in the List to fill
element - The element to insert
Returns:
The inserted Object

get

public java.lang.Object get(int index)
Get the object at a specific index from the List

Specified by:
get in interface java.util.List
Parameters:
index - The index of the required object
Returns:
The object

subList

public java.util.List subList(int fromIndex,
                              int toIndex)
Get a sublist from the List

Specified by:
subList in interface java.util.List
Parameters:
fromIndex - The position of the beginning of the sublist
toIndex - The position of the end of the sublist

toString

public java.lang.String toString()
Get a pretty String representation of the list

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Description copied from interface: TrackSource
Must implement cloning

Specified by:
clone in interface TrackSource
Specified by:
clone in class TrackSourcePipelineElementSkeleton

getSummary

public java.lang.String getSummary()
Return a String summarising the configuration of the task the source is performing

Specified by:
getSummary in interface TrackSource
Returns:
A String

getDescription

public java.lang.String getDescription()
Return a String describing what, in general terms, this TrackSource does

Specified by:
getDescription in interface TrackSource
Returns:
A String