|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.essbase.eas.ui.editor.editpane.ReadOnlyDocument
public class ReadOnlyDocument
Nested Class Summary | |
---|---|
static class |
ReadOnlyDocument.LineOffset |
class |
ReadOnlyDocument.ReaderThread |
class |
ReadOnlyDocument.ReadOnlyElement |
class |
ReadOnlyDocument.ReadOnlyEvent |
static class |
ReadOnlyDocument.ReadOnlyPosition |
class |
ReadOnlyDocument.ReadOnlyRootElement |
Field Summary | |
---|---|
protected boolean |
cancelled |
protected boolean |
deleteFile |
protected int |
docLength |
protected javax.swing.event.EventListenerList |
listenerList |
protected ObjectBucketList |
offList |
protected java.util.Hashtable |
properties |
protected CRandomAccessFile |
rafContent |
protected TextFileReader |
reader |
protected ReadOnlyDocument.ReadOnlyRootElement |
root |
Fields inherited from interface javax.swing.text.Document |
---|
StreamDescriptionProperty, TitleProperty |
Constructor Summary | |
---|---|
ReadOnlyDocument(java.util.List list, javax.swing.JProgressBar bar) |
|
ReadOnlyDocument(java.lang.String text, javax.swing.JProgressBar bar) |
|
ReadOnlyDocument(TextFileReader reader) |
|
ReadOnlyDocument(TextFileReader reader, javax.swing.JProgressBar bar) |
Method Summary | |
---|---|
void |
addDocumentListener(javax.swing.event.DocumentListener listener) |
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener listener) Registers the given observer to begin receiving notifications when undoable edits are made to the document. |
int |
binarySearch(java.util.ArrayList list, long offset) |
int |
binarySearch(long offset) |
void |
cancelLoading() |
javax.swing.text.Position |
createPosition(int offs) This method allows an application to mark a place in a sequence of character content. |
void |
dispose() |
void |
fireInsert(int offset, int len) |
protected void |
fireInsertUpdate(javax.swing.event.DocumentEvent e) |
javax.swing.text.Element |
getDefaultRootElement() Returns the root element that views should be based upon, unless some other mechanism for assigning views to element structures is provided. |
javax.swing.text.Position |
getEndPosition() Returns a position that represents the end of the document. |
int |
getLength() Returns number of characters of content currently in the document. |
java.lang.Object |
getProperty(java.lang.Object key) Gets the properties associated with the document. |
javax.swing.text.Element[] |
getRootElements() Returns all of the root elements that are defined. |
javax.swing.text.Position |
getStartPosition() Returns a position that represents the start of the document. |
java.lang.String |
getText(int offset, int len) Fetches the text contained within the given portion of 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 string of content. |
void |
putProperty(java.lang.Object key, java.lang.Object value) Associates a property with the document. |
void |
remove(int offs, int len) Removes a portion of the content of the document. |
void |
removeDocumentListener(javax.swing.event.DocumentListener listener) Unregisters the given observer from the notification list so it will no longer receive change updates. |
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener listener) Unregisters the given observer from the notification list so it will no longer receive updates. |
void |
render(java.lang.Runnable r) This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. |
void |
setDeleteFileOnClose(boolean delete) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.swing.event.EventListenerList listenerList
protected ReadOnlyDocument.ReadOnlyRootElement root
protected CRandomAccessFile rafContent
protected ObjectBucketList offList
protected java.util.Hashtable properties
protected int docLength
protected boolean cancelled
protected boolean deleteFile
protected TextFileReader reader
Constructor Detail |
---|
public ReadOnlyDocument(TextFileReader reader)
public ReadOnlyDocument(TextFileReader reader, javax.swing.JProgressBar bar)
public ReadOnlyDocument(java.util.List list, javax.swing.JProgressBar bar)
public ReadOnlyDocument(java.lang.String text, javax.swing.JProgressBar bar)
Method Detail |
---|
public void fireInsert(int offset, int len)
protected void fireInsertUpdate(javax.swing.event.DocumentEvent e)
public int getLength()
getLength
in interface javax.swing.text.Document
public void addDocumentListener(javax.swing.event.DocumentListener listener)
addDocumentListener
in interface javax.swing.text.Document
public void removeDocumentListener(javax.swing.event.DocumentListener listener)
removeDocumentListener
in interface javax.swing.text.Document
listener
- the observer to registerDocument.addDocumentListener(javax.swing.event.DocumentListener)
public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
addUndoableEditListener
in interface javax.swing.text.Document
listener
- the observer to registerUndoableEditEvent
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
removeUndoableEditListener
in interface javax.swing.text.Document
listener
- the observer to registerUndoableEditEvent
public java.lang.Object getProperty(java.lang.Object key)
getProperty
in interface javax.swing.text.Document
key
- a non-null
property keyputProperty(Object, Object)
public void putProperty(java.lang.Object key, java.lang.Object value)
StreamDescriptionProperty
and TitleProperty
. Other properties, such as author, may also be defined.putProperty
in interface javax.swing.text.Document
key
- the non-null
property keyvalue
- the property valuegetProperty(Object)
public void remove(int offs, int len) throws javax.swing.text.BadLocationException
To ensure reasonable behavior in the face of concurrency, the event is dispatched after the mutation has occurred. This means that by the time a notification of removal is dispatched, the document has already been updated and any marks created by createPosition
have already changed. For a removal, the end of the removal range is collapsed down to the start of the range, and any marks in the removal range are collapsed down to the start of the range.
If the Document structure changed as result of the removal, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to a remove.
If the Document supports undo/redo, an UndoableEditEvent will also be generated.
remove
in interface javax.swing.text.Document
offs
- the offset from the beginning >= 0len
- the number of characters to remove >= 0javax.swing.text.BadLocationException
- some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered.DocumentEvent
, DocumentListener
, UndoableEditEvent
, UndoableEditListener
public void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
If the Document structure changed as result of the insertion, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to an insertion.
If the Document supports undo/redo, an UndoableEditEvent will also be generated.
insertString
in interface javax.swing.text.Document
offset
- the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move.str
- the string to inserta
- the attributes to associate with the inserted content. This may be null if there are no attributes.javax.swing.text.BadLocationException
- the given insert position is not a valid position within the documentDocumentEvent
, DocumentListener
, UndoableEditEvent
, UndoableEditListener
public java.lang.String getText(int offset, int len) throws javax.swing.text.BadLocationException
getText
in interface javax.swing.text.Document
offset
- the offset into the document representing the desired start of the text >= 0length
- the length of the desired string >= 0javax.swing.text.BadLocationException
- some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.public void getText(int offset, int length, javax.swing.text.Segment txt) throws javax.swing.text.BadLocationException
If the partialReturn property on the txt parameter is false, the data returned in the Segment will be the entire length requested and may or may not be a copy depending upon how the data was stored. If the partialReturn property is true, only the amount of text that can be returned without creating a copy is returned. Using partial returns will give better performance for situations where large parts of the document are being scanned. The following is an example of using the partial return to access the entire document:
int nleft = doc.getDocumentLength();
Segment text = new Segment();
int offs = 0;
text.setPartialReturn(true);
while (nleft > 0) {
doc.getText(offs, nleft, text);
// do someting with text
nleft -= text.count;
offs += text.count;
}
getText
in interface javax.swing.text.Document
offset
- the offset into the document representing the desired start of the text >= 0length
- the length of the desired string >= 0txt
- the Segment object to return the text injavax.swing.text.BadLocationException
- Some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.public javax.swing.text.Position getStartPosition()
getStartPosition
in interface javax.swing.text.Document
public javax.swing.text.Position getEndPosition()
getEndPosition
in interface javax.swing.text.Document
public javax.swing.text.Position createPosition(int offs) throws javax.swing.text.BadLocationException
createPosition
in interface javax.swing.text.Document
offs
- the offset from the start of the document >= 0javax.swing.text.BadLocationException
- if the given position does not represent a valid location in the associated documentpublic javax.swing.text.Element[] getRootElements()
Typically there will be only one document structure, but the interface supports building an arbitrary number of structural projections over the text data. The document can have multiple root elements to support multiple document structures. Some examples might be:
getRootElements
in interface javax.swing.text.Document
public javax.swing.text.Element getDefaultRootElement()
getDefaultRootElement
in interface javax.swing.text.Document
public int binarySearch(long offset)
public int binarySearch(java.util.ArrayList list, long offset)
public void render(java.lang.Runnable r)
render
in interface javax.swing.text.Document
r
- a Runnable used to render the modelpublic void cancelLoading()
public void setDeleteFileOnClose(boolean delete)
public void dispose()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |