fi.hut.tml.xsmiles.content.xml
Class XMLContentHandler

java.lang.Object
  extended byfi.hut.tml.xsmiles.content.BaseContentHandler
      extended byfi.hut.tml.xsmiles.content.xml.XMLContentHandler
All Implemented Interfaces:
Media, ResourceReferencer, XSmilesContentHandler
Direct Known Subclasses:
HTMLContentHandler

public class XMLContentHandler
extends BaseContentHandler
implements XSmilesContentHandler

Handles application/xml

Author:
Mikko Honkala

Field Summary
protected  XMLDocument doc
          the XMLDocument of this contenthandler
 
Fields inherited from class fi.hut.tml.xsmiles.content.BaseContentHandler
connection, fBrowser, fClosed, fContainer, fDoc, fInputStream, fLink, fMLFCListener, fPrefetched, fPrimary, fShowControls, fStopped, referencedResources
 
Constructor Summary
XMLContentHandler()
           
 
Method Summary
protected  void activateDocument()
           
 void close()
          This will freeze all memory and references to this media.
protected  XMLDocument createDocument(BrowserWindow b, java.io.InputStream s, XLink l)
           
protected  void destroy()
           
protected  void fetch(java.io.InputStream stream, XLink url)
          fetches an resource
protected  XMLDocument fetchParseAndTransformDocument(XLink link, java.io.InputStream stream)
          this protected method uses XMLDocument to read the stream and tries to catch all exeptions
 java.io.InputStream getContentStream()
          get a stream to the content if possible This should read the contents from a cache if possible.
 java.lang.String getTitle()
          get the possible title (can be null)
protected  void initDocument()
           
 void pause()
          Pauses the media.
 void play()
          Plays the media.
 void prefetch()
          Prefetches media.
 void setContainer(java.awt.Container cont)
          Sets the container the media will be rendered in.
 void setZoom(double zoom)
          notify that the zoom level has changed.
 void stop()
          Stops the media.
 
Methods inherited from class fi.hut.tml.xsmiles.content.BaseContentHandler
addMediaListener, addResource, closeConnection, get, getContainer, getOriginalDuration, getOriginalHeight, getOriginalWidth, getPrimary, getResourceCount, getResourceReferencer, getResources, getXMLDocument, isStatic, setBounds, setBrowserWindow, setConnection, setInputStream, setMediaTime, setMLFCListener, setPrimary, setSoundVolume, setUrl, setURL, showControls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fi.hut.tml.xsmiles.content.XSmilesContentHandler
addMediaListener, get, getOriginalDuration, getOriginalHeight, getOriginalWidth, getPrimary, getResourceReferencer, getXMLDocument, isStatic, setBounds, setBrowserWindow, setConnection, setInputStream, setMediaTime, setMLFCListener, setPrimary, setSoundVolume, setUrl, setURL, showControls
 

Field Detail

doc

protected XMLDocument doc
the XMLDocument of this contenthandler

Constructor Detail

XMLContentHandler

public XMLContentHandler()
Method Detail

prefetch

public void prefetch()
              throws java.lang.Exception
Prefetches media. The URL must have been set using setUrl(). The data will be downloaded from the URL. After calling this method, the media will be in memory and can be played. This is a blocking method.

Specified by:
prefetch in interface XSmilesContentHandler
Overrides:
prefetch in class BaseContentHandler
Throws:
java.lang.Exception

play

public void play()
          throws java.lang.Exception
Plays the media. The media will be added to the container set using setContainer(). It will be visible. It will also play any animation it possibly has. Also, audio media is started using this method.

If the media is not yet prefetched, it will first be prefetched.

Specified by:
play in interface XSmilesContentHandler
Overrides:
play in class BaseContentHandler
Throws:
java.lang.Exception

pause

public void pause()
Description copied from interface: XSmilesContentHandler
Pauses the media. The media will stay visible, but any animations will be paused. Audio media will be silent. NOT IMPLEMENTED YET. ?How to restart paused media?

Specified by:
pause in interface XSmilesContentHandler
Overrides:
pause in class BaseContentHandler

stop

public void stop()
Stops the media. The media will be stopped and it will be invisible. Audio will be silent. It is possible to call start() after stop()

Specified by:
stop in interface XSmilesContentHandler
Overrides:
stop in class BaseContentHandler

close

public void close()
This will freeze all memory and references to this media. If the media is not yet stopped, it will first be stopped. It is not possible to call start() after close() has been called.

Specified by:
close in interface XSmilesContentHandler
Overrides:
close in class BaseContentHandler

fetch

protected void fetch(java.io.InputStream stream,
                     XLink url)
fetches an resource

Parameters:
url - the documents url, used for relative references
stream - the input stream of the content

initDocument

protected void initDocument()
                     throws java.lang.Exception
Throws:
java.lang.Exception

activateDocument

protected void activateDocument()
                         throws java.lang.Exception
Throws:
java.lang.Exception

createDocument

protected XMLDocument createDocument(BrowserWindow b,
                                     java.io.InputStream s,
                                     XLink l)

setContainer

public void setContainer(java.awt.Container cont)
Description copied from interface: XSmilesContentHandler
Sets the container the media will be rendered in. If media is audio, this can be null. Can be called if media is already visible in one container, it will then move to the new container.

Specified by:
setContainer in interface XSmilesContentHandler
Overrides:
setContainer in class BaseContentHandler

fetchParseAndTransformDocument

protected XMLDocument fetchParseAndTransformDocument(XLink link,
                                                     java.io.InputStream stream)
this protected method uses XMLDocument to read the stream and tries to catch all exeptions


destroy

protected void destroy()

setZoom

public void setZoom(double zoom)
notify that the zoom level has changed. Note that some content may choose to not implement zooming.

Specified by:
setZoom in interface XSmilesContentHandler
Overrides:
setZoom in class BaseContentHandler

getTitle

public java.lang.String getTitle()
Description copied from interface: XSmilesContentHandler
get the possible title (can be null)

Specified by:
getTitle in interface XSmilesContentHandler

getContentStream

public java.io.InputStream getContentStream()
Description copied from interface: XSmilesContentHandler
get a stream to the content if possible This should read the contents from a cache if possible. This is used for instance to save the content to a file Note that this could re-open the URL connection

Specified by:
getContentStream in interface XSmilesContentHandler
Overrides:
getContentStream in class BaseContentHandler


X-Smiles 1.2