sk.baka.ambient.stream.shoutcast
Class ShoutcastUtils

java.lang.Object
  extended by sk.baka.ambient.stream.shoutcast.ShoutcastUtils

public final class ShoutcastUtils
extends Object

Utility methods for SHOUTcast support.

Author:
Martin Vysny

Field Summary
static URL GENRES_LIST
          The genres list XML location.
 
Method Summary
static List<Radio> getRadioList(InputStream in)
          Parses the XML radio list and returns parsed object instances.
static List<Radio> getRadioList(String genre)
          Parses the server-side XML radio list and returns parsed object instances.
static List<String> parseGenres()
          Parses the SHOUTcast genre list XML.
static List<String> parseGenres(InputStream in)
          Parses the SHOUTcast genre list XML.
static List<TrackMetadataBean> parsePlaylist(InputStream in)
          Parses a playlist and returns list of all radio URLs (the File?=... lines; other lines are ignored).
static String removeAsciiGraphics(String string)
          Removes the ASCII graphics from the string start and end.
static void sortByName(List<Radio> radioList)
          Sorts given radio list by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENRES_LIST

public static final URL GENRES_LIST
The genres list XML location.

Method Detail

parsePlaylist

public static List<TrackMetadataBean> parsePlaylist(InputStream in)
                                             throws IOException,
                                                    ParseException
Parses a playlist and returns list of all radio URLs (the File?=... lines; other lines are ignored).

Parameters:
in - the playlist stream. the stream is always closed.
Returns:
list of URLs
Throws:
IOException - if i/o error occurs.
ParseException - if the playlist is not well formed.

parseGenres

public static List<String> parseGenres()
                                throws IOException,
                                       SAXException
Parses the SHOUTcast genre list XML. Reads the XML from the server.

Returns:
list of genres
Throws:
IOException
SAXException

parseGenres

public static List<String> parseGenres(InputStream in)
                                throws IOException,
                                       SAXException
Parses the SHOUTcast genre list XML.

Parameters:
in - the XML to read. the stream is always closed.
Returns:
list of genres
Throws:
IOException
SAXException

getRadioList

public static List<Radio> getRadioList(String genre)
                                throws IOException,
                                       SAXException
Parses the server-side XML radio list and returns parsed object instances.

Parameters:
genre - the genre
Returns:
radio list.
Throws:
SAXException
IOException - if i/o error occurs.

getRadioList

public static List<Radio> getRadioList(InputStream in)
                                throws IOException,
                                       SAXException
Parses the XML radio list and returns parsed object instances.

Parameters:
in - the XML to parse
Returns:
radio list. The list is sorted by the radio name and duplicate items are removed.
Throws:
SAXException
IOException - if i/o error occurs.

sortByName

public static void sortByName(List<Radio> radioList)
Sorts given radio list by name.

Parameters:
radioList - the list to sort.

removeAsciiGraphics

public static String removeAsciiGraphics(String string)
Removes the ASCII graphics from the string start and end. Graphics in the middle is left as-is. The string is trimmed as well.

Parameters:
string - the string
Returns:
trimmed string with ASCII graphics removed.


Copyright © 2007-2008. All Rights Reserved.