playcontrol
Class Song

java.lang.Object
  |
  +--playcontrol.Song

public class Song
extends java.lang.Object

Objects of this class represent playlist items, songs. A song has an id unique in its playlist, and other song information (title, album, length etc.). There can be several constructors for different information sources. Song information can be queried after a datum name, or in predefined formats.

Version:
$Id: Song.java,v 1.12 2002/11/11 14:30:56 tuukka Exp $
Author:
Niko Kotilainen, Tuukka Hastrup

Field Summary
static int debug
           
protected  java.util.Map info
          Song info mapping from datum names to String values.
protected  java.lang.String np3id
           
protected  java.lang.String np3string
           
static java.lang.String rcsid
           
 
Constructor Summary
protected Song()
          Instances are created using static methods.
 
Method Summary
static void dbg(java.lang.String msg)
           
static java.lang.String formatTime(int milliseconds)
          Formats the specified time as a string.
static Song fromNp3(java.lang.String np3id, java.lang.String np3string, java.lang.String time)
          Gives Song object for Np3 playlist item.
 java.lang.String getId()
          Returns the id of this song.
 java.lang.String getInfo(java.lang.String name)
          Returns the specified song info datum
 boolean hasInfoData()
          Tests whether this song has song info.
static void info(java.lang.String msg)
           
 java.lang.String infoString(java.lang.String prefix, java.lang.String name, java.lang.String suffix)
          Formats song info value as a string.
 java.lang.String inPlaylist()
          Formats info of this song for playlist.
 java.lang.String timeString(java.lang.String prefix, java.lang.String suffix)
          Formats song length time as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcsid

public static final java.lang.String rcsid
See Also:
Constant Field Values

debug

public static int debug

np3id

protected java.lang.String np3id

np3string

protected java.lang.String np3string

info

protected java.util.Map info
Song info mapping from datum names to String values.

If datum is null, it is not set (probably because it wasn't available for this filetype).

If datum is "", it is unknown (probably because it wasn't available for this file).
namevalue
Songsong title
Tracktrack number
Timelength in milliseconds
Yearyear (of publication)

Constructor Detail

Song

protected Song()
Instances are created using static methods.

Method Detail

dbg

public static void dbg(java.lang.String msg)

info

public static void info(java.lang.String msg)

fromNp3

public static Song fromNp3(java.lang.String np3id,
                           java.lang.String np3string,
                           java.lang.String time)
Gives Song object for Np3 playlist item.

Parameters:
np3id - the id unique for this playlist entry
np3string - info string sent by np3
time - length of this song in seconds
Returns:
Song object parsed from a string from np3

getId

public java.lang.String getId()
Returns the id of this song.

Returns:
an id string of this song, unique within its playlist

getInfo

public java.lang.String getInfo(java.lang.String name)
Returns the specified song info datum

Parameters:
name - a song info datum name
Returns:
the datum for this song, or "" if unspecified, or null if not available

hasInfoData

public boolean hasInfoData()
Tests whether this song has song info.

Returns:
true if meaningful info available

inPlaylist

public java.lang.String inPlaylist()
Formats info of this song for playlist.

Returns:
song info presentation suitable for showing in playlist.

infoString

public java.lang.String infoString(java.lang.String prefix,
                                   java.lang.String name,
                                   java.lang.String suffix)
Formats song info value as a string.

Parameters:
prefix - text added before datum
name - name of the info datum
suffix - text added after datum
Returns:
prefix, datum, and suffix, or empty string if no such datum.

timeString

public java.lang.String timeString(java.lang.String prefix,
                                   java.lang.String suffix)
Formats song length time as a string.

Parameters:
prefix - text added before time
suffix - text added after time
Returns:
prefix, time, suffix, or empty string if length unknown

formatTime

public static java.lang.String formatTime(int milliseconds)
Formats the specified time as a string.

Returns:
time string