com.neoworks.jukex.tracksource
Class TrackSourcePipeline

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

public class TrackSourcePipeline
extends java.util.LinkedList
implements TrackSource

A pipeline of TrackSources. This is the guts of the Track selection strategy for JukeX. Individual TrackSources are chained together and result in a stream of Tracks that can be requested by a player.

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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Method Summary
 void add(int index, java.lang.Object element)
          Add an element to the pipeline at a specified position
 boolean add(java.lang.Object element)
          Add an element to the back of the pipeline
 boolean addAll(java.util.Collection c)
          Add the contents of a Collection to the back of the pipeline
 boolean addAll(int index, java.util.Collection c)
          Add the contents of a Collection to the pipeline at a specified position
 void addFirst(java.lang.Object element)
          Add an element to the head of the pipeline
 void addLast(java.lang.Object element)
          Add an element to the back of the pipeline
 java.lang.String getDescription()
          Return a String describing what, in general terms, this TrackSource does
 long getId()
          Get the database ID of this TrackSourcePipeline
 java.lang.String getName()
          Get the name of this TrackSourcePipeline
 Track getNextTrack()
          Get the next track from the source.
static TrackSourcePipeline getPipeline(java.lang.String name)
          Get a pipeline by name, creating a new one if it does not exist
 java.lang.String getSummary()
          Return a String summarising the configuration of the task the source is performing
 boolean isEnabled()
          Pipelines are always enabled (at the moment)
 java.util.Iterator iterator()
          Get an Iterator on this Pipeline
 java.util.ListIterator listIterator()
          Get an Iterator on this Pipeline
 java.util.ListIterator listIterator(int index)
          Get an Iterator on this Pipeline at a specific index
 java.util.List peekTracks(int count)
           
 java.lang.Object remove(int index)
          Remove the element at the specified position
 boolean remove(java.lang.Object element)
          Remove the first occurence of an element from the pipeline
 java.lang.Object removeFirst()
          Remove the first element in the pipeline
 java.lang.Object removeLast()
          Remove the last element from the pipeline
 boolean restorePipeline()
          Restore the state of the Pipeline (ie it's elements) from storage.
 java.lang.Object set(int index, java.lang.Object element)
          Replace the element at the specified position with the specified element
 boolean storePipeline()
          Store the state of the Pipeline to the database
 java.lang.String toString()
          Get a String representation of this Pipeline
 
Methods inherited from class java.util.LinkedList
clear, clone, contains, get, getFirst, getLast, indexOf, lastIndexOf, size, toArray, toArray
 
Methods inherited from class java.util.AbstractList
equals, hashCode, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.neoworks.jukex.tracksource.TrackSource
clone
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, removeAll, retainAll, subList
 

Method Detail

getPipeline

public static TrackSourcePipeline getPipeline(java.lang.String name)
Get a pipeline by name, creating a new one if it does not exist

Parameters:
name - The name of the pipeline to get
Returns:
A TrackSourcePipeline

getId

public long getId()
Get the database ID of this TrackSourcePipeline

Returns:
The database as a long

isEnabled

public boolean isEnabled()
Pipelines are always enabled (at the moment)

Specified by:
isEnabled in interface TrackSource
Returns:
Status

getName

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

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

getNextTrack

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

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

peekTracks

public java.util.List peekTracks(int count)

restorePipeline

public boolean restorePipeline()
Restore the state of the Pipeline (ie it's elements) from storage.


storePipeline

public boolean storePipeline()
Store the state of the Pipeline to the database

Returns:
success

add

public void add(int index,
                java.lang.Object element)
Add an element to the pipeline at a specified position

Specified by:
add in interface java.util.List
Overrides:
add in class java.util.LinkedList
Parameters:
index - The position to add the element at
element - The TrackSourcePipelineElement to add
Throws:
java.lang.ClassCastException - If element is not a TrackSourcePipelineElement
java.lang.IndexOutOfBoundsException - Self explanatory

add

public boolean add(java.lang.Object element)
Add an element to the back of the pipeline

Specified by:
add in interface java.util.List
Overrides:
add in class java.util.LinkedList
Parameters:
element - The TrackSourcePipelineElement to add
Returns:
Success
Throws:
java.lang.ClassCastException - If element is not a TrackSourcePipelineElement

addAll

public boolean addAll(java.util.Collection c)
Add the contents of a Collection to the back of the pipeline

Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.LinkedList
Parameters:
c - The Collection of TrackSourcePipelineElements
Returns:
Success
Throws:
java.lang.ClassCastException - If any of the elemtns in c are not TrackSourcePipelineElements

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Add the contents of a Collection to the pipeline at a specified position

Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.LinkedList
Parameters:
c - The Collection of TrackSourcePipelineElements
index - The position to insert the elements
Returns:
Success
Throws:
java.lang.ClassCastException - If any of the elemtns in c are not TrackSourcePipelineElements
java.lang.IndexOutOfBoundsException - Self explanatory

addFirst

public void addFirst(java.lang.Object element)
Add an element to the head of the pipeline

Overrides:
addFirst in class java.util.LinkedList
Parameters:
element - The element to add
Throws:
java.lang.ClassCastException - If element is not a TrackSourcePipelineElement

addLast

public void addLast(java.lang.Object element)
Add an element to the back of the pipeline

Overrides:
addLast in class java.util.LinkedList
Parameters:
element - The element to add
Throws:
java.lang.ClassCastException - If element is not a TrackSourcePipelineElement

remove

public java.lang.Object remove(int index)
Remove the element at the specified position

Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.LinkedList
Parameters:
index - The index of the element to remove
Returns:
The removed TrackSourcePipelineElement
Throws:
java.lang.IndexOutOfBoundsException - Self explanatory

remove

public boolean remove(java.lang.Object element)
Remove the first occurence of an element from the pipeline

Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.LinkedList
Parameters:
element - The object to remove
Returns:
Success
Throws:
java.lang.IndexOutOfBoundsException - Self explanatory

removeFirst

public java.lang.Object removeFirst()
Remove the first element in the pipeline

Overrides:
removeFirst in class java.util.LinkedList
Returns:
the TrackSourcePipelineElement removed

removeLast

public java.lang.Object removeLast()
Remove the last element from the pipeline

Overrides:
removeLast in class java.util.LinkedList
Returns:
the TrackSourcePipelineElement removed

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replace the element at the specified position with the specified element

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.LinkedList
Parameters:
index - The position to set
element - The TrackSourcePipelineElement to be stored
Returns:
The PipeLineElement that has been replaced
Throws:
java.lang.IndexOutOfBoundsException - index < 0 | index >= size()
java.lang.ClassCastException - If element is not a TrackSourcePipelineElement

iterator

public java.util.Iterator iterator()
Get an Iterator on this Pipeline

Specified by:
iterator in interface java.util.List
Overrides:
iterator in class java.util.AbstractSequentialList
Returns:
ListIterator for this Pipeline

listIterator

public java.util.ListIterator listIterator()
Get an Iterator on this Pipeline

Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList
Returns:
ListIterator for this Pipeline

listIterator

public java.util.ListIterator listIterator(int index)
Get an Iterator on this Pipeline at a specific index

Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.LinkedList
Parameters:
index - The index to begin at
Returns:
ListIterator for this Pipeline

toString

public java.lang.String toString()
Get a String representation of this Pipeline

Overrides:
toString in class java.util.AbstractCollection
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

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