eXchaNGeR

org.xngr
Interface XDocument


public interface XDocument

The representation of a document for the xngr application. This implementation of this interface gives the service a reference to a document within the system and allows the service to save and get document specific parameters like the URL and the root element. It also allows for a listener to be added to listen for changes in the document.

Version:
$Revision: 1.2 $, $Date: 2002/08/19 20:06:34 $
Author:
Edwin Dankert

Method Summary
 void addListener(XDocumentListener listener)
          Adds a document listener to the document.
 void consistent()
          Checks to find out if this version of the document is consistent with the one saved on disk.
 void delete()
          Deletes the document from the eXchaNGeR application and informs the listeners about this.
 XElement getElement(String xpath)
          Gets an element from this document for the specified XPath expression.
 XElement[] getElements(String xpath)
          Gets a list of elements from this document for the specified XPath expression.
 String getName()
          Returns the name for this document.
 XElement getRoot()
          Returns the root element for this document.
 URL getURL()
          Returns the URL for this document.
 void load()
          Loads the document and informs the listeners about a potential complete update.
 void removeListener(XDocumentListener listener)
          Removes a document listener from the document.
 void save()
          Saves the document and informs the listeners about a potential complete update.
 void update(XElement element)
          Lets listeners know that the document has been updated.
 

Method Detail

getElement

public XElement getElement(String xpath)
Gets an element from this document for the specified XPath expression. Returns Null, if the element could not be found.
Parameters:
xpath - the XPath expression to the element.
Returns:
the element.

getElements

public XElement[] getElements(String xpath)
Gets a list of elements from this document for the specified XPath expression. Returns Null, if no element could be found.
Parameters:
xpath - the XPath expression to the element(s).
Returns:
the element(s).

getURL

public URL getURL()
Returns the URL for this document.
Returns:
the URL for this document.

getName

public String getName()
Returns the name for this document.
Returns:
the name for this document.

getRoot

public XElement getRoot()
Returns the root element for this document.
Returns:
the root element.

save

public void save()
          throws IOException
Saves the document and informs the listeners about a potential complete update.
Throws:
IOException - if the document cannot be saved.

load

public void load()
          throws IOException,
                 org.xml.sax.SAXParseException
Loads the document and informs the listeners about a potential complete update.
Throws:
IOException - if the document cannot be found.
org.xml.sax.SAXParseException - if the information in the document cannot be parsed.

delete

public void delete()
Deletes the document from the eXchaNGeR application and informs the listeners about this. The document does no longer contain valid information after this!

update

public void update(XElement element)
Lets listeners know that the document has been updated.
Parameters:
element - the root element for the changes in the elements.

consistent

public void consistent()
Checks to find out if this version of the document is consistent with the one saved on disk. Tries to find out if the document has been changed or deleted by an external process.

When the document has been changed or deleted by an external process the user is informed and forced to make a decision on wether to go on with the saved 'external' version or the current 'internal' version. This results in a documentUpdated() or documentDeleted() event being fired.


addListener

public void addListener(XDocumentListener listener)
Adds a document listener to the document. The listener is invoked when the document has been updated.
Parameters:
listener - the listener for changes in the document.

removeListener

public void removeListener(XDocumentListener listener)
Removes a document listener from the document.
Parameters:
listener - the listener for changes in the document.

eXchaNGeR

Copyright © 2002, Cladonia Ltd., All Rights Reserved