com.neoworks.jukex.sqlimpl
Class InMemoryPlaylist

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.AbstractSequentialList
                    |
                    +--java.util.LinkedList
                          |
                          +--com.neoworks.jukex.sqlimpl.InMemoryPlaylist
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, Playlist, java.io.Serializable, TrackSource, TrackSourcePipelineElement

public class InMemoryPlaylist
extends java.util.LinkedList
implements Playlist

A Playlist implementation that is not persisted to the database

Author:
Nick Vincent (nick@neoworks.com)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
InMemoryPlaylist()
          Creates a new instance of InMemoryPlaylist
InMemoryPlaylist(java.lang.String name)
          Creates a new instance of InMemoryPlaylist
 
Method Summary
 java.lang.Object clone()
          Must implement cloning
 void disable()
          Disable this element
 void enable()
          Enable this element
 java.lang.String getDescription()
          Return a String describing what, in general terms, this TrackSource does
 java.lang.String getName()
          Get the name of this TrackSource
 Track getNextTrack()
          Get the next track from the source.
 TrackSourcePipelineElement getNextTrackSource()
          Get the next TrackSourcePipelineElement.
 java.util.Map getState()
          Get the current state of this PipelineElement for persisting.
 java.lang.String getSummary()
          Return a String summarising the configuration of the task the source is performing
 Track getTrack(int index)
          Get the Track at the specified index
 boolean isEnabled()
          Is this playlist enabled
 java.util.List peekTracks(int count)
          Peek at the next count tracks from this TrackSourcePipelineElement
 boolean removeTrack(int index)
          Remove a track from the playlist
 void setName(java.lang.String name)
          Set the name of this Playlist
 TrackSourcePipelineElement setNextTrackSource(TrackSourcePipelineElement next)
          Tells this tracksource of a new link in the chain
 TrackSourcePipelineElement setOwner(TrackSourcePipeline pipe)
          Set which TrackSourcePipeline this PipelineElement is currently a part of
 boolean setState(java.util.Map state)
          Load the configuration of this PipelineElement.
 boolean storeState(java.sql.Connection conn)
          Persist the current state of the PipelineElement into the database
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, contains, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, remove, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

InMemoryPlaylist

public InMemoryPlaylist()
Creates a new instance of InMemoryPlaylist


InMemoryPlaylist

public InMemoryPlaylist(java.lang.String name)
Creates a new instance of InMemoryPlaylist

Parameters:
name - The name of this playlist
Method Detail

getName

public java.lang.String getName()
Get the name of this TrackSource

Specified by:
getName in interface Playlist
Returns:
A String identifying the TrackSource

isEnabled

public boolean isEnabled()
Is this playlist enabled

Specified by:
isEnabled in interface TrackSource
Returns:
Status

enable

public void enable()
Description copied from interface: TrackSourcePipelineElement
Enable this element

Specified by:
enable in interface TrackSourcePipelineElement

disable

public void disable()
Description copied from interface: TrackSourcePipelineElement
Disable this element

Specified by:
disable in interface TrackSourcePipelineElement

getNextTrack

public Track getNextTrack()
Get the next track from the source.

Specified by:
getNextTrack in interface Playlist
Returns:
A Track object

removeTrack

public boolean removeTrack(int index)
Remove a track from the playlist

Specified by:
removeTrack in interface TrackSourcePipelineElement
Parameters:
index - The index of the track to remove
Returns:
Success

getNextTrackSource

public TrackSourcePipelineElement getNextTrackSource()
Get the next TrackSourcePipelineElement. Does nothing in this implementation as it isn't supported.

Specified by:
getNextTrackSource in interface TrackSourcePipelineElement
Returns:
null

getState

public java.util.Map getState()
Get the current state of this PipelineElement for persisting. As this will never be persisted it just returns null.

Specified by:
getState in interface TrackSourcePipelineElement
Returns:
null

getTrack

public Track getTrack(int index)
Get the Track at the specified index

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

peekTracks

public java.util.List peekTracks(int count)
Peek at the next count tracks from this TrackSourcePipelineElement

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

setNextTrackSource

public TrackSourcePipelineElement setNextTrackSource(TrackSourcePipelineElement next)
Tells this tracksource of a new link in the chain

Specified by:
setNextTrackSource in interface TrackSourcePipelineElement
Returns:
The previous TrackSource

setOwner

public TrackSourcePipelineElement setOwner(TrackSourcePipeline pipe)
Set which TrackSourcePipeline this PipelineElement is currently a part of

Specified by:
setOwner in interface TrackSourcePipelineElement
Parameters:
pipe - The TrackSourcePipeline to which you now belong
Returns:
The PipelineElement, to allow for chaining of calls

setState

public boolean setState(java.util.Map state)
Load the configuration of this PipelineElement. This does nothing as the configuration is never stored.

Specified by:
setState in interface TrackSourcePipelineElement
Parameters:
state - a Map of values keyed by Strings representing the state of this PipelineElement.
Returns:
success

storeState

public boolean storeState(java.sql.Connection conn)
Persist the current state of the PipelineElement into the database

Specified by:
storeState in interface TrackSourcePipelineElement
Parameters:
conn - The database connection to use, which must have AutoCommit disabled
Returns:
success

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

setName

public void setName(java.lang.String name)
Set the name of this Playlist

Specified by:
setName in interface TrackSourcePipelineElement
Parameters:
name - The new name

clone

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

Specified by:
clone in interface TrackSource
Overrides:
clone in class java.util.LinkedList