sk.baka.ambient.library
Class LibraryUtils

java.lang.Object
  extended by sk.baka.ambient.library.LibraryUtils

public final class LibraryUtils
extends Object

Library utility methods.

Author:
Martin Vysny

Field Summary
static String[] COLUMN_NAMES
          All column names in the tracks table.
static String COLUMNS
          All columns separated by commas.
static FileFilter MUSIC_FILTER
          Filters out all files except directories, playlist and track files.
static FilenameFilter MUSIC_NAME_FILTER
          Filters out all files except playlist and track files.
static List<String> musicExtensions
          Set of supported extensions of music (track and playlist) files, lower-case.
static FileFilter PLAYLIST_FILTER
          Filters out all files except directories and playlist files.
static FilenameFilter PLAYLIST_NAME_FILTER
          Filters out all files except playlist files.
static List<String> playlistExtensions
          Set of supported extensions of playlist files, lower-case.
static FileFilter TRACK_FILTER
          Filters out all files except directories and track files.
static FilenameFilter TRACK_META_NAME_FILTER
          Filters out all files except track files which the Entagged library supports.
static FilenameFilter TRACK_NAME_FILTER
          Filters out all files except track files.
static List<String> trackExtensions
          Set of supported extensions of track files, lower-case.
static List<String> trackMetaExtensions
          Set of supported extensions of track files, lower-case, which is the Entagged library able to process.
static List<String> trackMime
          MIME types for trackExtensions.
 
Method Summary
static TrackMetadataBean cursorToTrackBean(Cursor cursor)
          Converts the sqlite3 ContentValues to the tag bean.
static String fixId3Genre(String genre)
          If the genre is in the form of (number), the string is replaced by appropriate genre name.
static String getMime(String fileName)
          Returns MIME type for given file.
static TrackMetadataBean getTag(String filename)
          Retrieves a music file tag from given file name.
static List<String> pollStrings(Cursor c, char separator, int column, List<String> columnValues, String... useAsNull)
          Polls all tracks from given cursor.
static List<TrackMetadataBean> pollTracks(Cursor c)
          Polls all tracks from given cursor.
static List<TrackMetadataBean> toTrackBean(List<SkreemRSong> songs)
          Converts a list of SkreemRSong to a list of tag bean.
static TrackMetadataBean toTrackBean(SkreemRSong song)
          Converts the SkreemRSong to the tag bean.
static ContentValues trackBeanToValues(TrackMetadataBean track)
          Converts the track to ContentValues suitable for database insert.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN_NAMES

public static final String[] COLUMN_NAMES
All column names in the tracks table.


COLUMNS

public static final String COLUMNS
All columns separated by commas.


trackExtensions

public static final List<String> trackExtensions
Set of supported extensions of track files, lower-case.


trackMime

public static final List<String> trackMime
MIME types for trackExtensions.


trackMetaExtensions

public static final List<String> trackMetaExtensions
Set of supported extensions of track files, lower-case, which is the Entagged library able to process.


playlistExtensions

public static final List<String> playlistExtensions
Set of supported extensions of playlist files, lower-case.


musicExtensions

public static final List<String> musicExtensions
Set of supported extensions of music (track and playlist) files, lower-case.


TRACK_NAME_FILTER

public static final FilenameFilter TRACK_NAME_FILTER
Filters out all files except track files.


TRACK_META_NAME_FILTER

public static final FilenameFilter TRACK_META_NAME_FILTER
Filters out all files except track files which the Entagged library supports.


TRACK_FILTER

public static final FileFilter TRACK_FILTER
Filters out all files except directories and track files.


PLAYLIST_NAME_FILTER

public static final FilenameFilter PLAYLIST_NAME_FILTER
Filters out all files except playlist files.


PLAYLIST_FILTER

public static final FileFilter PLAYLIST_FILTER
Filters out all files except directories and playlist files.


MUSIC_NAME_FILTER

public static final FilenameFilter MUSIC_NAME_FILTER
Filters out all files except playlist and track files.


MUSIC_FILTER

public static final FileFilter MUSIC_FILTER
Filters out all files except directories, playlist and track files.

Method Detail

cursorToTrackBean

public static TrackMetadataBean cursorToTrackBean(Cursor cursor)
Converts the sqlite3 ContentValues to the tag bean.

Parameters:
cursor - the content values object, must not be null. Expects columns in COLUMN_NAMES ordering.
Returns:
the bean instance, never null

toTrackBean

public static TrackMetadataBean toTrackBean(SkreemRSong song)
Converts the SkreemRSong to the tag bean.

Parameters:
song - the song.
Returns:
the bean instance, never null

toTrackBean

public static List<TrackMetadataBean> toTrackBean(List<SkreemRSong> songs)
Converts a list of SkreemRSong to a list of tag bean.

Parameters:
songs - the song list.
Returns:
the bean instance, never null

trackBeanToValues

public static ContentValues trackBeanToValues(TrackMetadataBean track)
Converts the track to ContentValues suitable for database insert.

Parameters:
track - the track to convert.
Returns:
values

getTag

public static TrackMetadataBean getTag(String filename)
Retrieves a music file tag from given file name.

Parameters:
filename - the file to retrieve tags from.
Returns:
bean instance, never null.

fixId3Genre

public static String fixId3Genre(String genre)
If the genre is in the form of (number), the string is replaced by appropriate genre name.

Parameters:
genre - the genre to check
Returns:
fixed genre string representation.

pollTracks

public static List<TrackMetadataBean> pollTracks(Cursor c)
Polls all tracks from given cursor. The cursor is closed afterwards. Usable for example on the DBStrategy.findByCriteria(java.util.Map, boolean, String) method output.

Parameters:
c - the cursor
Returns:
list of track meta beans, never null, may be empty.

pollStrings

public static List<String> pollStrings(Cursor c,
                                       char separator,
                                       int column,
                                       List<String> columnValues,
                                       String... useAsNull)
Polls all tracks from given cursor. The cursor is closed afterwards. Usable for example on the DBStrategy.getCriteriaList(sk.baka.ambient.collection.CategoryEnum[], java.util.EnumMap) method result.

Parameters:
c - the cursor
separator - if multiple columns are required, this character separates them. In case of a single column, this parameter is ignored.
column - put values of this column into the columnValues list. Ignored when columnValues is null.
columnValues - put values from column here.
useAsNull - if not null then this value is used instead of null value.
Returns:
values of first selected column, never null, may be empty.

getMime

public static String getMime(String fileName)
Returns MIME type for given file. Detects only audio file types.

Parameters:
fileName - the file name.
Returns:
the MIME type or "application/octet-stream" if unknown.


Copyright © 2007-2008. All Rights Reserved.