ccs.xml
Class XSPFFile

java.lang.Object
  extended by ccs.xml.XSPFFile

public class XSPFFile
extends java.lang.Object

A low-level wrapper for a generic XSPF. This will read and write an XSPF DOM, and locate various elements which are likely to be of use, if they're there. The rest is up to you. Although not abstract, it is intended to be subclassed.


Field Summary
protected  javax.xml.parsers.DocumentBuilder builder
          The DocumentBuilder which read this.
protected  java.lang.String title
          The title of the complete playlist.
protected  org.w3c.dom.NodeList tracks
          The list of track elements.
protected  org.w3c.dom.Document tree
          The complete XSPF document.
 
Constructor Summary
XSPFFile()
          Create an XSPF file.
 
Method Summary
protected  org.w3c.dom.Element getPlaylist(org.w3c.dom.Document tree)
          returns the <playlist> element.
 java.lang.String getTitle()
          The title, after the XSPF has been read.
protected  org.w3c.dom.Element getTrackLocation(int idx)
          Utility method.
protected  org.w3c.dom.Element getTrackTitle(int idx)
          Utility method.
 void readFrom(java.io.InputStream src)
          Read in the XSPF.
 void writeTo(java.io.OutputStream tgt)
          Write the DOM tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

title

protected java.lang.String title
The title of the complete playlist. This is effectively read-only; if you change it, the change does not propagate to the DOM and will not be written.


tree

protected org.w3c.dom.Document tree
The complete XSPF document. The contents of this can be written using writeTo.


tracks

protected org.w3c.dom.NodeList tracks
The list of track elements.


builder

protected javax.xml.parsers.DocumentBuilder builder
The DocumentBuilder which read this. You probably won't need it.

Constructor Detail

XSPFFile

public XSPFFile()
Create an XSPF file. Before use, you must read in some data using readFrom.

Method Detail

readFrom

public void readFrom(java.io.InputStream src)
              throws java.io.IOException
Read in the XSPF.

Parameters:
src - Where to read it from.
Throws:
java.io.IOException

getTitle

public java.lang.String getTitle()
The title, after the XSPF has been read.


writeTo

public void writeTo(java.io.OutputStream tgt)
             throws java.io.IOException
Write the DOM tree.

Parameters:
tgt - The stream to write to.
Throws:
java.io.IOException

getPlaylist

protected org.w3c.dom.Element getPlaylist(org.w3c.dom.Document tree)
returns the <playlist> element. This is the outer element within the document. Utility method.

Returns:
The playlist.

getTrackTitle

protected org.w3c.dom.Element getTrackTitle(int idx)
Utility method. Find the element which is the title of the specified track, if there is one. Else null.

Parameters:
idx - The index of the track within the track list.
Returns:
The track title element.

getTrackLocation

protected org.w3c.dom.Element getTrackLocation(int idx)
Utility method. Find the element which is the location of the specified track, if there is one. Else null.