com.evolution.player.core.media
Class MediaInfoBuilder<E extends MediaInfo>

java.lang.Object
  extended by com.evolution.player.core.media.MediaInfoBuilder<E>
Type Parameters:
E - the type of the media info to build

public class MediaInfoBuilder<E extends MediaInfo>
extends java.lang.Object

A media info builder can build a media info. The difference to MediaInfo.create(File) is that the media info builder can write to a file. Hint that it is only possible to modify a subset of media infos.

Since:
0.6

Method Summary
 E build()
          Create the result of the build.
static MediaInfoBuilder<MediaInfo> createBuilder()
          Create a builder which does modify a data structure in memory.
static MediaInfoBuilder<LocalMediaInfo> createLocalBuilder(java.io.File file)
          Create a builder which does modify the given file if such a builder exist.
 MediaInfoBuilder<E> setAlbumName(java.lang.String name)
          Set the name of the album to the given string.
 MediaInfoBuilder<E> setArtistName(java.lang.String name)
          Set the name of the artist to the given string.
 MediaInfoBuilder<E> setMusicbrainzId(java.lang.String mbid, MediaInfo.MusicbrainzIdType type)
          Set the given musibrainz id of the given type.
 MediaInfoBuilder<E> setSongName(java.lang.String name)
          Set the name of the song to the given string.
 MediaInfoBuilder<E> setTag(java.lang.String key, java.lang.String value)
          Set the tag with the given key to the given value.
 MediaInfoBuilder<E> setTrackNumber(int trackNumber)
          Set the track number of the song to the given number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createLocalBuilder

public static MediaInfoBuilder<LocalMediaInfo> createLocalBuilder(java.io.File file)
Create a builder which does modify the given file if such a builder exist.

Parameters:
file - the file to modify
Returns:
the builder to use to modify the file or null

createBuilder

public static MediaInfoBuilder<MediaInfo> createBuilder()
Create a builder which does modify a data structure in memory.

Returns:
the builder to use to modify the data structure

build

public E build()
                          throws java.io.IOException
Create the result of the build.

Returns:
the resulting media info
Throws:
java.io.IOException - if the media info could not be build

setSongName

public MediaInfoBuilder<E> setSongName(java.lang.String name)
                                                  throws java.io.IOException
Set the name of the song to the given string.

Parameters:
name - the name of the song
Returns:
this builder
Throws:
java.io.IOException - if the song name could not be stored

setAlbumName

public MediaInfoBuilder<E> setAlbumName(java.lang.String name)
                                                   throws java.io.IOException
Set the name of the album to the given string.

Parameters:
name - the name of the album
Returns:
this builder
Throws:
java.io.IOException - if the album name could not be stored

setArtistName

public MediaInfoBuilder<E> setArtistName(java.lang.String name)
                                                    throws java.io.IOException
Set the name of the artist to the given string.

Parameters:
name - the name of the artist
Returns:
this builder
Throws:
java.io.IOException - if the artist name could not be stored

setTrackNumber

public MediaInfoBuilder<E> setTrackNumber(int trackNumber)
                                                     throws java.io.IOException
Set the track number of the song to the given number.

Parameters:
trackNumber - the number of the track
Returns:
this builder
Throws:
java.io.IOException - if the track number could not be stored

setMusicbrainzId

public MediaInfoBuilder<E> setMusicbrainzId(java.lang.String mbid,
                                            MediaInfo.MusicbrainzIdType type)
                                                       throws java.io.IOException
Set the given musibrainz id of the given type.

Parameters:
mbid - the musicbrainz id
type - the type of the id
Returns:
this builder
Throws:
java.io.IOException - if id could not be stored

setTag

public MediaInfoBuilder<E> setTag(java.lang.String key,
                                  java.lang.String value)
                                             throws java.io.IOException
Set the tag with the given key to the given value.

Parameters:
key - the key of the tag
value - the value of the tag
Returns:
this builder
Throws:
java.io.IOException - if tag could not be stored