org.musicontroller.gui.edit
Class TrackList

java.lang.Object
  extended by org.musicontroller.gui.edit.TrackList

public class TrackList
extends java.lang.Object

Helper class to construct a track listing of track index numbers satisfying some condition. For example, the tracks on which some artist plays guitar. Tracks can be "added" using the add() method. Adding a track increases the track counter. The track counter can be queried using getTrackCount(). The same track index number may be added more than once. Each addition will increase the track counter, but the track list will contain each added track index number exactly once.

Version:
$Id: TrackList.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
Author:
Hans Drexler

Constructor Summary
TrackList()
          Default constructor.
 
Method Summary
 void add(int trackno)
          Adds a track to the listing, increasing the track counter.
 boolean contains(int trackno)
          Tests if the track number is contained in the Tracklist.
 boolean containsAllSongs()
          Returns true if the number of added songs is greater or equal than the highestIndexNo.
static TrackList createInstance(Playlist playlist)
          Factory method creates a tracklist containing all tracks in the playlist.
static TrackList createInstance(java.lang.String tracks)
          Factory method for constructing TrackLists from strings representing track numbers separated by commas.
 boolean equals(java.lang.Object other)
          Two TrackLists are equal if they contain the same tracks.
 int getHighestIndexNr()
          Getter for the highest track number.
 int getTrackCount()
          Getter for the track counter.
 java.lang.String getTrackListing()
          Returns a string containing the numerically sorted track numbers of the added tracks separated by commas.
 int hashCode()
           
 void setHighestIndexNr(int highestTrackNo)
          Sets the index number of the last song in the tracklist.
 void setTracks(java.lang.String tracks)
          Adds all tracks in the tracks String to the list of tracks indexes.
 java.lang.String toString()
          Returns a short human readable representation of the track list.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrackList

public TrackList()
Default constructor.

Method Detail

getTrackCount

public int getTrackCount()
Getter for the track counter.

Returns:
The track counter.

add

public void add(int trackno)
Adds a track to the listing, increasing the track counter. Track 0 may be added multiple time, increasing the track count at every addition. Other track numbers will only be counted once. Negative track numbers are ignored.

Parameters:
trackno - The track index number.

getTrackListing

public java.lang.String getTrackListing()
Returns a string containing the numerically sorted track numbers of the added tracks separated by commas.

Returns:
The track listing.

equals

public boolean equals(java.lang.Object other)
Two TrackLists are equal if they contain the same tracks.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

createInstance

public static TrackList createInstance(java.lang.String tracks)
Factory method for constructing TrackLists from strings representing track numbers separated by commas.

Parameters:
tracks - The string representing the track numbers.
Returns:
A tracklist object reflecting the track numbers in the string.

createInstance

public static TrackList createInstance(Playlist playlist)
Factory method creates a tracklist containing all tracks in the playlist.

Parameters:
playlist - The playlist. If the playlist is null, the result is an empty tracklist.
Returns:
A Track list with all tracks in the play list.

contains

public boolean contains(int trackno)
Tests if the track number is contained in the Tracklist.

Parameters:
trackno - The track number to test.
Returns:
true if the track number is included in the track list, false otherwise.

setHighestIndexNr

public void setHighestIndexNr(int highestTrackNo)
Sets the index number of the last song in the tracklist. TrackList uses this number to determine if the entered tracks are equal to all tracks in the playlist.

Parameters:
highestTrackNo - the index of the last song in the tracklist

getHighestIndexNr

public int getHighestIndexNr()
Getter for the highest track number.

Returns:
The highest track number.

containsAllSongs

public boolean containsAllSongs()
Returns true if the number of added songs is greater or equal than the highestIndexNo. Return false in all other cases.

Returns:
True if getHighestIndexNr() <= getTrackCount() or else false.

setTracks

public void setTracks(java.lang.String tracks)
Adds all tracks in the tracks String to the list of tracks indexes. Track indexes are positive integers separated by commas. range indications are also allowed, like "7-9".

Parameters:
tracks - A String containing the tracks to add.

toString

public java.lang.String toString()
Returns a short human readable representation of the track list.

Overrides:
toString in class java.lang.Object


Copyright © 2010 A.J.V.. All Rights Reserved.