sk.baka.ambient.stream.shoutcast
Class ShoutcastUtils

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

public final class ShoutcastUtils
extends java.lang.Object

Utility methods for SHOUTcast support.

Author:
Martin Vysny

Field Summary
static java.net.URL GENRES_LIST
          The genres list XML location.
 
Method Summary
static java.util.List<Radio> getRadioList(java.io.InputStream in)
          Parses the XML radio list and returns parsed object instances.
static java.util.List<Radio> getRadioList(java.lang.String genre)
          Parses the server-side XML radio list and returns parsed object instances.
static java.util.List<java.lang.String> parseGenres()
          Parses the SHOUTcast genre list XML.
static java.util.List<java.lang.String> parseGenres(java.io.InputStream in)
          Parses the SHOUTcast genre list XML.
static java.util.List<TrackMetadataBean> parsePlaylist(java.io.InputStream in)
          Parses a playlist and returns list of all radio URLs (the File?=... lines; other lines are ignored).
static java.lang.String removeAsciiGraphics(java.lang.String string)
          Removes the ASCII graphics from the string start and end.
static void sortByName(java.util.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 java.net.URL GENRES_LIST
The genres list XML location.

Method Detail

parsePlaylist

public static java.util.List<TrackMetadataBean> parsePlaylist(java.io.InputStream in)
                                                       throws java.io.IOException,
                                                              java.text.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:
java.io.IOException - if i/o error occurs.
java.text.ParseException - if the playlist is not well formed.

parseGenres

public static java.util.List<java.lang.String> parseGenres()
                                                    throws java.io.IOException,
                                                           org.xml.sax.SAXException
Parses the SHOUTcast genre list XML. Reads the XML from the server.

Returns:
list of genres
Throws:
java.io.IOException
org.xml.sax.SAXException

parseGenres

public static java.util.List<java.lang.String> parseGenres(java.io.InputStream in)
                                                    throws java.io.IOException,
                                                           org.xml.sax.SAXException
Parses the SHOUTcast genre list XML.

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

getRadioList

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

Parameters:
genre - the genre
Returns:
radio list.
Throws:
org.xml.sax.SAXException
java.io.IOException - if i/o error occurs.

getRadioList

public static java.util.List<Radio> getRadioList(java.io.InputStream in)
                                          throws java.io.IOException,
                                                 org.xml.sax.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:
org.xml.sax.SAXException
java.io.IOException - if i/o error occurs.

sortByName

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

Parameters:
radioList - the list to sort.

removeAsciiGraphics

public static java.lang.String removeAsciiGraphics(java.lang.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-2009. All Rights Reserved.