sk.baka.ambient.playlist
Class Parsers

java.lang.Object
  extended by sk.baka.ambient.playlist.Parsers

public final class Parsers
extends java.lang.Object

Contains parsers for PLS, m3u, m3u8 and WPL playlists.

Author:
Martin Vysny

Method Summary
static boolean hasMetadata(java.lang.String filename)
          Checks if given playlist contains metadata.
static java.util.List<TrackMetadataBean> parse(java.io.File playlist)
          Parses given playlist.
static java.util.List<TrackMetadataBean> parseM3u(java.io.InputStream in, java.lang.String directory, boolean unicode)
          Parses the M3U playlist and returns list of tracks contained in the playlist.
static java.util.List<TrackMetadataBean> parsePls(java.io.InputStream in, java.lang.String directory)
          Parses the PLS playlist and returns list of tracks contained in the playlist.
static java.util.List<TrackMetadataBean> parseWpl(java.io.InputStream in, java.lang.String directory)
          Parses the WPL playlist and returns list of tracks contained in the playlist.
static java.util.List<TrackMetadataBean> parseXspf(java.io.InputStream in, java.lang.String directory)
          Parses the XSPF playlist and returns list of tracks contained in the playlist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parsePls

public static java.util.List<TrackMetadataBean> parsePls(java.io.InputStream in,
                                                         java.lang.String directory)
                                                  throws java.io.IOException,
                                                         java.text.ParseException
Parses the PLS playlist and returns list of tracks contained in the playlist.

Parameters:
in - the playlist stream. the stream is always closed.
directory - resolve all relative filenames against this directory. May be null if no resolving will be performed.
Returns:
list of parsed tracks.
Throws:
java.io.IOException - if i/o error occurs.
java.text.ParseException - on parse error

parseM3u

public static java.util.List<TrackMetadataBean> parseM3u(java.io.InputStream in,
                                                         java.lang.String directory,
                                                         boolean unicode)
                                                  throws java.io.IOException
Parses the M3U playlist and returns list of tracks contained in the playlist.

Parameters:
in - the playlist stream. the stream is always closed.
directory - resolve all relative filenames against this directory. May be null if no resolving will be performed.
unicode - if true then the M3U8 UTF-8 encoding is used. If false then the M3U ISO8859_1 encoding is used.
Returns:
list of tracks
Throws:
java.io.IOException - if i/o error occurs.

parseXspf

public static java.util.List<TrackMetadataBean> parseXspf(java.io.InputStream in,
                                                          java.lang.String directory)
                                                   throws java.io.IOException,
                                                          java.text.ParseException
Parses the XSPF playlist and returns list of tracks contained in the playlist.

Parameters:
in - the playlist stream. the stream is always closed.
directory - resolve all relative filenames against this directory. May be null if no resolving will be performed.
Returns:
list of tracks
Throws:
java.io.IOException - if i/o error occurs.
java.text.ParseException - if parse exception occurs.

parseWpl

public static java.util.List<TrackMetadataBean> parseWpl(java.io.InputStream in,
                                                         java.lang.String directory)
                                                  throws java.io.IOException,
                                                         java.text.ParseException
Parses the WPL playlist and returns list of tracks contained in the playlist.

Parameters:
in - the playlist stream. the stream is always closed.
directory - resolve all relative filenames against this directory. May be null if no resolving will be performed.
Returns:
list of tracks
Throws:
java.io.IOException - if i/o error occurs.
java.text.ParseException - if parse exception occurs.

parse

public static java.util.List<TrackMetadataBean> parse(java.io.File playlist)
                                               throws java.io.IOException,
                                                      java.text.ParseException
Parses given playlist.

Parameters:
playlist - the playlist to parse.
Returns:
list of tracks contained in the playlist
Throws:
java.io.IOException - if i/o error occurs
java.text.ParseException - if the playlist is not well formed or is of unknown type.

hasMetadata

public static boolean hasMetadata(java.lang.String filename)
Checks if given playlist contains metadata. Currently only XSPF playlists contain metadata.

Parameters:
filename - the file to check.
Returns:
true if the playlist contains track metadata, false otherwise.


Copyright © 2007-2009. All Rights Reserved.