sk.baka.ambient.library
Class LibraryUtils

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

public final class LibraryUtils
extends java.lang.Object

Library utility methods.

Author:
Martin Vysny

Field Summary
static java.lang.String[] COLUMN_NAMES
          All column names in the tracks table.
static java.lang.String COLUMNS
          All columns separated by commas.
static java.io.FileFilter MUSIC_FILTER
          Filters out all files except directories, playlist and track files.
static java.io.FilenameFilter MUSIC_NAME_FILTER
          Filters out all files except playlist and track files.
static java.util.List<java.lang.String> musicExtensions
          Set of supported extensions of music (track and playlist) files, lower-case.
static java.io.FileFilter PLAYLIST_FILTER
          Filters out all files except directories and playlist files.
static java.io.FilenameFilter PLAYLIST_NAME_FILTER
          Filters out all files except playlist files.
static java.util.List<java.lang.String> playlistExtensions
          Set of supported extensions of playlist files, lower-case.
static java.io.FileFilter TRACK_FILTER
          Filters out all files except directories and track files.
static java.io.FilenameFilter TRACK_META_NAME_FILTER
          Filters out all files except track files which the Entagged library supports.
static java.io.FilenameFilter TRACK_NAME_FILTER
          Filters out all files except track files.
static java.util.List<java.lang.String> trackExtensions
          Set of supported extensions of track files, lower-case.
static java.util.List<java.lang.String> trackMetaExtensions
          Set of supported extensions of track files, lower-case, which is the Entagged library able to process.
static java.util.List<java.lang.String> trackMime
          MIME types for trackExtensions.
 
Method Summary
static TrackMetadataBean cursorToTrackBean(android.database.Cursor cursor)
          Converts the sqlite3 ContentValues to the tag bean.
static java.lang.String fixId3Genre(java.lang.String genre)
          If the genre is in the form of (number), the string is replaced by appropriate genre name.
static java.lang.String getMime(java.lang.String fileName)
          Returns MIME type for given file.
static TrackMetadataBean getTag(java.lang.String filename)
          Retrieves a music file tag from given file name.
static java.util.List<java.lang.String> pollStrings(android.database.Cursor c, char separator, int column, java.util.List<java.lang.String> columnValues, java.lang.String... useAsNull)
          Polls all tracks from given cursor.
static java.util.List<TrackMetadataBean> pollTracks(android.database.Cursor c)
          Polls all tracks from given cursor.
static java.util.List<TrackMetadataBean> toTrackBean(java.util.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 android.content.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 java.lang.String[] COLUMN_NAMES
All column names in the tracks table.


COLUMNS

public static final java.lang.String COLUMNS
All columns separated by commas.


trackExtensions

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


trackMime

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


trackMetaExtensions

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


playlistExtensions

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


musicExtensions

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


TRACK_NAME_FILTER

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


TRACK_META_NAME_FILTER

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


TRACK_FILTER

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


PLAYLIST_NAME_FILTER

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


PLAYLIST_FILTER

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


MUSIC_NAME_FILTER

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


MUSIC_FILTER

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

Method Detail

cursorToTrackBean

public static TrackMetadataBean cursorToTrackBean(android.database.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 java.util.List<TrackMetadataBean> toTrackBean(java.util.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 android.content.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(java.lang.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 java.lang.String fixId3Genre(java.lang.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 java.util.List<TrackMetadataBean> pollTracks(android.database.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 java.util.List<java.lang.String> pollStrings(android.database.Cursor c,
                                                           char separator,
                                                           int column,
                                                           java.util.List<java.lang.String> columnValues,
                                                           java.lang.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 java.lang.String getMime(java.lang.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-2009. All Rights Reserved.