|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--editor.AbstractDocument
This class provides a skeleton implementation of Document interface abstracting from pattern syntax and semantic and using listIterator method to iterate over document's characters, wrapped by java.lang.Character objects
listIterator(int)
,
Character
Constructor Summary | |
AbstractDocument()
|
Method Summary | |
void |
clear()
Clears document content. |
void |
copy()
Overwrites the currently selected region to the clipboard. |
void |
copyAll()
Overwrites all document's content to the clipboard. |
void |
cut()
Removes the currently selected region and overwrites it to the clipboard. |
void |
cutAll()
Cut all document's content and overwrites it to clipboard. |
boolean |
isEmpty()
Returns true if document is empty. |
protected abstract ListIterator |
listIterator(int index)
This method returns an iterator over document's characters wrapped by java.lang.Character objects. |
boolean |
loopSearch(String p)
A version of search to be used in loop conditions. |
void |
open(Reader reader)
Reads document content from a characters-stream Reader. |
void |
paste()
Pastes the clipboard content to document, immediately following the current position. |
void |
put(String s)
Inserts a string after current position. |
void |
remove()
Removes current selection. |
boolean |
replace(String p,
String s)
Replaces the first occurrence of a pattern with a string. |
int |
replaceAll(String p,
String s)
Replaces all occurrences of a pattern with a string. |
void |
reset()
Moves current selection to (0,0). |
void |
save(Writer writer)
Saves document content into a characters-stream Writer. |
int |
size()
Return the number of characters composing this document. |
String |
toString()
Returns a String object representing document's content. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public AbstractDocument()
Method Detail |
public void cut()
public void cutAll()
cut()
public void paste()
public void copy()
public void copyAll()
copy()
public boolean replace(String p, String s)
pattern
- pattern to search for and replaces
- string to replace the first occurrence of pattern withpublic int replaceAll(String p, String s)
pattern
- pattern to search for and replaces
- string to replace the first occurrence of pattern withDocument.replace(java.lang.String, java.lang.String)
public void put(String s)
s
- string to insertpublic void remove()
public void reset()
public void clear()
public boolean loopSearch(String p)
doc.clear(); doc.put("aaaab"); while (doc.search("b")) { System.out.println("found: "+doc.clipboard); }will never end because after a successful searching, current position is at the end of document, so that next searching start again from position 0.
This method slightly modify search semantic returning false and moving current selection to (0,0) when invoked with current position set at the end of the document. Following code details new semantic:
public boolean loopSearch(String p) { if (getPosition()==size()) { reset(); // Document circularity return false; } return search(p); }
p
- pattern to search forDocument.search(java.lang.String)
public boolean isEmpty()
public int size()
public void open(Reader reader) throws IOException
reader
- Reader from which new document's content is readDocument.save(java.io.Writer)
public void save(Writer writer) throws IOException
writer
- Weader into which document's content is writtenDocument.open(java.io.Reader)
public String toString()
protected abstract ListIterator listIterator(int index)
Character
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |