Higraph, v1.0, January 29, 2003 (02:21 PM)

uk.ac.ed.inf.higraph
Class HigraphXml

java.lang.Object
  |
  +--uk.ac.ed.inf.higraph.HigraphXml
All Implemented Interfaces:
HigraphConstants

public class HigraphXml
extends Object
implements HigraphConstants

XML wrapper for Higraph - a bridge between JDOM Elements and Higraphs.


Nested Class Summary
protected  class HigraphXml.SAXErrorHandler
          Extends MySAXErrorHandler by intercepting exceptions signalling that the document does not conform to the DTD and setting the dtdNotValid flag accordingly.
 
Field Summary
 
Fields inherited from interface uk.ac.ed.inf.higraph.HigraphConstants
AUTHORS, AUTHORS_EMAIL, BGROUND, BLOB_TAG, BLOBS_TAG, BROWSER_LOCATION, BUGS_HTML, DARKER_BGROUND, DB_DRIVER, DEFAULT_BACKGROUND, DEFAULT_BORDER_COLOR, DEFAULT_BOUNDS, DEFAULT_CANVAS_BOUNDS, DEFAULT_NEW_LOCATION, DEFAULT_OPAQUE, DEFAULT_VERTEX_SIZE, EDGE_TAG, EDGES_TAG, EDITOR_MARGIN, FILE_SEPARATOR, GEOMETRY_TAG, HEIGHT_ATTR_TAG, HIGRAPH_DTD, HIGRAPH_TAG, HIGRAPHED_URL, ID_ATTR_TAG, JAVA_PUB_URL, JAVASRC, LABEL_ATTR_TAG, MANUAL_HTML, MANUAL_MESSAGE, MIN_BLOB_HEIGHT, MIN_BLOB_WIDTH, OVERVIEW_HTML, PACKAGE_DIR, PROJECT_DESCRIPTION, PROJECT_NAME, PROJECT_URL, SAVES, SAX_PARSER, SHRINKING_FACTOR, SOURCE_ATTR_TAG, TARGET_ATTR_TAG, TEST_DIR, TEST_GEOMETRY_FILE, TEST_XML_LOAD_FILE, TEST_XML_STORE_FILE, TEST_XML_STORE2_FILE, USER_HOME, UTF_ENCODING, WIDTH_ATTR_TAG, X_ATTR_TAG, XML_DIR, Y_ATTR_TAG
 
Constructor Summary
HigraphXml()
          Creates a new HigraphXml instance setting the value of this.higraph to a new Higraph
HigraphXml(File file)
          Creates a new HigraphXml instance from the XML representation stored in file.
HigraphXml(Higraph higraph)
          Creates a new HigraphXml instance setting the value of this.higraph to higraph.
 
Method Summary
 Document getDocument()
          Gets the value of document.
 Higraph getHigraph()
          Gets the value of higraph.
 XMLOutputter getOutputter()
          Returns a validating XMLOutputter, creating it if it does not already exist.
protected  boolean isDtdNotValid()
          Returns true when the parsed document does not conform to HigraphConstants.HIGRAPH_DTD.
 void load(File file)
          It displays the higraph stored as XML in file.
 Document parse(File file)
          Parses file using SAXBuilder and HigraphXml.SAXErrorHandler.
protected  void setBlobs(Element blobsEl)
          Sets the blobs of higraph using blobsEl.
protected  void setDocument(Document v)
          Sets the value of document.
protected  void setEdges(Element edgesEl)
          Sets the edges of higraph using edgesEl.
protected  void setHigraph(Higraph v)
          Sets the value of higraph.
 void storeTo(File file)
          Builds the XML document corresponding to higraph and saves it to file.
 Document toXmlDocument()
          Builds and returns the XML Document corresponding to higraph.
 Element toXmlElement()
          Returns the XML Element corresponding to higraph by taking the root element of toXmlDocument().
 String toXmlString()
          Returns the String corresponding to the XML Element produced by toXmlElement().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HigraphXml

public HigraphXml(Higraph higraph)
Creates a new HigraphXml instance setting the value of this.higraph to higraph.

Parameters:
higraph - a Higraph value

HigraphXml

public HigraphXml()
Creates a new HigraphXml instance setting the value of this.higraph to a new Higraph


HigraphXml

public HigraphXml(File file)
           throws MyXmlLoadException
Creates a new HigraphXml instance from the XML representation stored in file.

Parameters:
file - a File value consisting of an XML document
Throws:
MyXmlLoadException - if an error occurs
Method Detail

getDocument

public Document getDocument()
Gets the value of document.

Returns:
value of document.

setDocument

protected void setDocument(Document v)
Sets the value of document.

Parameters:
v - Value to assign to document.

getHigraph

public Higraph getHigraph()
Gets the value of higraph.

Returns:
value of higraph.

setHigraph

protected void setHigraph(Higraph v)
Sets the value of higraph.

Parameters:
v - Value to assign to higraph.

isDtdNotValid

protected boolean isDtdNotValid()
Returns true when the parsed document does not conform to HigraphConstants.HIGRAPH_DTD.

Returns:
true when the parsed document does not conform to HigraphConstants.HIGRAPH_DTD.

getOutputter

public XMLOutputter getOutputter()
Returns a validating XMLOutputter, creating it if it does not already exist.

Returns:
a validating XMLOutputter, creating it if it does not already exist

load

public void load(File file)
          throws MyXmlLoadException
It displays the higraph stored as XML in file. Bug: it does not handle edges properly yet!

Parameters:
file - a File consisting of an XML document
Throws:
MyXmlLoadException - if an error occurs

parse

public Document parse(File file)
               throws JDOMException
Parses file using SAXBuilder and HigraphXml.SAXErrorHandler.

Parameters:
file - a File value
Returns:
the parsed file as a Document value
Throws:
JDOMException - if an error occurs

setBlobs

protected void setBlobs(Element blobsEl)
Sets the blobs of higraph using blobsEl.

Parameters:
blobsEl - an Element value

setEdges

protected void setEdges(Element edgesEl)
Sets the edges of higraph using edgesEl.

Parameters:
edgesEl - an Element value

toXmlDocument

public Document toXmlDocument()
Builds and returns the XML Document corresponding to higraph.

Returns:
the XML Document corresponding to higraph

toXmlString

public String toXmlString()
Returns the String corresponding to the XML Element produced by toXmlElement().

Returns:
the String corresponding to the XML Element produced by toXmlElement()

toXmlElement

public Element toXmlElement()
Returns the XML Element corresponding to higraph by taking the root element of toXmlDocument().

Returns:
the XML Element corresponding to higraph

storeTo

public void storeTo(File file)
             throws MyXmlStoreException
Builds the XML document corresponding to higraph and saves it to file. If file exists the file is first backed up in emacs style.

Parameters:
file - the File where the higraph is stored
Throws:
MyXmlStoreException - if an error occurs

Higraph, v1.0, January 29, 2003 (02:21 PM)

Copyright © The University of Edinburgh. All Rights Reserved.