Home » openjdk-7 » javax » swing » text » [javadoc | source]
public class: PlainDocument [javadoc | source]

All Implemented Interfaces:
    Document, Serializable

Direct Known Subclasses:
    FloatNumberDocument, AutoCompleteDocument, BealeDocument, TextAreaDocument, DateDocument, CyrillicDocument, NumberDocument, UpperCaseDocument, NumericPlainDocument, NumberDocument, NumberDocument, JTextFieldValidation, FixedLengthDocument, CompilableStringDocument, NumberDocument

A plain document that maintains no character attributes. The default element structure for this document is a map of the lines in the text. The Element returned by getDefaultRootElement is a map of the lines, and each child element represents a line. This model does not maintain any character level attributes, but each line can be tagged with an arbitrary set of attributes. Line to offset, and offset to line translations can be quickly performed using the default root element. The structure information of the DocumentEvent's fired by edits will indicate the line structure changes.

The default content storage management is performed by a gapped buffer implementation (GapContent). It supports editing reasonably large documents with good efficiency when the edits are contiguous or clustered, as is typical.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .

Field Summary
public static final  String tabSizeAttribute    Name of the attribute that specifies the tab size for tabs contained in the content. The type for the value is Integer. 
public static final  String lineLimitAttribute    Name of the attribute that specifies the maximum length of a line, if there is a maximum length. The type for the value is Integer. 
Fields inherited from javax.swing.text.AbstractDocument:
listenerList,  BAD_LOCATION,  ParagraphElementName,  ContentElementName,  SectionElementName,  BidiElementName,  ElementNameAttribute,  I18NProperty,  MultiByteProperty,  AsyncLoadPriority
 public PlainDocument() 
 public PlainDocument(Content c) 
Method from javax.swing.text.PlainDocument Summary:
createDefaultRoot,   getDefaultRootElement,   getParagraphElement,   insertString,   insertUpdate,   removeUpdate
Methods from javax.swing.text.AbstractDocument:
addDocumentListener,   addUndoableEditListener,   createBranchElement,   createLeafElement,   createPosition,   dump,   fireChangedUpdate,   fireInsertUpdate,   fireRemoveUpdate,   fireUndoableEditUpdate,   getAsynchronousLoadPriority,   getAttributeContext,   getBidiRootElement,   getContent,   getCurrentWriter,   getDefaultRootElement,   getDocumentFilter,   getDocumentListeners,   getDocumentProperties,   getEndPosition,   getLength,   getListeners,   getParagraphElement,   getProperty,   getRootElements,   getStartPosition,   getText,   getText,   getUndoableEditListeners,   handleInsertString,   handleRemove,   insertString,   insertUpdate,   isLeftToRight,   postRemoveUpdate,   putProperty,   readLock,   readUnlock,   remove,   removeDocumentListener,   removeUndoableEditListener,   removeUpdate,   render,   replace,   setAsynchronousLoadPriority,   setDocumentFilter,   setDocumentProperties,   updateBidi,   writeLock,   writeUnlock
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.PlainDocument Detail:
 protected AbstractElement createDefaultRoot() 
    Creates the root element to be used to represent the default document structure.
 public Element getDefaultRootElement() 
    Gets the default root element for the document model.
 public Element getParagraphElement(int pos) 
    Get the paragraph element containing the given position. Since this document only models lines, it returns the line instead.
 public  void insertString(int offs,
    String str,
    AttributeSet a) throws BadLocationException 
    Inserts some content into the document. Inserting content causes a write lock to be held while the actual changes are taking place, followed by notification to the observers on the thread that grabbed the write lock.

    This method is thread safe, although most Swing methods are not. Please see How to Use Threads for more information.

 protected  void insertUpdate(DefaultDocumentEvent chng,
    AttributeSet attr) 
    Updates document structure as a result of text insertion. This will happen within a write lock. Since this document simply maps out lines, we refresh the line map.
 protected  void removeUpdate(DefaultDocumentEvent chng) 
    Updates any document structure as a result of text removal. This will happen within a write lock. Since the structure represents a line map, this just checks to see if the removal spans lines. If it does, the two lines outside of the removal area are joined together.