VdexReload 1.1.3 API

uk.ac.reload.moonunit.dom
Class ReloadDocument

java.lang.Object
  extended byuk.ac.reload.moonunit.dom.ReloadDocument
Direct Known Subclasses:
ReloadSchemaDocument

public abstract class ReloadDocument
extends java.lang.Object

This encapsulates the JDOM XML Document file with it plus helper methods.


Field Summary
protected  boolean _dirty
          A flag to set if this Document is dirty (edited)
protected  org.jdom.Document _doc
          The JDOM Document
protected  java.io.File _file
          The File for this Document - this may be null if not saved to disk
 
Constructor Summary
ReloadDocument()
          Default Constructor
ReloadDocument(java.io.File file, org.jdom.Document doc)
          Constructor that takes in a an XML filename, JDOM document and a ReloadSchemaController
 
Method Summary
 org.jdom.Document getDocument()
          Get the JDOM Metadata or Vocabulary Document.
 java.io.File getFile()
          Get the File of this Document.
 org.jdom.Element getRootElement()
          Get the Root Element of the JDOM Document
 org.jdom.Namespace getSchemaNamespace()
          Get the Schema Namespace of the Document if there is one
 boolean isDirty()
          Whether this Document has been changed in some way
 boolean isDocumentNamespace(org.jdom.Element element)
          Checks if element belongs to the namespace of this document
static boolean isMemberOfSameDocument(org.jdom.Element element1, org.jdom.Element element2)
          Checks of element1 and element2 belongs to the same document
 void loadDocument(java.io.File file)
          Load the JDOM Document File
 void saveAsDocument(java.io.File file)
          This will save the XML IMS file with a new File ref
 void saveDocument()
          This will save the XML IMS file with the existing File ref.
 void setDirty(boolean isDirty)
          Set whether this Document is dirty or not
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_doc

protected org.jdom.Document _doc
The JDOM Document


_dirty

protected boolean _dirty
A flag to set if this Document is dirty (edited)


_file

protected java.io.File _file
The File for this Document - this may be null if not saved to disk

Constructor Detail

ReloadDocument

public ReloadDocument()
Default Constructor


ReloadDocument

public ReloadDocument(java.io.File file,
                      org.jdom.Document doc)
Constructor that takes in a an XML filename, JDOM document and a ReloadSchemaController

Parameters:
file - the XML file, for example an IMS metadata or an IMS VDEX vocabulary file doc the JDOM document of the XML file
Method Detail

getDocument

public org.jdom.Document getDocument()
Get the JDOM Metadata or Vocabulary Document.

Returns:
The JDOM Document

getFile

public java.io.File getFile()
Get the File of this Document. This might be null.

Returns:
the file of this document, null otherwise

loadDocument

public void loadDocument(java.io.File file)
                  throws DweezilXMLException
Load the JDOM Document File

Parameters:
file - The XML File to read in
Throws:
DweezilXMLException

saveDocument

public void saveDocument()
                  throws ReloadDomException
This will save the XML IMS file with the existing File ref.

Throws:
ReloadDomException - if an error occurs

saveAsDocument

public void saveAsDocument(java.io.File file)
                    throws ReloadDomException
This will save the XML IMS file with a new File ref

Parameters:
file - The File to save as
Throws:
ReloadDomException - if an error occurs

isDirty

public boolean isDirty()
Whether this Document has been changed in some way

Returns:
true if the document is changed, false otherwise

setDirty

public void setDirty(boolean isDirty)
Set whether this Document is dirty or not

Parameters:
isDirty - true if the document is changed, false otherwise

getRootElement

public org.jdom.Element getRootElement()
Get the Root Element of the JDOM Document

Returns:
the Root Element of the JDOM Document, or null if none

getSchemaNamespace

public org.jdom.Namespace getSchemaNamespace()
Get the Schema Namespace of the Document if there is one

Returns:
the Schema Namespace of the Document if there is one, or null

isDocumentNamespace

public boolean isDocumentNamespace(org.jdom.Element element)
Checks if element belongs to the namespace of this document

Returns:
true if element belongs to the Namespace of this Document, false otherwise

isMemberOfSameDocument

public static boolean isMemberOfSameDocument(org.jdom.Element element1,
                                             org.jdom.Element element2)
Checks of element1 and element2 belongs to the same document

Returns:
true if element1 and element2 belong to the same Document, false otherwise

VdexReload 1.1.3 API