< prev index next >

src/java.desktop/share/classes/javax/swing/text/PlainDocument.java

Print this page




  32  * the text.  The Element returned by getDefaultRootElement is
  33  * a map of the lines, and each child element represents a line.
  34  * This model does not maintain any character level attributes,
  35  * but each line can be tagged with an arbitrary set of attributes.
  36  * Line to offset, and offset to line translations can be quickly
  37  * performed using the default root element.  The structure information
  38  * of the DocumentEvent's fired by edits will indicate the line
  39  * structure changes.
  40  * <p>
  41  * The default content storage management is performed by a
  42  * gapped buffer implementation (GapContent).  It supports
  43  * editing reasonably large documents with good efficiency when
  44  * the edits are contiguous or clustered, as is typical.
  45  * <p>
  46  * <strong>Warning:</strong>
  47  * Serialized objects of this class will not be compatible with
  48  * future Swing releases. The current serialization support is
  49  * appropriate for short term storage or RMI between applications running
  50  * the same version of Swing.  As of 1.4, support for long term storage
  51  * of all JavaBeans&trade;
  52  * has been added to the <code>java.beans</code> package.
  53  * Please see {@link java.beans.XMLEncoder}.
  54  *
  55  * @author  Timothy Prinzing
  56  * @see     Document
  57  * @see     AbstractDocument
  58  */
  59 @SuppressWarnings("serial") // Same-version serialization only
  60 public class PlainDocument extends AbstractDocument {
  61 
  62     /**
  63      * Name of the attribute that specifies the tab
  64      * size for tabs contained in the content.  The
  65      * type for the value is Integer.
  66      */
  67     public static final String tabSizeAttribute = "tabSize";
  68 
  69     /**
  70      * Name of the attribute that specifies the maximum
  71      * length of a line, if there is a maximum length.
  72      * The type for the value is Integer.
  73      */
  74     public static final String lineLimitAttribute = "lineLimit";
  75 
  76     /**
  77      * Constructs a plain text document.  A default model using
  78      * <code>GapContent</code> is constructed and set.
  79      */
  80     public PlainDocument() {
  81         this(new GapContent());
  82     }
  83 
  84     /**
  85      * Constructs a plain text document.  A default root element is created,
  86      * and the tab size set to 8.
  87      *
  88      * @param c  the container for the content
  89      */
  90     public PlainDocument(Content c) {
  91         super(c);
  92         putProperty(tabSizeAttribute, Integer.valueOf(8));
  93         defaultRoot = createDefaultRoot();
  94     }
  95 
  96     /**
  97      * Inserts some content into the document.
  98      * Inserting content causes a write lock to be held while the




  32  * the text.  The Element returned by getDefaultRootElement is
  33  * a map of the lines, and each child element represents a line.
  34  * This model does not maintain any character level attributes,
  35  * but each line can be tagged with an arbitrary set of attributes.
  36  * Line to offset, and offset to line translations can be quickly
  37  * performed using the default root element.  The structure information
  38  * of the DocumentEvent's fired by edits will indicate the line
  39  * structure changes.
  40  * <p>
  41  * The default content storage management is performed by a
  42  * gapped buffer implementation (GapContent).  It supports
  43  * editing reasonably large documents with good efficiency when
  44  * the edits are contiguous or clustered, as is typical.
  45  * <p>
  46  * <strong>Warning:</strong>
  47  * Serialized objects of this class will not be compatible with
  48  * future Swing releases. The current serialization support is
  49  * appropriate for short term storage or RMI between applications running
  50  * the same version of Swing.  As of 1.4, support for long term storage
  51  * of all JavaBeans&trade;
  52  * has been added to the {@code java.beans} package.
  53  * Please see {@link java.beans.XMLEncoder}.
  54  *
  55  * @author  Timothy Prinzing
  56  * @see     Document
  57  * @see     AbstractDocument
  58  */
  59 @SuppressWarnings("serial") // Same-version serialization only
  60 public class PlainDocument extends AbstractDocument {
  61 
  62     /**
  63      * Name of the attribute that specifies the tab
  64      * size for tabs contained in the content.  The
  65      * type for the value is Integer.
  66      */
  67     public static final String tabSizeAttribute = "tabSize";
  68 
  69     /**
  70      * Name of the attribute that specifies the maximum
  71      * length of a line, if there is a maximum length.
  72      * The type for the value is Integer.
  73      */
  74     public static final String lineLimitAttribute = "lineLimit";
  75 
  76     /**
  77      * Constructs a plain text document.  A default model using
  78      * {@code GapContent} is constructed and set.
  79      */
  80     public PlainDocument() {
  81         this(new GapContent());
  82     }
  83 
  84     /**
  85      * Constructs a plain text document.  A default root element is created,
  86      * and the tab size set to 8.
  87      *
  88      * @param c  the container for the content
  89      */
  90     public PlainDocument(Content c) {
  91         super(c);
  92         putProperty(tabSizeAttribute, Integer.valueOf(8));
  93         defaultRoot = createDefaultRoot();
  94     }
  95 
  96     /**
  97      * Inserts some content into the document.
  98      * Inserting content causes a write lock to be held while the


< prev index next >