sk.baka.ambient.playlist
Class Parsers

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

public final class Parsers
extends Object

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

Author:
Martin Vysny

Method Summary
static boolean hasMetadata(String filename)
          Checks if given playlist contains metadata.
static List<TrackMetadataBean> parse(File playlist)
          Parses given playlist.
static List<TrackMetadataBean> parseM3u(InputStream in, String directory, boolean unicode)
          Parses the M3U playlist and returns list of tracks contained in the playlist.
static List<TrackMetadataBean> parsePls(InputStream in, String directory)
          Parses the PLS playlist and returns list of tracks contained in the playlist.
static List<TrackMetadataBean> parseWpl(InputStream in, String directory)
          Parses the WPL playlist and returns list of tracks contained in the playlist.
static List<TrackMetadataBean> parseXspf(InputStream in, 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 List<TrackMetadataBean> parsePls(InputStream in,
                                               String directory)
                                        throws IOException,
                                               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:
IOException - if i/o error occurs.
ParseException - on parse error

parseM3u

public static List<TrackMetadataBean> parseM3u(InputStream in,
                                               String directory,
                                               boolean unicode)
                                        throws 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:
IOException - if i/o error occurs.

parseXspf

public static List<TrackMetadataBean> parseXspf(InputStream in,
                                                String directory)
                                         throws IOException,
                                                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:
IOException - if i/o error occurs.
ParseException - if parse exception occurs.

parseWpl

public static List<TrackMetadataBean> parseWpl(InputStream in,
                                               String directory)
                                        throws IOException,
                                               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:
IOException - if i/o error occurs.
ParseException - if parse exception occurs.

parse

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

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

hasMetadata

public static boolean hasMetadata(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-2008. All Rights Reserved.