Java Reference
In-Depth Information
Although this particular document might not warrant it, multiple element hierarchies are
possible. Each would store different attributes because a particular text component could have
an alternative rendering of the content. Alternatively, different style sheets could be used to
render the same HTML markup differently.
AbstractDocument Class
The AbstractDocument class provides the basic implementation of the Document interface. It
defines the management of the listener lists, provides a read-write locking mechanism to
ensure that content isn't corrupted, and enables a Dictionary for storing document properties.
Table 15-3 lists the 11 properties of the AbstractDocument class, of which 5 are defined by
the Document interface itself.
Table 15-3. AbstractDocument Properties
Property Name
Data Type
Access
asynchronousLoadPriority *
int
Read-write
bidiRootElement *
Element
Read-only
defaultRootElement
Element
Read-only
documentFilter *
DocumentFilter
Read-write
documentListeners *
DocumentListener[ ]
Read-only
documentProperties *
Dictionary
Read-write
endPosition
Position
Read-only
length
int
Read-only
rootElements
Element[ ]
Read-only
startPosition
Position
Read-only
undoableEditListeners *
UndoableEditListener[ ]
Read-only
* These properties are specific to the AbstractDocument class. The remaining five properties are defined in the
Document interface.
For the most part, you don't access any of these properties directly, except perhaps
documentFilter . In the case of the documentProperties property, you get and set individual prop-
erties with the public Object getProperty(Object key) and public void putProperty(Object key,
Object value) methods. For the length property, in most cases, you can simply ask for the text
within a text component, and then get its length by using textComponent.getText().length() .
The bidiRootElement property is for the bidirectional root element, which may be appro-
priate in certain Unicode character sets. You would normally just use the defaultRootElement .
However, both are rarely accessed.
Search WWH ::




Custom Search