sk.baka.ambient.collection
Class TrackMetadataBean

java.lang.Object
  extended by sk.baka.ambient.collection.TrackMetadataBean
All Implemented Interfaces:
Serializable

public final class TrackMetadataBean
extends Object
implements Serializable

Contains metadata about a track. Immutable, thread-safe.

Author:
Martin Vysny
See Also:
Serialized Form

Nested Class Summary
static class TrackMetadataBean.Builder
          The mutable version of TrackMetadataBean.
 
Field Summary
static TrackMetadataBean EMPTY
          An empty bean.
 
Method Summary
static void appendDisplayableLength(int length, StringBuilder builder, boolean emptyStringOnZero)
          Appends length in the [hh:]mm:ss format.
 boolean equals(Object o)
           
 String getAlbum()
          Album name.
 String getArtist()
          Artist name.
 String getArtistDesc()
          The artist's description.
 String getArtistURL()
          A link to artist's page
 int getBitrate()
          Bitrate in kbps.
 String getBuyURL()
          You can buy the album here
 String getComposer()
          Original composer.
 String getDisplayableLength()
          Returns length in the [hh:]mm:ss format.
static String getDisplayableLength(int length)
          Returns length in the [hh:]mm:ss format.
 String getDisplayableName()
          Returns the name of the track.
 long getFileSize()
          File size in bytes.
 int getFrequency()
          Frequency in hz.
 String getGenre()
          Genre.
 int getLength()
          Length in seconds.
 String getLicense()
          The license URL
 String getLocation()
          Location on the filesystem.
 TrackOriginEnum getOrigin()
          The track origin.
 String getTitle()
           
 long getTrackId()
          Database track id.
 String getTrackNumber()
           
 String getYearReleased()
          The year released.
 int hashCode()
           
 boolean isLocal()
          Checks if the track denoted by this object is a local one (you can pass getLocation() to a File object) , or an Internet stream (getLocation() is valid URL).
static TrackMetadataBean.Builder newBuilder()
          Returns new track metadata builder instance.
 TrackMetadataBean nullsEqualFields(TrackMetadataBean other)
          Creates new bean having equal fields nulled.
 TrackMetadataBean nullsEqualFields(TrackMetadataBean other, boolean sensibleFieldsOnly)
          Creates new bean having equal fields nulled.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final TrackMetadataBean EMPTY
An empty bean.

Method Detail

getDisplayableName

public final String getDisplayableName()
Returns the name of the track. Returns getTitle() unless it's null - in this case returns the file name.

Returns:
the track name, never null.

getDisplayableLength

public static String getDisplayableLength(int length)
Returns length in the [hh:]mm:ss format.

Parameters:
length - the length in seconds
Returns:
displayable length. If zero then empty string is returned.

appendDisplayableLength

public static void appendDisplayableLength(int length,
                                           StringBuilder builder,
                                           boolean emptyStringOnZero)
Appends length in the [hh:]mm:ss format.

Parameters:
length - the length in seconds
builder - append the time here.
emptyStringOnZero - if true then empty string is returned on zero.

getDisplayableLength

public String getDisplayableLength()
Returns length in the [hh:]mm:ss format.

Returns:
displayable length. If zero then empty string is returned.

getAlbum

public String getAlbum()
Album name.

Returns:
the album

getArtist

public String getArtist()
Artist name.

Returns:
the artist

getBitrate

public int getBitrate()
Bitrate in kbps. If zero then it is not known.

Returns:
the bitrate

getComposer

public String getComposer()
Original composer.

Returns:
the composer

getFileSize

public long getFileSize()
File size in bytes. -1 if the track is an Internet stream.

Returns:
the fileSize

getYearReleased

public String getYearReleased()
The year released.

Returns:
the yearReleased

getGenre

public String getGenre()
Genre.

Returns:
the genre

getLength

public int getLength()
Length in seconds. May be 0 if not known.

Returns:
the length

getLocation

public String getLocation()
Location on the filesystem. May be URL if it is an Internet stream.

Returns:
the location

isLocal

public boolean isLocal()
Checks if the track denoted by this object is a local one (you can pass getLocation() to a File object) , or an Internet stream (getLocation() is valid URL).

Returns:
true if the file is local.

getTitle

public String getTitle()
Returns:
the title

getTrackNumber

public String getTrackNumber()
Returns:
the trackNumber

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getFrequency

public int getFrequency()
Frequency in hz.

Returns:
the frequency in hz, or 0 if not known.

getTrackId

public long getTrackId()
Database track id.

Returns:
the trackId

nullsEqualFields

public TrackMetadataBean nullsEqualFields(TrackMetadataBean other)
Creates new bean having equal fields nulled.

Parameters:
other - the other bean
Returns:
bean with equal fields nulled.

nullsEqualFields

public TrackMetadataBean nullsEqualFields(TrackMetadataBean other,
                                          boolean sensibleFieldsOnly)
Creates new bean having equal fields nulled.

Parameters:
other - the other bean
sensibleFieldsOnly - if true then only sensible fields are compared - i.e. the bitrate, fileSize, frequency, length, title and trackNumber are not nulled even when equal.
Returns:
bean with equal fields nulled.

getOrigin

public TrackOriginEnum getOrigin()
The track origin.

Returns:
origin, never null.

getBuyURL

public String getBuyURL()
You can buy the album here

Returns:
the buyURL

getLicense

public String getLicense()
The license URL

Returns:
the license

getArtistURL

public String getArtistURL()
A link to artist's page

Returns:
the artistURL

getArtistDesc

public String getArtistDesc()
The artist's description.

Returns:
the artistDesc

newBuilder

public static TrackMetadataBean.Builder newBuilder()
Returns new track metadata builder instance.

Returns:
the builder instance.


Copyright © 2007-2008. All Rights Reserved.