jdk/src/share/classes/javax/swing/text/Element.java
author malenkov
Fri, 04 Apr 2014 20:18:53 +0400
changeset 24158 6afb40c4e9f8
parent 23010 6dadb192ad81
permissions -rw-r--r--
8039137: KSS: JTextComponent.isProcessInputMethodEventOverridden Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20428
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * Interface to describe a structural piece of a document.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * is intended to capture the spirit of an SGML element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
public interface Element {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
     * Fetches the document associated with this element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
     * @return the document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public Document getDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * Fetches the parent element.  If the element is a root level
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * element returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * @return the parent element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public Element getParentElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Fetches the name of the element.  If the element is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * represent some type of structure, this would be the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @return the element name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Fetches the collection of attributes this element contains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @return the attributes for the element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public AttributeSet getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Fetches the offset from the beginning of the document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * that this element begins at.  If this element has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * children, this will be the offset of the first child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * As a document position, there is an implied forward bias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
    72
     * @return the starting offset &gt;= 0 and &lt; getEndOffset();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @see Document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @see AbstractDocument
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public int getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Fetches the offset from the beginning of the document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * that this element ends at.  If this element has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * children, this will be the end offset of the last child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * As a document position, there is an implied backward bias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * All the default <code>Document</code> implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * descend from <code>AbstractDocument</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * <code>AbstractDocument</code> models an implied break at the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * the document. As a result of this, it is possible for this to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * return a value greater than the length of the document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
    90
     * @return the ending offset &gt; getStartOffset() and
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
    91
     *     &lt;= getDocument().getLength() + 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see Document
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see AbstractDocument
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public int getEndOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Gets the child element index closest to the given offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * The offset is specified relative to the beginning of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * document.  Returns <code>-1</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * <code>Element</code> is a leaf, otherwise returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * the index of the <code>Element</code> that best represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * the given location.  Returns <code>0</code> if the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * is less than the start offset. Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <code>getElementCount() - 1</code> if the location is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * greater than or equal to the end offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   108
     * @param offset the specified offset &gt;= 0
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   109
     * @return the element index &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public int getElementIndex(int offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Gets the number of child elements contained by this element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * If this element is a leaf, a count of zero is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   117
     * @return the number of child elements &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public int getElementCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Fetches the child element at the given index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   124
     * @param index the specified index &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @return the child element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public Element getElement(int index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Is this element a leaf element? An element that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * <i>may</i> have children, even if it currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * has no children, would return <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @return true if a leaf element else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public boolean isLeaf();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}