|
|||||||||
| Home >> All >> org >> greenstone >> gatherer >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.greenstone.gatherer.util
Class AppendLineOnlyFileDocument

java.lang.Objectorg.greenstone.gatherer.util.AppendLineOnlyFileDocument
- All Implemented Interfaces:
- javax.swing.text.Document
- public class AppendLineOnlyFileDocument
- extends java.lang.Object
- implements javax.swing.text.Document
- extends java.lang.Object
A Document whose underlying data is stored in a RandomAccessFile, and whose Element implementations lack the memory hogging problems associated with anything that extends the AbstractDocument class. This Document, for reasons of time constraints and sanity, only provides an editting ability of appending new lines to the end of the current document, perfect for our logging needs, completely useless for text editing purposes. Furthermore, since the append actions tend to somewhat swamp the IO, I'll temporarily store strings in the structure model, and write them out using a separate thread.
| Nested Class Summary | |
private class |
AppendLineOnlyFileDocument.AppendLineOnlyFileDocumentElement
|
private class |
AppendLineOnlyFileDocument.AppendLineOnlyFileDocumentEvent
|
private class |
AppendLineOnlyFileDocument.AppendLineOnlyFileDocumentPosition
|
private class |
AppendLineOnlyFileDocument.WriterThread
|
| Field Summary | |
private java.util.HashMap |
cache
|
private static java.lang.String |
EMPTY_STR
|
private java.io.RandomAccessFile |
file
|
private static java.lang.String |
GLI_HEADER_STR
|
private long |
length
|
private javax.swing.event.EventListenerList |
listeners_list
|
private AppendLineOnlyFileDocumentOwner |
owner
|
private java.util.HashMap |
properties
|
private AppendLineOnlyFileDocument.AppendLineOnlyFileDocumentElement |
root_element
|
private AppendLineOnlyFileDocument.WriterThread |
writer
|
| Fields inherited from interface javax.swing.text.Document |
StreamDescriptionProperty, TitleProperty |
| Constructor Summary | |
AppendLineOnlyFileDocument(java.lang.String filename)
|
|
| Method Summary | |
void |
addDocumentListener(javax.swing.event.DocumentListener listener)
Adds a document listener for notification of any changes. |
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Adds an undo listener for notification of any changes. |
void |
appendLine(java.lang.String str)
Append some content after the document. |
javax.swing.text.Position |
createPosition(int offs)
Returns a position that will track change as the document is altered. |
javax.swing.text.Element |
getDefaultRootElement()
Gets the default root element for the document model. |
javax.swing.text.Position |
getEndPosition()
Returns the position that marks the end of the document. |
int |
getLength()
Returns the length of the data. |
int |
getLengthToNearestLine()
A version of get length which essentially returns the offset to the start of the last line in the document. |
java.lang.Object |
getProperty(java.lang.Object key)
Returns a document property with the specified key. |
javax.swing.text.Element[] |
getRootElements()
Gets all root elements defined. |
javax.swing.text.Position |
getStartPosition()
Returns the position that marks the beginning of the document content. |
java.lang.String |
getText(int offset,
int l)
Gets a sequence of text from the document. |
void |
getText(int offset,
int length,
javax.swing.text.Segment txt)
Fetches the text contained within the given portion of the document. |
void |
insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet a)
Inserts a piece of text with an AttributeSet at the specified offset. |
boolean |
isStillWriting()
|
static void |
main(java.lang.String[] args)
|
static void |
print(java.lang.String message)
|
void |
putProperty(java.lang.Object key,
java.lang.Object value)
Sets a document property. |
private java.lang.String |
read(long start_offset,
int l)
|
boolean |
ready()
|
void |
remove(int offs,
int len)
Removes some content from the document. |
void |
removeDocumentListener(javax.swing.event.DocumentListener listener)
Removes a DocumentListener from this Document. |
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Removes an undo listener. |
void |
render(java.lang.Runnable r)
Renders a runnable apparently. |
void |
setExit()
|
void |
setOwner(AppendLineOnlyFileDocumentOwner owner)
|
void |
setSpecialCharacter(char character)
To record the final state of the logging process we reserve a single character at the start of the file. |
private void |
write(long start_offset,
long end_offset,
java.lang.String str,
int l)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
EMPTY_STR
private static final java.lang.String EMPTY_STR
- See Also:
- Constant Field Values
GLI_HEADER_STR
private static final java.lang.String GLI_HEADER_STR
- See Also:
- Constant Field Values
root_element
private AppendLineOnlyFileDocument.AppendLineOnlyFileDocumentElement root_element
owner
private AppendLineOnlyFileDocumentOwner owner
listeners_list
private javax.swing.event.EventListenerList listeners_list
cache
private java.util.HashMap cache
properties
private java.util.HashMap properties
length
private long length
file
private java.io.RandomAccessFile file
writer
private AppendLineOnlyFileDocument.WriterThread writer
| Constructor Detail |
AppendLineOnlyFileDocument
public AppendLineOnlyFileDocument(java.lang.String filename)
| Method Detail |
addDocumentListener
public void addDocumentListener(javax.swing.event.DocumentListener listener)
- Adds a document listener for notification of any changes.
- Specified by:
addDocumentListenerin interfacejavax.swing.text.Document
appendLine
public void appendLine(java.lang.String str)
- Append some content after the document.
createPosition
public javax.swing.text.Position createPosition(int offs)
- Returns a position that will track change as the document is altered.
- Specified by:
createPositionin interfacejavax.swing.text.Document
getDefaultRootElement
public javax.swing.text.Element getDefaultRootElement()
- Gets the default root element for the document model.
- Specified by:
getDefaultRootElementin interfacejavax.swing.text.Document
getLength
public int getLength()
- Returns the length of the data.
- Specified by:
getLengthin interfacejavax.swing.text.Document
getLengthToNearestLine
public int getLengthToNearestLine()
- A version of get length which essentially returns the offset to the start of the last line in the document.
getProperty
public java.lang.Object getProperty(java.lang.Object key)
- Description copied from interface:
javax.swing.text.Document - Returns a document property with the specified key.
- Specified by:
getPropertyin interfacejavax.swing.text.Document
isStillWriting
public boolean isStillWriting()
getText
public java.lang.String getText(int offset, int l) throws javax.swing.text.BadLocationException
- Gets a sequence of text from the document.
- Specified by:
getTextin interfacejavax.swing.text.Document
getText
public void getText(int offset,
int length,
javax.swing.text.Segment txt)
throws javax.swing.text.BadLocationException
- Fetches the text contained within the given portion of the document.
- Specified by:
getTextin interfacejavax.swing.text.Document
putProperty
public void putProperty(java.lang.Object key, java.lang.Object value)
- Description copied from interface:
javax.swing.text.Document - Sets a document property.
- Specified by:
putPropertyin interfacejavax.swing.text.Document
ready
public boolean ready()
removeDocumentListener
public void removeDocumentListener(javax.swing.event.DocumentListener listener)
- Description copied from interface:
javax.swing.text.Document - Removes a DocumentListener from this Document.
- Specified by:
removeDocumentListenerin interfacejavax.swing.text.Document
setExit
public void setExit()
setOwner
public void setOwner(AppendLineOnlyFileDocumentOwner owner)
setSpecialCharacter
public void setSpecialCharacter(char character)
- To record the final state of the logging process we reserve a single character at the start of the file.
read
private java.lang.String read(long start_offset, int l) throws java.io.IOException
write
private void write(long start_offset,
long end_offset,
java.lang.String str,
int l)
throws java.io.IOException
addUndoableEditListener
public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
- Adds an undo listener for notification of any changes.
- Specified by:
addUndoableEditListenerin interfacejavax.swing.text.Document
getEndPosition
public javax.swing.text.Position getEndPosition()
- Description copied from interface:
javax.swing.text.Document - Returns the position that marks the end of the document.
- Specified by:
getEndPositionin interfacejavax.swing.text.Document
getRootElements
public javax.swing.text.Element[] getRootElements()
- Gets all root elements defined.
- Specified by:
getRootElementsin interfacejavax.swing.text.Document
getStartPosition
public javax.swing.text.Position getStartPosition()
- Description copied from interface:
javax.swing.text.Document - Returns the position that marks the beginning of the document
content.
- Specified by:
getStartPositionin interfacejavax.swing.text.Document
insertString
public void insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet a)
- Description copied from interface:
javax.swing.text.Document - Inserts a piece of text with an AttributeSet at the specified
offset.- Specified by:
insertStringin interfacejavax.swing.text.Document
remove
public void remove(int offs,
int len)
- Removes some content from the document.
- Specified by:
removein interfacejavax.swing.text.Document
removeUndoableEditListener
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
- Removes an undo listener.
- Specified by:
removeUndoableEditListenerin interfacejavax.swing.text.Document
render
public void render(java.lang.Runnable r)
- Renders a runnable apparently.
- Specified by:
renderin interfacejavax.swing.text.Document
public static void print(java.lang.String message)
main
public static void main(java.lang.String[] args)
|
|||||||||
| Home >> All >> org >> greenstone >> gatherer >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.greenstone.gatherer.util.AppendLineOnlyFileDocument