Changeset 6632


Ignore:
Timestamp:
2004-01-28T14:39:40+13:00 (20 years ago)
Author:
jmt12
Message:

In order to allow for other types of logs, the AppendLineOnlyFileDocument can now be created as a non-build script log. This is useful for the new mirroring stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r6622 r6632  
    5454    /** The current owner of this document, useful for callbacks when certain tasks are complete. */
    5555    private AppendLineOnlyFileDocumentOwner owner;
     56    /** Is this document a build log, and hence has some extra functionality, of just a straight log. */
     57    private boolean build_log = false;
    5658    /** A list of listeners attached to this document. */
    5759    private EventListenerList listeners_list;
     
    6668    /** An independant thread responsible for writing the 'in memory' contents of the document model to the random access file as appropriate. This is done so IO lag does not effect the gui as much as it used to. */
    6769    private WriterThread writer;
     70
     71   
     72    public AppendLineOnlyFileDocument(String filename) {
     73    this(filename, true);
     74    }
     75
    6876    /** The constructor is responsible for creating several necessary data structures as well as opening the random access file. When it creates the new file, as it is wont to do, it will immediately add the special header line defined above.
    6977     * @param filename the absolute path name of the file as a String
     
    7482     * @see org.greenstone.gatherer.util.StaticStrings#NEW_LINE_CHAR
    7583     */
    76     public AppendLineOnlyFileDocument(String filename) {
     84    public AppendLineOnlyFileDocument(String filename, boolean build_log) {
    7785    Gatherer.println("Creating log: " + filename);
    7886    // Initialization
     87    this.build_log = build_log;
    7988    this.filename = filename;
    8089    this.listeners_list = new EventListenerList();
     
    101110        }
    102111        }
    103         // If there we no lines found, then append the file header.
    104         if(root_element.getElementCount() == 0) {
     112        // If there we no lines found, and we are a build log, then append the file header.
     113        if(build_log && root_element.getElementCount() == 0) {
    105114        appendLine(GLI_HEADER_STR);
    106115        }
     
    110119    }
    111120    }
    112    
     121
    113122    /** Adds a document listener for notification of any changes.
    114123     * @param listener the new DocumentListener to keep track of
     
    338347     */
    339348    public synchronized void setSpecialCharacter(char character) {
    340     try {
    341         file.seek(0L);
    342         file.write((int)character);
    343     }
    344     catch (Exception error) {
    345         Gatherer.printStackTrace(error);
     349    if(build_log) {
     350        try {
     351        file.seek(0L);
     352        file.write((int)character);
     353        }
     354        catch (Exception error) {
     355        Gatherer.printStackTrace(error);
     356        }
    346357    }
    347358    }
Note: See TracChangeset for help on using the changeset viewer.