sk.baka.ambient.collection.sync
Class SyncUtils

java.lang.Object
  extended by sk.baka.ambient.collection.sync.SyncUtils

public final class SyncUtils
extends java.lang.Object

Utility class.

Author:
Martin Vysny

Field Summary
 ICollection downloadFrom
          Download excess tracks from this collection.
 android.media.MediaScannerConnection msc
          Connection to the media scanner.
 TagFormatter pathFormatter
          produces a relative path where the music file should be stored.
 ICollection reference
          This is the reference collection, i.e.
 
Constructor Summary
SyncUtils(ICollection reference, ICollection downloadFrom, TagFormatter pathFormatter, android.media.MediaScannerConnection msc)
           
 
Method Summary
 void downloadTrack(java.lang.String rootPath, TrackMetadataBean track)
          Downloads given track.
static TagFormatter newPathFormatter()
          Returns a new instance of a default tag formatter.
static void removeLocalTracks(java.util.Collection<TrackMetadataBean> tracks, java.util.Collection<? extends TrackMetadataBean> localTracks)
          Removes local tracks from given collection.
static java.lang.String removeSlashes(java.lang.String str)
          Since /sdcard is most probably a fat32 drive, we have to remove several characters beside slash.
static TrackMetadataBean removeSlashes(TrackMetadataBean track)
          Creates a new track with invalid characters removed from title, album name, artist name, genre, year released and track number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pathFormatter

public final TagFormatter pathFormatter
produces a relative path where the music file should be stored. Must produce valid paths! Paths are created automatically.


reference

public final ICollection reference
This is the reference collection, i.e. tracks which are not to be synchronized.


downloadFrom

public final ICollection downloadFrom
Download excess tracks from this collection.


msc

public final android.media.MediaScannerConnection msc
Connection to the media scanner.

Constructor Detail

SyncUtils

public SyncUtils(ICollection reference,
                 ICollection downloadFrom,
                 TagFormatter pathFormatter,
                 android.media.MediaScannerConnection msc)
Parameters:
reference - This is the reference collection, i.e. tracks which are not to be synchronized.
downloadFrom - Download excess tracks from this collection.
pathFormatter - produces a relative path where the music file should be stored. Must produce valid paths! Paths are created automatically.
msc - after a successful track download the track will be reported to Android scanner.
Method Detail

newPathFormatter

public static TagFormatter newPathFormatter()
Returns a new instance of a default tag formatter. It outputs strings in the following form: sync/artist/year album/tracknum title.ext.

Returns:
non-null formatter instance.

removeLocalTracks

public static void removeLocalTracks(java.util.Collection<TrackMetadataBean> tracks,
                                     java.util.Collection<? extends TrackMetadataBean> localTracks)
Removes local tracks from given collection.

Parameters:
tracks - the track list. Removes local tracks from this collection.
localTracks - a list of local tracks.

removeSlashes

public static TrackMetadataBean removeSlashes(TrackMetadataBean track)
Creates a new track with invalid characters removed from title, album name, artist name, genre, year released and track number.

Parameters:
track - the track to fix
Returns:
fixed track.

removeSlashes

public static java.lang.String removeSlashes(java.lang.String str)
Since /sdcard is most probably a fat32 drive, we have to remove several characters beside slash.

Parameters:
str - the string to remove invalid characters from.
Returns:
string having all invalid characters replaced by _

downloadTrack

public void downloadTrack(java.lang.String rootPath,
                          TrackMetadataBean track)
                   throws java.io.IOException
Downloads given track.

Parameters:
rootPath - prepend the formatted name with this path. Must not end with a slash.
track - the track. Slashes are removed automatically.
Throws:
java.io.IOException


Copyright © 2007-2009. All Rights Reserved.