|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Unsafe:
Field Summary | |
static String |
StreamDescriptionProperty
Suppressed: The property name for the description of the stream used to initialize the document. |
static String |
TitleProperty
Suppressed: The property name for the title of the document, if there is one. |
Method Summary | |
void |
addDocumentListener(DocumentListener listener)
Enabled: Registers the given observer to begin receiving notifications when changes are made to the document. |
void |
addUndoableEditListener(UndoableEditListener listener)
Enabled: Registers the given observer to begin receiving notifications when undoable edits are made to the document. |
Position |
createPosition(int offs)
Enabled: This method allows an application to mark a place in a sequence of character content. |
Element |
getDefaultRootElement()
Enabled: Returns the root element that views should be based upon, unless some other mechanism for assigning views to element structures is provided. |
Position |
getEndPosition()
Enabled: Returns a position that represents the end of the document. |
int |
getLength()
Enabled: Returns number of characters of content currently in the document. |
Object |
getProperty(Object key)
Suppressed: Gets the properties associated with the document. |
Element[] |
getRootElements()
Enabled: Returns all of the root elements that are defined. |
Position |
getStartPosition()
Enabled: Returns a position that represents the start of the document. |
String |
getText(int offset,
int length)
Enabled: Fetches the text contained within the given portion of the document. |
void |
getText(int offset,
int length,
Segment txt)
Enabled: Fetches the text contained within the given portion of the document. |
void |
insertString(int offset,
String str,
AttributeSet a)
Enabled: Inserts a string of content. |
void |
putProperty(Object key,
Object value)
Suppressed: Associates a property with the document. |
void |
remove(int offs,
int len)
Enabled: Removes a portion of the content of the document. |
void |
removeDocumentListener(DocumentListener listener)
Enabled: Unregisters the given observer from the notification list so it will no longer receive change updates. |
void |
removeUndoableEditListener(UndoableEditListener listener)
Enabled: Unregisters the given observer from the notification list so it will no longer receive updates. |
void |
render(Runnable r)
Suppressed: This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. |
Field Detail |
public static final String StreamDescriptionProperty
public static final String TitleProperty
Method Detail |
public int getLength()
public void addDocumentListener(DocumentListener listener)
listener
- the observer to registerremoveDocumentListener(javax.swing.event.DocumentListener)
public void removeDocumentListener(DocumentListener listener)
listener
- the observer to registeraddDocumentListener(javax.swing.event.DocumentListener)
public void addUndoableEditListener(UndoableEditListener listener)
listener
- the observer to registerjavax.swing.event.UndoableEditEvent
public void removeUndoableEditListener(UndoableEditListener listener)
listener
- the observer to registerjavax.swing.event.UndoableEditEvent
public Object getProperty(Object key)
key
- a non-null
property key
putProperty(Object, Object)
public void putProperty(Object key, Object value)
StreamDescriptionProperty
and
TitleProperty
.
Other properties, such as author, may also be defined.
key
- the non-null
property keyvalue
- the property valuegetProperty(Object)
public void remove(int offs, int len) throws 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.
offs
- the offset from the beginning >= 0len
- the number of characters to remove >= 0
BadLocationException
javax.swing.event.DocumentEvent
,
javax.swing.event.DocumentListener
,
javax.swing.event.UndoableEditEvent
,
javax.swing.event.UndoableEditListener
public void insertString(int offset, String str, AttributeSet a) throws 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.
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.
BadLocationException
javax.swing.event.DocumentEvent
,
javax.swing.event.DocumentListener
,
javax.swing.event.UndoableEditEvent
,
javax.swing.event.UndoableEditListener
public String getText(int offset, int length) throws BadLocationException
offset
- the offset into the document representing the desired
start of the text >= 0length
- the length of the desired string >= 0
BadLocationException
public void getText(int offset, int length, Segment txt) throws 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;
}
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 in
BadLocationException
public Position getStartPosition()
public Position getEndPosition()
public Position createPosition(int offs) throws BadLocationException
offs
- the offset from the start of the document >= 0
BadLocationException
public 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:
public Element getDefaultRootElement()
public void render(Runnable r)
r
- a Runnable used to render the model
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |