agentland.device.intelliCD
Class Song

java.lang.Object
  |
  +--agentland.device.intelliCD.Song
All Implemented Interfaces:
Serializable, SongContainerElement
Direct Known Subclasses:
CDSong, SoftwareSong

public class Song
extends Object
implements Serializable, SongContainerElement

Class for holding Songs. Contains information on the song itself, and also holds information on an enclosing SongContainer.

See Also:
Serializable, SongContainerElement, Serialized Form

Field Summary
protected  String author
          The author of the song.
protected  int duration
          The duration of the song, in seconds.
protected  long id
          The song identifier.
protected  SongContainer parent
          The containing structure that has information about this song.
protected  Player player
           
protected  String title
          The title of the song
 
Constructor Summary
Song()
          Creates a new, empty Song.
Song(long id)
          Creates a song placeholder.
Song(long id, String title, String author, int duration)
          Creates a new song and populates the fields.
 
Method Summary
 SongContainerElement copyParentTree()
           
 SongContainerElement copySubtree()
           
 boolean equals(long id)
           
 boolean equals(Object o)
           
 boolean equals(Song s)
           
 String getAuthor()
          Returns the author of the song.
 int getDuration()
          Returns the duration of the song.
 long getID()
          Get the identifier code for the song.
 String getName()
           
 String getNiceDuration()
          Gets a string with a nicely formatted duration.
 SongContainer getParent()
          Gets the song's containing class.
 Player getPlayer()
           
 String getTitle()
          Return the title of the song.
 int hashCode()
           
 String iconName()
           
 SongContainerElement lightweightCopy()
           
static String niceDuration(long t)
          Creates a nicely formatted duration string for the given duration.
 void pause()
           
 void play()
           
 void resume()
           
 void setAuthor(String a)
           
 void setDuration(int d)
           
protected  void setID(long l)
           
 void setParent(SongContainer d)
           
 void setPlayer(Player agent)
           
 void setTitle(String t)
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected long id
The song identifier. This is mostly used to store songs, but is also used to differentiate one song from another. Two different songs must be given different ids.

title

protected String title
The title of the song

author

protected String author
The author of the song.

parent

protected SongContainer parent
The containing structure that has information about this song.

duration

protected int duration
The duration of the song, in seconds.

player

protected transient Player player
Constructor Detail

Song

public Song()
Creates a new, empty Song. The information in the song is blank.

Song

public Song(long id,
            String title,
            String author,
            int duration)
Creates a new song and populates the fields.
Parameters:
id - the song ID.
title - the title.
author - the author.
duration - the song duration, in seconds.
See Also:
id

Song

public Song(long id)
Creates a song placeholder. This has an empty title and parent, but a valid ID, so it is considered equal to a filled-in song with the same information.
Parameters:
id - the identifier.
Method Detail

getTitle

public String getTitle()
Return the title of the song.
Returns:
the title.

getAuthor

public String getAuthor()
Returns the author of the song. If the author is not defined within the song, the author of the container is used instead.
Returns:
the author of the song.

getID

public long getID()
Get the identifier code for the song.
Specified by:
getID in interface SongContainerElement
Returns:
the song identifier.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getParent

public SongContainer getParent()
Gets the song's containing class. Since the SongContainer can nest items, this is usually the most specific container holding the song, not a parent of the container.
Specified by:
getParent in interface SongContainerElement
Returns:
The containing object.

getDuration

public int getDuration()
Returns the duration of the song.
Returns:
The duration, in seconds.

getNiceDuration

public String getNiceDuration()
Gets a string with a nicely formatted duration.
Returns:
A string of the format `MM:SS'
See Also:
niceDuration(long)

niceDuration

public static String niceDuration(long t)
Creates a nicely formatted duration string for the given duration.
Parameters:
t - the duration to format, in milliseconds
Returns:
a string of the format `MM:SS'

setTitle

public void setTitle(String t)

setAuthor

public void setAuthor(String a)

setID

protected void setID(long l)

setParent

public void setParent(SongContainer d)
Specified by:
setParent in interface SongContainerElement

setDuration

public void setDuration(int d)

setPlayer

public void setPlayer(Player agent)

getPlayer

public Player getPlayer()

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()
Specified by:
getName in interface SongContainerElement

equals

public boolean equals(Object o)
Overrides:
equals in class Object

equals

public boolean equals(long id)

equals

public boolean equals(Song s)

play

public void play()

pause

public void pause()

resume

public void resume()

stop

public void stop()

lightweightCopy

public SongContainerElement lightweightCopy()
Specified by:
lightweightCopy in interface SongContainerElement

copyParentTree

public SongContainerElement copyParentTree()
Specified by:
copyParentTree in interface SongContainerElement

copySubtree

public SongContainerElement copySubtree()
Specified by:
copySubtree in interface SongContainerElement

iconName

public String iconName()
Specified by:
iconName in interface SongContainerElement