Changeset 6632
- Timestamp:
- 2004-01-28T14:39:40+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java
r6622 r6632 54 54 /** The current owner of this document, useful for callbacks when certain tasks are complete. */ 55 55 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; 56 58 /** A list of listeners attached to this document. */ 57 59 private EventListenerList listeners_list; … … 66 68 /** 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. */ 67 69 private WriterThread writer; 70 71 72 public AppendLineOnlyFileDocument(String filename) { 73 this(filename, true); 74 } 75 68 76 /** 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. 69 77 * @param filename the absolute path name of the file as a String … … 74 82 * @see org.greenstone.gatherer.util.StaticStrings#NEW_LINE_CHAR 75 83 */ 76 public AppendLineOnlyFileDocument(String filename ) {84 public AppendLineOnlyFileDocument(String filename, boolean build_log) { 77 85 Gatherer.println("Creating log: " + filename); 78 86 // Initialization 87 this.build_log = build_log; 79 88 this.filename = filename; 80 89 this.listeners_list = new EventListenerList(); … … 101 110 } 102 111 } 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) { 105 114 appendLine(GLI_HEADER_STR); 106 115 } … … 110 119 } 111 120 } 112 121 113 122 /** Adds a document listener for notification of any changes. 114 123 * @param listener the new DocumentListener to keep track of … … 338 347 */ 339 348 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 } 346 357 } 347 358 }
Note:
See TracChangeset
for help on using the changeset viewer.