Class Overview
DocumentFilter
, as the name implies, is a filter for the
Document
mutation methods. When a Document
containing a DocumentFilter
is modified (either through
insert
or remove
), it forwards the appropriate
method invocation to the DocumentFilter
. The
default implementation allows the modification to
occur. Subclasses can filter the modifications by conditionally invoking
methods on the superclass, or invoking the necessary methods on
the passed in FilterBypass
. Subclasses should NOT call back
into the Document for the modification
instead call into the superclass or the FilterBypass
.
When remove
or insertString
is invoked
on the DocumentFilter
, the DocumentFilter
may callback into the
FilterBypass
multiple times, or for different regions, but
it should not callback into the FilterBypass
after returning
from the remove
or insertString
method.
Summary
Nested Classes |
class |
DocumentFilter.FilterBypass |
Used as a way to circumvent calling back into the Document to
change it. |
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Public Constructors
Public Methods
Invoked prior to insertion of text into the
specified Document. Subclasses that want to conditionally allow
insertion should override this and only call supers implementation as
necessary, or call directly into the FilterBypass.
Parameters
fb
| FilterBypass that can be used to mutate 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. |
string
| the string to insert |
attr
| the attributes to associate with the inserted
content. This may be null if there are no attributes. |
Invoked prior to removal of the specified region in the
specified Document. Subclasses that want to conditionally allow
removal should override this and only call supers implementation as
necessary, or call directly into the FilterBypass
as
necessary.
Parameters
fb
| FilterBypass that can be used to mutate Document |
offset
| the offset from the beginning >= 0 |
length
| the number of characters to remove >= 0 |
Throws
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.
|
Invoked prior to replacing a region of text in the
specified Document. Subclasses that want to conditionally allow
replace should override this and only call supers implementation as
necessary, or call directly into the FilterBypass.
Parameters
fb
| FilterBypass that can be used to mutate Document |
offset
| Location in Document |
length
| Length of text to delete |
text
| Text to insert, null indicates no text to insert |
attrs
| AttributeSet indicating attributes of inserted text,
null is legal. |