sk.baka.ambient.collection
Class TrackMetadataBean

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

@Immutable
@ThreadSafe
public final class TrackMetadataBean
extends java.lang.Object
implements java.io.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, java.lang.StringBuilder builder, boolean emptyStringOnZero)
          Appends length in the [hh:]mm:ss format.
 void appendDisplayableLength(java.lang.StringBuilder builder, boolean emptyStringOnZero)
          Appends length in the [hh:]mm:ss format.
 boolean equals(java.lang.Object o)
           
 java.lang.String getAlbum()
          Album name.
 java.lang.String getArtist()
          Artist name.
 java.lang.String getArtistDesc()
          The artist's description.
 java.lang.String getArtistURL()
          A link to artist's page
 int getBitrate()
          Bitrate in kbps.
 java.lang.String getBuyURL()
          You can buy the album here
 java.lang.String getComposer()
          Original composer.
 java.lang.String getDisplayableLength()
          Returns length in the [hh:]mm:ss format.
static java.lang.String getDisplayableLength(int length)
          Returns length in the [hh:]mm:ss format.
 java.lang.String getDisplayableName()
          Returns the name of the track.
 long getFileSize()
          File size in bytes.
 int getFrequency()
          Frequency in hz.
 java.lang.String getGenre()
          Genre.
 int getLength()
          Length in seconds.
 java.lang.String getLicense()
          The license URL
 java.lang.String getLocation()
          Location on the filesystem.
 TrackOriginEnum getOrigin()
          The track origin.
 java.lang.String getTitle()
           
 long getTrackId()
          Database track id.
 java.lang.String getTrackNumber()
           
 java.lang.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.
 java.lang.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 java.lang.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 java.lang.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,
                                           java.lang.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 java.lang.String getDisplayableLength()
Returns length in the [hh:]mm:ss format.

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

getAlbum

public java.lang.String getAlbum()
Album name.

Returns:
the album

getArtist

public java.lang.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 java.lang.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 java.lang.String getYearReleased()
The year released.

Returns:
the yearReleased

getGenre

public java.lang.String getGenre()
Genre.

Returns:
the genre

getLength

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

Returns:
the length

getLocation

public java.lang.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 java.lang.String getTitle()
Returns:
the title

getTrackNumber

public java.lang.String getTrackNumber()
Returns:
the trackNumber

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.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 java.lang.String getBuyURL()
You can buy the album here

Returns:
the buyURL

getLicense

public java.lang.String getLicense()
The license URL

Returns:
the license

getArtistURL

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

Returns:
the artistURL

getArtistDesc

public java.lang.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.

appendDisplayableLength

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

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


Copyright © 2007-2009. All Rights Reserved.