org.esau.ptarmigan.impl.filter
Class B4SFilter

java.lang.Object
  |
  +--org.xml.sax.helpers.XMLFilterImpl
        |
        +--org.esau.ptarmigan.impl.filter.BaseFilter
              |
              +--org.esau.ptarmigan.impl.filter.PlaylistFilter
                    |
                    +--org.esau.ptarmigan.impl.filter.XMLPlaylistFilter
                          |
                          +--org.esau.ptarmigan.impl.filter.B4SFilter
All Implemented Interfaces:
CharacterStreamSource, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

public final class B4SFilter
extends XMLPlaylistFilter

B4SFilter -- transforms B4S playlist to ptarmigan playlist

  Example source:

   <?xml version="1.0" encoding='UTF-8' standalone="yes"?>
    <WinampXML>
    <!- Generated by: Nullsoft Winamp3 version 3.0 ->
     <playlist num_entries="4" label="Playlist 001">
       <entry Playstring="file:C:\work\java\ptarmigan\ptarmigan\test\none.mp3">
         <Name>none</Name>
         <Length>2247</Length>
       </entry>
       <entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\01 - Body And Soul.mp3">
         <Name>Billie Holiday - Body And Soul</Name>
         <Length>383530</Length>
       </entry>
       <entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\02 - They Can't Take That Away From Me.mp3">
         <Name>Billie Holiday - They Can't Take That Away From Me</Name>
         <Length>252500</Length>
       </entry>
       <entry Playstring="file:C:\music\Jazz\Vocals\Billie Holiday\Body and Soul\03 - Darn That Dream.mp3">
         <Name>Billie Holiday - Darn That Dream</Name>
         <Length>379481</Length>
       </entry>
     </playlist>
    </WinampXML>
 
 The equivalent XSLT would appear thus:
 
<xsl:stylesheet version="1.0" xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:pl='http://esau.org/ns/ptarmigan/playlist'> <xsl:param name='include_entries'/> <xsl:param name='file_separator'/> <xsl:template match="/WinampXML/playlist"> <pl:playlist> <pl:properties> <pl:title><xsl:value-of select='@label'/></pl:title> <pl:entry-count><xsl:value-of select='count(./entry)'/></pl:entry-count> <pl:duration-total><xsl:value-of select='sum(./entry/Length)'/></pl:duration-total> </pl:properties> <xsl:if test="$include_entries = 'true'"> <xsl:apply-templates select="entry"/> </xsl:if> </pl:playlist> </xsl:template> <xsl:template match="entry"> <pl:entry> <pl:path><xsl:value-of select='@Playstring'/></pl:path> <pl:title><xsl:value-of select='Name'/></pl:title> <pl:duration><xsl:value-of select='Length'/></pl:duration> </pl:entry> </xsl:template> </xsl:stylesheet>
TODO: recursively scan all playlists found.

Version:
$Revision: 1.2 $ $Date: 2002/09/16 04:05:07 $
Author:
Reed Esau

Constructor Summary
B4SFilter()
           
 
Method Summary
 void endElement(java.lang.String uri, java.lang.String local_name, java.lang.String qName)
          Filter an end element event.
 boolean isMatch(java.lang.String sniff_chars)
          is the root element of the xml file indicate it's WinampXML? Note: do B4S files have namespaces?
 void startElement(java.lang.String uri, java.lang.String local_name, java.lang.String qName, org.xml.sax.Attributes atts)
          Filter a start element event.
 
Methods inherited from class org.esau.ptarmigan.impl.filter.XMLPlaylistFilter
endDocument, startDocument
 
Methods inherited from class org.esau.ptarmigan.impl.filter.PlaylistFilter
getIncludeEntries, resetData, setBaseDir, setIncludeEntries
 
Methods inherited from class org.esau.ptarmigan.impl.filter.BaseFilter
characters, getMediaProperties, parse, setMediaProperties
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

B4SFilter

public B4SFilter()
          throws org.xml.sax.SAXException
Method Detail

isMatch

public boolean isMatch(java.lang.String sniff_chars)
is the root element of the xml file indicate it's WinampXML? Note: do B4S files have namespaces?
Overrides:
isMatch in class PlaylistFilter

startElement

public void startElement(java.lang.String uri,
                         java.lang.String local_name,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Filter a start element event.
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl

endElement

public void endElement(java.lang.String uri,
                       java.lang.String local_name,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Filter an end element event.
Overrides:
endElement in class org.xml.sax.helpers.XMLFilterImpl


Copyright © 2002 Reed Esau, All Rights Reserved.