org.merlotxml.merlot
Class XMLFile

java.lang.Object
  extended byorg.merlotxml.merlot.XMLFile
All Implemented Interfaces:
MerlotConstants
Direct Known Subclasses:
XMLEditorFile

public class XMLFile
extends java.lang.Object
implements MerlotConstants

An XML file. This provides an internface into a particular XML file, including its dtd and its file location. It provides methods for loading and parsing a file, saving a file, and accessing the content model in the dtd.

Author:
Kelly A. Campbell

Field Summary
protected  boolean _dirty
          Status holder for marking the file as needing a save
protected  ValidDocument _doc
          The parsed DOM document with validation
protected  org.w3c.dom.DocumentType _docType
          The document type (dtd)
protected  java.io.File _file
          The file on the filesystem
protected  boolean _new
          Status marker for brand new files so we can call saveas instead of save
protected  java.beans.PropertyChangeSupport _propchange
          property change delegate
 
Fields inherited from interface org.merlotxml.merlot.MerlotConstants
ACTION_MENU_ACCELERATOR, ACTION_MENU_ICON, ACTION_NAME, ACTION_SHORT_DESCRIPTION, ACTION_SMALL_ICON, AFTER, BEFORE, ERR, INTO, UI, XML
 
Constructor Summary
XMLFile()
          creates a new file with a blank Document tree
XMLFile(java.io.File f)
          Reads in the given filename to create the Document tree
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a feature to the PropertyChangeListener attribute of the XMLFile object
protected  void close()
           
protected  void close(java.io.File f)
           
 boolean elementIsValid(org.w3c.dom.Element el, boolean checkChildren)
          Description of the Method
 void firePropertyChange(java.lang.String s, boolean ov, boolean nv)
          Description of the Method
 org.w3c.dom.DocumentType getDoctype()
          Gets the doctype attribute of the XMLFile object
 org.w3c.dom.Document getDocument()
          Returns the DOM document for this file
 DTDDocument getDTD(java.lang.String name)
          Returns the main DTDDocument for this file
 java.util.Enumeration getDTDAttributes(java.lang.String elementName)
          Gets the dTDAttributes attribute of the XMLFile object
 DTDCacheEntry getDTDCacheEntry()
          returns the DTDCacheEntry for this document.
protected  java.io.InputStream getFileInputStream()
           
 java.util.Enumeration getInsertableElements(org.w3c.dom.Element el)
          Gets the insertableElements attribute of the XMLFile object
 java.util.Enumeration getInsertableElements(org.w3c.dom.Element el, int index)
          Gets the insertableElements attribute of the XMLFile object
static MerlotDOMNode getInstanciatedNode(org.w3c.dom.Node node)
          Gets the instanciatedNode attribute of the XMLFile class
 java.lang.String getName()
          Gets the name attribute of the XMLFile object
 java.lang.String getPath()
          Gets the path attribute of the XMLFile object
 ValidDocument getValidDocument()
          Returns the DOMLiaison ValidDocument wrapper for this file
 XMLEditorDoc getXMLEditorDoc()
           
 boolean isDirty()
          Gets the dirty attribute of the XMLFile object
 boolean isNew()
          returns the new property
protected  void parseDocument()
          Description of the Method
 void printRawXML(java.io.OutputStream s, boolean pretty)
          Description of the Method
