< prev index next >

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

Print this page
rev 60127 : 8249205: Remove unnecessary trademark symbols


  74  * and not access the component lock if trying to be safe from deadlocks.
  75  * The <code>repaint</code> and <code>revalidate</code> methods
  76  * on JComponent are safe.
  77  * <p>
  78  * AbstractDocument models an implied break at the end of the document.
  79  * Among other things this allows you to position the caret after the last
  80  * character. As a result of this, <code>getLength</code> returns one less
  81  * than the length of the Content. If you create your own Content, be
  82  * sure and initialize it to have an additional character. Refer to
  83  * StringContent and GapContent for examples of this. Another implication
  84  * of this is that Elements that model the implied end character will have
  85  * an endOffset == (getLength() + 1). For example, in DefaultStyledDocument
  86  * <code>getParagraphElement(getLength()).getEndOffset() == getLength() + 1
  87  * </code>.
  88  * <p>
  89  * <strong>Warning:</strong>
  90  * Serialized objects of this class will not be compatible with
  91  * future Swing releases. The current serialization support is
  92  * appropriate for short term storage or RMI between applications running
  93  * the same version of Swing.  As of 1.4, support for long term storage
  94  * of all JavaBeans&trade;
  95  * has been added to the <code>java.beans</code> package.
  96  * Please see {@link java.beans.XMLEncoder}.
  97  *
  98  * @author  Timothy Prinzing
  99  */
 100 @SuppressWarnings("serial") // Same-version serialization only
 101 public abstract class AbstractDocument implements Document, Serializable {
 102 
 103     /**
 104      * Constructs a new <code>AbstractDocument</code>, wrapped around some
 105      * specified content storage mechanism.
 106      *
 107      * @param data the content
 108      */
 109     protected AbstractDocument(Content data) {
 110         this(data, StyleContext.getDefaultStyleContext());
 111     }
 112 
 113     /**
 114      * Constructs a new <code>AbstractDocument</code>, wrapped around some


1758          * would call this in its finalize method.
1759          *
1760          * @param a the attribute set to reclaim
1761          */
1762         public void reclaim(AttributeSet a);
1763     }
1764 
1765     /**
1766      * Implements the abstract part of an element.  By default elements
1767      * support attributes by having a field that represents the immutable
1768      * part of the current attribute set for the element.  The element itself
1769      * implements MutableAttributeSet which can be used to modify the set
1770      * by fetching a new immutable set.  The immutable sets are provided
1771      * by the AttributeContext associated with the document.
1772      * <p>
1773      * <strong>Warning:</strong>
1774      * Serialized objects of this class will not be compatible with
1775      * future Swing releases. The current serialization support is
1776      * appropriate for short term storage or RMI between applications running
1777      * the same version of Swing.  As of 1.4, support for long term storage
1778      * of all JavaBeans&trade;
1779      * has been added to the <code>java.beans</code> package.
1780      * Please see {@link java.beans.XMLEncoder}.
1781      */
1782     @SuppressWarnings("serial") // Same-version serialization only
1783     public abstract class AbstractElement implements Element, MutableAttributeSet, Serializable, TreeNode {
1784 
1785         /**
1786          * Creates a new AbstractElement.
1787          *
1788          * @param parent the parent element
1789          * @param a the attributes for the element
1790          * @since 1.4
1791          */
1792         public AbstractElement(Element parent, AttributeSet a) {
1793             this.parent = parent;
1794             attributes = getAttributeContext().getEmptySet();
1795             if (a != null) {
1796                 addAttributes(a);
1797             }
1798         }


2228             StyleContext.readAttributeSet(s, attr);
2229             AttributeContext context = getAttributeContext();
2230             attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2231         }
2232 
2233         // ---- variables -----------------------------------------------------
2234 
2235         private Element parent;
2236         private transient AttributeSet attributes;
2237 
2238     }
2239 
2240     /**
2241      * Implements a composite element that contains other elements.
2242      * <p>
2243      * <strong>Warning:</strong>
2244      * Serialized objects of this class will not be compatible with
2245      * future Swing releases. The current serialization support is
2246      * appropriate for short term storage or RMI between applications running
2247      * the same version of Swing.  As of 1.4, support for long term storage
2248      * of all JavaBeans&trade;
2249      * has been added to the <code>java.beans</code> package.
2250      * Please see {@link java.beans.XMLEncoder}.
2251      */
2252     @SuppressWarnings("serial") // Same-version serialization only
2253     public class BranchElement extends AbstractElement {
2254 
2255         /**
2256          * Constructs a composite element that initially contains
2257          * no children.
2258          *
2259          * @param parent  The parent element
2260          * @param a the attributes for the element
2261          * @since 1.4
2262          */
2263         public BranchElement(Element parent, AttributeSet a) {
2264             super(parent, a);
2265             children = new AbstractElement[1];
2266             nchildren = 0;
2267             lastIndex = -1;
2268         }


2483                 tempVector.addElement(children[counter]);
2484             return tempVector.elements();
2485         }
2486 
2487         // ------ members ----------------------------------------------
2488 
2489         private AbstractElement[] children;
2490         private int nchildren;
2491         private int lastIndex;
2492     }
2493 
2494     /**
2495      * Implements an element that directly represents content of
2496      * some kind.
2497      * <p>
2498      * <strong>Warning:</strong>
2499      * Serialized objects of this class will not be compatible with
2500      * future Swing releases. The current serialization support is
2501      * appropriate for short term storage or RMI between applications running
2502      * the same version of Swing.  As of 1.4, support for long term storage
2503      * of all JavaBeans&trade;
2504      * has been added to the <code>java.beans</code> package.
2505      * Please see {@link java.beans.XMLEncoder}.
2506      *
2507      * @see     Element
2508      */
2509     @SuppressWarnings("serial") // Same-version serialization only
2510     public class LeafElement extends AbstractElement {
2511 
2512         /**
2513          * Constructs an element that represents content within the
2514          * document (has no children).
2515          *
2516          * @param parent  The parent element
2517          * @param a       The element attributes
2518          * @param offs0   The start offset &gt;= 0
2519          * @param offs1   The end offset &gt;= offs0
2520          * @since 1.4
2521          */
2522         public LeafElement(Element parent, AttributeSet a, int offs0, int offs1) {
2523             super(parent, a);




  74  * and not access the component lock if trying to be safe from deadlocks.
  75  * The <code>repaint</code> and <code>revalidate</code> methods
  76  * on JComponent are safe.
  77  * <p>
  78  * AbstractDocument models an implied break at the end of the document.
  79  * Among other things this allows you to position the caret after the last
  80  * character. As a result of this, <code>getLength</code> returns one less
  81  * than the length of the Content. If you create your own Content, be
  82  * sure and initialize it to have an additional character. Refer to
  83  * StringContent and GapContent for examples of this. Another implication
  84  * of this is that Elements that model the implied end character will have
  85  * an endOffset == (getLength() + 1). For example, in DefaultStyledDocument
  86  * <code>getParagraphElement(getLength()).getEndOffset() == getLength() + 1
  87  * </code>.
  88  * <p>
  89  * <strong>Warning:</strong>
  90  * Serialized objects of this class will not be compatible with
  91  * future Swing releases. The current serialization support is
  92  * appropriate for short term storage or RMI between applications running
  93  * the same version of Swing.  As of 1.4, support for long term storage
  94  * of all JavaBeans
  95  * has been added to the <code>java.beans</code> package.
  96  * Please see {@link java.beans.XMLEncoder}.
  97  *
  98  * @author  Timothy Prinzing
  99  */
 100 @SuppressWarnings("serial") // Same-version serialization only
 101 public abstract class AbstractDocument implements Document, Serializable {
 102 
 103     /**
 104      * Constructs a new <code>AbstractDocument</code>, wrapped around some
 105      * specified content storage mechanism.
 106      *
 107      * @param data the content
 108      */
 109     protected AbstractDocument(Content data) {
 110         this(data, StyleContext.getDefaultStyleContext());
 111     }
 112 
 113     /**
 114      * Constructs a new <code>AbstractDocument</code>, wrapped around some


1758          * would call this in its finalize method.
1759          *
1760          * @param a the attribute set to reclaim
1761          */
1762         public void reclaim(AttributeSet a);
1763     }
1764 
1765     /**
1766      * Implements the abstract part of an element.  By default elements
1767      * support attributes by having a field that represents the immutable
1768      * part of the current attribute set for the element.  The element itself
1769      * implements MutableAttributeSet which can be used to modify the set
1770      * by fetching a new immutable set.  The immutable sets are provided
1771      * by the AttributeContext associated with the document.
1772      * <p>
1773      * <strong>Warning:</strong>
1774      * Serialized objects of this class will not be compatible with
1775      * future Swing releases. The current serialization support is
1776      * appropriate for short term storage or RMI between applications running
1777      * the same version of Swing.  As of 1.4, support for long term storage
1778      * of all JavaBeans
1779      * has been added to the <code>java.beans</code> package.
1780      * Please see {@link java.beans.XMLEncoder}.
1781      */
1782     @SuppressWarnings("serial") // Same-version serialization only
1783     public abstract class AbstractElement implements Element, MutableAttributeSet, Serializable, TreeNode {
1784 
1785         /**
1786          * Creates a new AbstractElement.
1787          *
1788          * @param parent the parent element
1789          * @param a the attributes for the element
1790          * @since 1.4
1791          */
1792         public AbstractElement(Element parent, AttributeSet a) {
1793             this.parent = parent;
1794             attributes = getAttributeContext().getEmptySet();
1795             if (a != null) {
1796                 addAttributes(a);
1797             }
1798         }


2228             StyleContext.readAttributeSet(s, attr);
2229             AttributeContext context = getAttributeContext();
2230             attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2231         }
2232 
2233         // ---- variables -----------------------------------------------------
2234 
2235         private Element parent;
2236         private transient AttributeSet attributes;
2237 
2238     }
2239 
2240     /**
2241      * Implements a composite element that contains other elements.
2242      * <p>
2243      * <strong>Warning:</strong>
2244      * Serialized objects of this class will not be compatible with
2245      * future Swing releases. The current serialization support is
2246      * appropriate for short term storage or RMI between applications running
2247      * the same version of Swing.  As of 1.4, support for long term storage
2248      * of all JavaBeans
2249      * has been added to the <code>java.beans</code> package.
2250      * Please see {@link java.beans.XMLEncoder}.
2251      */
2252     @SuppressWarnings("serial") // Same-version serialization only
2253     public class BranchElement extends AbstractElement {
2254 
2255         /**
2256          * Constructs a composite element that initially contains
2257          * no children.
2258          *
2259          * @param parent  The parent element
2260          * @param a the attributes for the element
2261          * @since 1.4
2262          */
2263         public BranchElement(Element parent, AttributeSet a) {
2264             super(parent, a);
2265             children = new AbstractElement[1];
2266             nchildren = 0;
2267             lastIndex = -1;
2268         }


2483                 tempVector.addElement(children[counter]);
2484             return tempVector.elements();
2485         }
2486 
2487         // ------ members ----------------------------------------------
2488 
2489         private AbstractElement[] children;
2490         private int nchildren;
2491         private int lastIndex;
2492     }
2493 
2494     /**
2495      * Implements an element that directly represents content of
2496      * some kind.
2497      * <p>
2498      * <strong>Warning:</strong>
2499      * Serialized objects of this class will not be compatible with
2500      * future Swing releases. The current serialization support is
2501      * appropriate for short term storage or RMI between applications running
2502      * the same version of Swing.  As of 1.4, support for long term storage
2503      * of all JavaBeans
2504      * has been added to the <code>java.beans</code> package.
2505      * Please see {@link java.beans.XMLEncoder}.
2506      *
2507      * @see     Element
2508      */
2509     @SuppressWarnings("serial") // Same-version serialization only
2510     public class LeafElement extends AbstractElement {
2511 
2512         /**
2513          * Constructs an element that represents content within the
2514          * document (has no children).
2515          *
2516          * @param parent  The parent element
2517          * @param a       The element attributes
2518          * @param offs0   The start offset &gt;= 0
2519          * @param offs1   The end offset &gt;= offs0
2520          * @since 1.4
2521          */
2522         public LeafElement(Element parent, AttributeSet a, int offs0, int offs1) {
2523             super(parent, a);


< prev index next >