com.neoworks.jukex.tracksource
Class TrackSourcePipelineElementSkeleton

java.lang.Object
  |
  +--com.neoworks.jukex.tracksource.TrackSourcePipelineElementSkeleton
All Implemented Interfaces:
java.io.Serializable, TrackSource, TrackSourcePipelineElement
Direct Known Subclasses:
AnnoyingPipelineElement, AudioBannerPipelineElement, FilterPipelineElement, JukeXPlaylist, NoRepeatPipelineElement, OnetimeSearchPipelineElement, RandomiserPipelineElement, RoundRobinPipelineElement, SearchRandomiserPipelineElement

public abstract class TrackSourcePipelineElementSkeleton
extends java.lang.Object
implements TrackSourcePipelineElement

Skeleton class that implements the framework for taking part in a Pipeline of PipelineElement objects.

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

Field Summary
protected  java.lang.String name
           
 
Constructor Summary
TrackSourcePipelineElementSkeleton()
          Default Constructor
TrackSourcePipelineElementSkeleton(java.lang.String name)
          Public Constructor
TrackSourcePipelineElementSkeleton(TrackSourcePipeline tsp)
          Public Constructor
TrackSourcePipelineElementSkeleton(TrackSourcePipeline tsp, java.lang.String name)
          Public Constructor
 
Method Summary
abstract  java.lang.Object clone()
          Not much point cloning this Clone operations should not copy the nextTrackSource or pipeline fields
protected  Track delegateGetNextTrack()
          Get the next track from the next track source in the chain, or do something appropriate if there is no track source, like screaming or flapping your arms.
protected  java.util.List delegatePeekTracks(int size)
          Peek the next source for the specified number of tracks.
 void disable()
          Disable this element
 void enable()
          Enable this element
 java.lang.String getName()
          Get the name of this PipelineElement
 TrackSourcePipelineElement getNextTrackSource()
          Return the next TrackSourcePipelineElement
 TrackSourcePipeline getOwner()
          Get the owner of this PipelineElement
abstract  java.util.Map getState()
          Get the current state of this PipelineElement for persisting
 boolean isEnabled()
          Is this TrackSource enabled?
 boolean removeTrack(int index)
          Remove a track from this PipelineElement (or rather don't).
 void setName(java.lang.String name)
          Set the owner of this PipelineElement
 TrackSourcePipelineElement setNextTrackSource(TrackSourcePipelineElement nextTrackSource)
          Tells this tracksource of a new link in the chain
 TrackSourcePipelineElement setOwner(TrackSourcePipeline pipe)
          Set the owner of this PipelineElement
abstract  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.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.neoworks.jukex.tracksource.TrackSourcePipelineElement
peekTracks
 
Methods inherited from interface com.neoworks.jukex.tracksource.TrackSource
getDescription, getNextTrack, getSummary
 

Field Detail

name

protected java.lang.String name
Constructor Detail

TrackSourcePipelineElementSkeleton

public TrackSourcePipelineElementSkeleton()
Default Constructor


TrackSourcePipelineElementSkeleton

public TrackSourcePipelineElementSkeleton(TrackSourcePipeline tsp)
Public Constructor

Parameters:
tsp - The parent Pipeline of this PipelineElement

TrackSourcePipelineElementSkeleton

public TrackSourcePipelineElementSkeleton(TrackSourcePipeline tsp,
                                          java.lang.String name)
Public Constructor

Parameters:
tsp - The parent Pipeline of this PipelineElement
name - The name of this element

TrackSourcePipelineElementSkeleton

public TrackSourcePipelineElementSkeleton(java.lang.String name)
Public Constructor

Parameters:
name - The name of this element
Method Detail

setNextTrackSource

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

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

getNextTrackSource

public final TrackSourcePipelineElement getNextTrackSource()
Return the next TrackSourcePipelineElement

Specified by:
getNextTrackSource in interface TrackSourcePipelineElement
Returns:
The next TrackSourcePipelineElement

delegateGetNextTrack

protected Track delegateGetNextTrack()
Get the next track from the next track source in the chain, or do something appropriate if there is no track source, like screaming or flapping your arms.


removeTrack

public boolean removeTrack(int index)
Remove a track from this PipelineElement (or rather don't).

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

delegatePeekTracks

protected java.util.List delegatePeekTracks(int size)
Peek the next source for the specified number of tracks.

Parameters:
size - The number of Tracks to peek
Returns:
A List of Track objects or null if there is no next element

storeState

public final 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

getState

public abstract java.util.Map getState()
Get the current state of this PipelineElement for persisting

Specified by:
getState in interface TrackSourcePipelineElement
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.

setState

public abstract boolean setState(java.util.Map state)
Load the configuration of this PipelineElement

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

getName

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

Specified by:
getName in interface TrackSource
Returns:
The name

setName

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

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

getOwner

public TrackSourcePipeline getOwner()
Get the owner of this PipelineElement

Returns:
The TrackSourcePipeline

setOwner

public TrackSourcePipelineElement setOwner(TrackSourcePipeline pipe)
Set the owner of this PipelineElement

Specified by:
setOwner in interface TrackSourcePipelineElement
Parameters:
pipe - The TrackSourcePipeline that owns this PipelineElement
Returns:
This PipelineElement for convenience

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

isEnabled

public final boolean isEnabled()
Description copied from interface: TrackSource
Is this TrackSource enabled?

Specified by:
isEnabled in interface TrackSource
Returns:
Status

clone

public abstract java.lang.Object clone()
Not much point cloning this Clone operations should not copy the nextTrackSource or pipeline fields

Specified by:
clone in interface TrackSource
Overrides:
clone in class java.lang.Object