static void putInstanciatedNode(org.w3c.dom.Node node, MerlotDOMNode mNode)
          Description of the Method
 void save()
          Saves in the same file we opened
 void saveAs(java.io.File f)
          Saves to a new file
 void setDirty(boolean tf)
          Sets the dirty attribute of the XMLFile object
 void setNew(boolean tf)
          Sets the new property
 void setXMLEditorDoc(XMLEditorDoc doc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_doc

protected ValidDocument _doc
The parsed DOM document with validation


_docType

protected org.w3c.dom.DocumentType _docType
The document type (dtd)


_file

protected java.io.File _file
The file on the filesystem


_dirty

protected boolean _dirty
Status holder for marking the file as needing a save


_new

protected boolean _new
Status marker for brand new files so we can call saveas instead of save


_propchange

protected java.beans.PropertyChangeSupport _propchange
property change delegate

Constructor Detail

XMLFile

public XMLFile(java.io.File f)
        throws MerlotException
Reads in the given filename to create the Document tree

Parameters:
f - Description of the Parameter
Throws:
MerlotException - Description of the Exception

XMLFile

public XMLFile()
        throws MerlotException
creates a new file with a blank Document tree

Throws:
MerlotException - Description of the Exception
Method Detail

setXMLEditorDoc

public void setXMLEditorDoc(XMLEditorDoc doc)

getXMLEditorDoc

public XMLEditorDoc getXMLEditorDoc()

getDocument

public org.w3c.dom.Document getDocument()
Returns the DOM document for this file

Returns:
The document value

getValidDocument

public ValidDocument getValidDocument()
Returns the DOMLiaison ValidDocument wrapper for this file

Returns:
The validDocument value

getDTD

public DTDDocument getDTD(java.lang.String name)
Returns the main DTDDocument for this file

Parameters:
name - Description of the Parameter
Returns:
The dTD value

getDTDCacheEntry

public DTDCacheEntry getDTDCacheEntry()
returns the DTDCacheEntry for this document. Useful to get access to the DTD plugin associated with this file

Returns:
The dTDCacheEntry value

setNew

public void setNew(boolean tf)
Sets the new property

Parameters:
tf - The new new value

isNew

public boolean isNew()
returns the new property

Returns:
The new value

getDoctype

public org.w3c.dom.DocumentType getDoctype()
Gets the doctype attribute of the XMLFile object

Returns:
The doctype value

parseDocument

protected void parseDocument()
                      throws MerlotException
Description of the Method

Throws:
MerlotException - Description of the Exception

getFileInputStream

protected java.io.InputStream getFileInputStream()
                                          throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

printRawXML

public void printRawXML(java.io.OutputStream s,
                        boolean pretty)
                 throws MerlotException
Description of the Method

Parameters:
s - Description of the Parameter
pretty - Description of the Parameter
Throws:
MerlotException - Description of the Exception

getName

public java.lang.String getName()
Gets the name attribute of the XMLFile object

Returns:
The name value

getPath

public java.lang.String getPath()
Gets the path attribute of the XMLFile object

Returns:
The path value

getDTDAttributes

public java.util.Enumeration getDTDAttributes(java.lang.String elementName)
Gets the dTDAttributes attribute of the XMLFile object

Parameters:
elementName - Description of the Parameter
Returns:
The dTDAttributes value

getInsertableElements

public java.util.Enumeration getInsertableElements(org.w3c.dom.Element el,
                                                   int index)
Gets the insertableElements attribute of the XMLFile object

Parameters:
el - Description of the Parameter
index - Description of the Parameter
Returns:
The insertableElements value

getInsertableElements

public java.util.Enumeration getInsertableElements(org.w3c.dom.Element el)
Gets the insertableElements attribute of the XMLFile object

Parameters:
el - Description of the Parameter
Returns:
The insertableElements value

elementIsValid

public boolean elementIsValid(org.w3c.dom.Element el,
                              boolean checkChildren)
Description of the Method

Parameters:
el - Description of the Parameter
checkChildren - Description of the Parameter
Returns:
Description of the Return Value

setDirty

public void setDirty(boolean tf)
Sets the dirty attribute of the XMLFile object

Parameters:
tf - The new dirty value

isDirty

public boolean isDirty()
Gets the dirty attribute of the XMLFile object

Returns:
The dirty value

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a feature to the PropertyChangeListener attribute of the XMLFile object

Parameters:
l - The feature to be added to the PropertyChangeListener attribute

firePropertyChange

public void firePropertyChange(java.lang.String s,
                               boolean ov,
                               boolean nv)
Description of the Method

Parameters:
s - Description of the Parameter
ov - Description of the Parameter
nv - Description of the Parameter

save

public void save()
          throws MerlotException
Saves in the same file we opened

Throws:
MerlotException - Description of the Exception

saveAs

public void saveAs(java.io.File f)
            throws MerlotException
Saves to a new file

Parameters:
f - Description of the Parameter
Throws:
MerlotException - Description of the Exception

close

protected void close()

close

protected void close(java.io.File f)

putInstanciatedNode

public static void putInstanciatedNode(org.w3c.dom.Node node,
                                       MerlotDOMNode mNode)
Description of the Method

Parameters:
node - Description of the Parameter
mNode - Description of the Parameter

getInstanciatedNode

public static MerlotDOMNode getInstanciatedNode(org.w3c.dom.Node node)
Gets the instanciatedNode attribute of the XMLFile class

Parameters:
node - Description of the Parameter
Returns:
The instanciatedNode value