org.embl.ebi.escience.scufl.view
Class XScuflView

java.lang.Object
  extended by org.embl.ebi.escience.scufl.view.XScuflView
All Implemented Interfaces:
java.io.Serializable, ScuflModelEventListener

public class XScuflView
extends java.lang.Object
implements ScuflModelEventListener, java.io.Serializable

Represents a ScuflModel instance as an XScufl document.

The view registers with the model to always provide updated XML representations.

Note that when you are finished using the view, you have to manually remove the listener from the model as:

   XScuflView view = new XScuflView(model);
   ..
   model.removeListener(view);
 
If you don't do this, the NotifyThread will be kept alive by the XScuflView, and the XScuflView by the list of listeners in NotifyThread. Indirectly that would mean even the ScuflModel is kept alive forever.

Use the static methods getDocument(ScuflModel model) and getXMLText(ScuflModel model) to avoid constructing the view and having to remember to remove the listener from the ScuflModel.

Author:
Tom Oinn, Stian Soiland
See Also:
Serialized Form

Constructor Summary
XScuflView(ScuflModel model)
          Construct the view and bind to the given model.
 
Method Summary
 org.jdom.Document getDocument()
          Get the XML Document from this view.
static org.jdom.Document getDocument(ScuflModel model)
          Get the XML Document for the model.
 java.lang.String getXMLText()
          Get the XML String from this view
static java.lang.String getXMLText(ScuflModel model)
          Get the XML representation as String for this model.
 void receiveModelEvent(ScuflModelEvent event)
          Invalidate cache on changed model (but don't recalculate the XML now)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XScuflView

public XScuflView(ScuflModel model)
Construct the view and bind to the given model.

Method Detail

getDocument

public org.jdom.Document getDocument()
Get the XML Document from this view.

This is probably preferable over getXMLText() if you are passing on the XML to another method expecting either Document or String.


getDocument

public static org.jdom.Document getDocument(ScuflModel model)
Get the XML Document for the model.

Use this static version of getXMLText() if you are only getting the XML once, and don't expect the model to change.

This is probably preferable over getXMLText(model) if you are passing on the XML to another method expecting either Document or String.


getXMLText

public java.lang.String getXMLText()
Get the XML String from this view


getXMLText

public static java.lang.String getXMLText(ScuflModel model)
Get the XML representation as String for this model. Use this static version of getXMLText() if you are only getting the XML once, and don't expect the model to change.


receiveModelEvent

public void receiveModelEvent(ScuflModelEvent event)
Invalidate cache on changed model (but don't recalculate the XML now)

Specified by:
receiveModelEvent in interface ScuflModelEventListener