|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Document interface must be implemented by all Editor implementations wishing to share a common clipboard.
EditorDocument
Field Summary | |
static Document |
clipboard
A common clipboard for classes implementing this interface. |
Method Summary | |
void |
clear()
Clears document content. |
void |
copy()
Overwrites the currently selected region to the clipboard. |
void |
cut()
Removes the currently selected region and overwrites it to the clipboard. |
boolean |
getCaseSensitive()
Returns search and match sensitivity to characters case. |
int |
getPosition()
Get current position. |
int |
getStartPoint()
Get current start position. |
boolean |
isEmpty()
Returns true if document is empty. |
boolean |
loopSearch(String p)
A version of search to be used in loop conditions. |
boolean |
match(String pattern)
Matches a pattern starting from current position. |
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 pattern,
String s)
Replaces the first occurrence 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. |
boolean |
search(String pattern)
Searches for the next occurrence of pattern starting. |
void |
setCaseSensitive(boolean cs)
Set search and match sensitivity to characters case. |
void |
setPosition(int index)
Set current position (right delimeter of current selection). |
void |
setStartPoint(int index)
Set current start position (left delimeter of current selection). |
int |
size()
Return the number of characters composing this document. |
String |
toString()
Returns a String object representing document's content. |
Field Detail |
public static final Document clipboard
Method Detail |
public void cut()
copy()
,
paste()
public void copy()
cut()
,
paste()
public void paste()
copy()
,
cut()
public boolean replace(String pattern, String s)
pattern
- pattern to search for and replaces
- string to replace the first occurrence of pattern withpublic 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 to solve this problem.
p
- pattern to search forsearch(java.lang.String)
public boolean search(String pattern)
pattern
- the pattern to search forloopSearch(java.lang.String)
public boolean match(String pattern)
This method is useful for incrementally delimit a region starting from a given position.
pattern
- the pattern to matchpublic void setPosition(int index)
index
- new current position to setpublic int getPosition()
public void setStartPoint(int index)
index
- new start positionpublic int getStartPoint()
public int size()
public boolean isEmpty()
public void open(Reader reader) throws IOException
reader
- Reader from which new document's content is readsave(java.io.Writer)
public void save(Writer writer) throws IOException
writer
- Weader into which document's content is writtenopen(java.io.Reader)
public void setCaseSensitive(boolean cs)
match(java.lang.String)
,
search(java.lang.String)
public boolean getCaseSensitive()
match(java.lang.String)
,
search(java.lang.String)
public String toString()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |