Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.jsxe
Class DocumentBuffer

    java.lang.Object
      net.sourceforge.jsxe.dom.XMLDocument
          net.sourceforge.jsxe.DocumentBuffer

public class DocumentBuffer
extends XMLDocument

The DocumentBuffer class implements application specific properties of an XML document.

Version:
  $Id: DocumentBuffer.java 938 2006-06-09 03:12:01Z ian_lewis $
Author:
  Ian Lewis (IanLewis@member.fsf.org)

Field Summary
`static int` | `DIRTY` A status that indicates the file is dirty.

Fields inherited from class net.sourceforge.jsxe.dom.XMLDocument
`ENCODING, FORMAT_XML, INDENT, IS_USING_SOFT_TABS, IS_VALIDATING, LINE_SEPARATOR, WS_IN_ELEMENT_CONTENT`

Method Summary
`void` | `addDocumentBufferListener(DocumentBufferListener listener)` Adds a listener to this document buffer that is notified when the buffer is changed.
`boolean` | `close(TabbedView view, boolean confirmClose)` Performs closing tasks.
`boolean` | `equalsOnDisk(DocumentBuffer buffer)` Indicates if the DocumentBuffer given represents the same file on disk as the file used by this DocumentBuffer.
`boolean` | `equalsOnDisk(File file)` Indicates if the file given is the same file on disk as the file used by this DocumentBuffer are the same file on disk.
`protected void` | `fireStructureChanged(AdapterNode location)` Called when the structure of the document has changed.
`File` | `getFile()` Gets the File for this DocumentBuffer.
`String` | `getName()` Gets the name of the buffer.
`OptionPane` | `getOptionPane()` Gets the pane for editing options for this DocumentBuffer.
`boolean` | `getStatus(int statusType)` Gets a status for the DocumentBuffer, such as if it is dirty.
`boolean` | `isUntitled()` Gets whether this DocumentBuffer is untitled.
`boolean` | `reload(TabbedView view)` Reloads the file for this DocumentBuffer.
`void` | `removeDocumentBufferListener(DocumentBufferListener listener)` Removes a listener from this buffer.
`boolean` | `save(TabbedView view)` Saves the document buffer to disk in the current file.
`boolean` | `saveAs(TabbedView view)` Displays a save dialog that the user uses to chose a file to save to and saves the document to it.
`boolean` | `saveAs(TabbedView view, File file)` Saves the document to the given file.

Methods inherited from class net.sourceforge.jsxe.dom.XMLDocument
`addXMLDocumentListener, checkWellFormedness, entityDeclared, getAdapterNode, getAllowedEntities, getCompletionInfoMappings, getDocType, getDocumentCopy, getElementDecl, getEntityDecl, getErrors, getLength, getProperties, getProperty, getProperty, getRootElementNode, getSegment, getText, getURI, insertText, isValid, isWellFormed, newAdapterNode, newAdapterNode, parseDocument, parseWithoutUpdate, removeText, removeXMLDocumentListener, serialize, serializeNodeToString, setEntityResolver, setModel, setProperty, setURI`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DIRTY

    public static final int DIRTY

  A status that indicates the file is dirty.

  See Also:
    Constant Field Values

Method Detail

### close

    public boolean close(TabbedView view,
                         boolean confirmClose)
                  throws IOException

  Performs closing tasks. If the document is dirty then the user is prompted if they want to save.

  Parameters:
    `view` - the view that initiated the close
    `confirmClose` - true if the user is to confirm save
  Returns:
    true if the close is requested
  Throws:
    `IOException` - if the user chooses to save and the file could not be saved

### addDocumentBufferListener

    public void addDocumentBufferListener(DocumentBufferListener listener)

  Adds a listener to this document buffer that is notified when the buffer is changed.

  Parameters:
    `listener` - the listener that is notified when the buffer is changed

### removeDocumentBufferListener

    public void removeDocumentBufferListener(DocumentBufferListener listener)

  Removes a listener from this buffer. The listener will no longer recieve notifications when the buffer changes.

  Parameters:
    `listener` - the listener to remove

### getName

    public String getName()

  Gets the name of the buffer.

  Returns:
    the name of the buffer

### getFile

    public File getFile()

  Gets the File for this DocumentBuffer.

  Returns:
    the File where the document was stored on disk or null if the document is untitled and does not exist on disk.

### getStatus

    public boolean getStatus(int statusType)

  Gets a status for the DocumentBuffer, such as if it is dirty.

  Returns:
    true if the status for the type is set to true, false otherwise

### isUntitled

    public boolean isUntitled()

  Gets whether this DocumentBuffer is untitled.

  Returns:
    true if the document has no corresponding file on disk.

### reload

    public boolean reload(TabbedView view)
                   throws IOException

  Reloads the file for this DocumentBuffer. If the document is dirty then the user is prompted if they want to continue. If the user decides to cancel at that point then the reload is aborted and this method returns false.

  Parameters:
    `view` - the view that requested the reload operation
  Returns:
    true if the document was reloaded sucessfully
  Throws:
    `IOException`

### save

    public boolean save(TabbedView view)
                 throws IOException

  Saves the document buffer to disk in the current file. If the document is untitled the user is prompted for a file to save to.

  Parameters:
    `view` - the TabbedView that made this save request
  Returns:
    true if the save was successful and the used did not intervene. false if the user canceled the save.
  Throws:
    `IOException` - if the document could not be written due to an I/O error.

### saveAs

    public boolean saveAs(TabbedView view)
                   throws IOException

  Displays a save dialog that the user uses to chose a file to save to and saves the document to it.

  Parameters:
    `view` - the view that made the save request.
  Throws:
    `IOException` - if the document could not be written due to an I/O error.

### saveAs

    public boolean saveAs(TabbedView view,
                          File file)
                   throws IOException

  Saves the document to the given file. If the file is null then the user is prompted for a file to save to.

  Parameters:
    `view` - the TabbedView that requested this save
    `file` - the file to save the document to.
  Returns:
    true if the document was saved successfully the user did not intervene
  Throws:
    `IOException` - if the document could not be written due to an I/O error.

### equalsOnDisk

    public boolean equalsOnDisk(File file)
                         throws IOException

  Indicates if the file given is the same file on disk as the file used by this DocumentBuffer are the same file on disk.

  Parameters:
    `file` - the File to compare this DocumentBuffer's file against
  Returns:
    true if the file given is the same file on disk as the file used by this DocumentBuffer
  Throws:
    `IOException` - if the files cannot be compared due to an I/O error

### equalsOnDisk

    public boolean equalsOnDisk(DocumentBuffer buffer)
                         throws IOException

  Indicates if the DocumentBuffer given represents the same file on disk as the file used by this DocumentBuffer.

  Returns:
    true if the DocumentBuffer given uses the same file on disk as the file used by this DocumentBuffer
  Throws:
    `IOException` - if the files cannot be compared due to an I/O error

### getOptionPane

    public OptionPane getOptionPane()

  Gets the pane for editing options for this DocumentBuffer.

  Returns:
    the option pane specific to this DocumentBuffer

### fireStructureChanged

    protected void fireStructureChanged(AdapterNode location)

  Description copied from class: `XMLDocument`
  Called when the structure of the document has changed. This may be called in the event that specs that will alter how the document is serialized or parsed are changed.

  Overrides:
    `fireStructureChanged` in class `XMLDocument`
  Parameters:
    `location` - the location of the change. null if unknown

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD