0N/A/*
2362N/A * Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing.text;
0N/A
0N/A/**
0N/A * Interface to describe a structural piece of a document. It
0N/A * is intended to capture the spirit of an SGML element.
0N/A *
0N/A * @author Timothy Prinzing
0N/A */
0N/Apublic interface Element {
0N/A
0N/A /**
0N/A * Fetches the document associated with this element.
0N/A *
0N/A * @return the document
0N/A */
0N/A public Document getDocument();
0N/A
0N/A /**
0N/A * Fetches the parent element. If the element is a root level
0N/A * element returns <code>null</code>.
0N/A *
0N/A * @return the parent element
0N/A */
0N/A public Element getParentElement();
0N/A
0N/A /**
0N/A * Fetches the name of the element. If the element is used to
0N/A * represent some type of structure, this would be the type
0N/A * name.
0N/A *
0N/A * @return the element name
0N/A */
0N/A public String getName();
0N/A
0N/A /**
0N/A * Fetches the collection of attributes this element contains.
0N/A *
0N/A * @return the attributes for the element
0N/A */
0N/A public AttributeSet getAttributes();
0N/A
0N/A /**
0N/A * Fetches the offset from the beginning of the document
0N/A * that this element begins at. If this element has
0N/A * children, this will be the offset of the first child.
0N/A * As a document position, there is an implied forward bias.
0N/A *
0N/A * @return the starting offset >= 0 and < getEndOffset();
0N/A * @see Document
0N/A * @see AbstractDocument
0N/A */
0N/A public int getStartOffset();
0N/A
0N/A /**
0N/A * Fetches the offset from the beginning of the document
0N/A * that this element ends at. If this element has
0N/A * children, this will be the end offset of the last child.
0N/A * As a document position, there is an implied backward bias.
0N/A * <p>
0N/A * All the default <code>Document</code> implementations
0N/A * descend from <code>AbstractDocument</code>.
0N/A * <code>AbstractDocument</code> models an implied break at the end of
0N/A * the document. As a result of this, it is possible for this to
0N/A * return a value greater than the length of the document.
0N/A *
0N/A * @return the ending offset > getStartOffset() and
0N/A * <= getDocument().getLength() + 1
0N/A * @see Document
0N/A * @see AbstractDocument
0N/A */
0N/A public int getEndOffset();
0N/A
0N/A /**
0N/A * Gets the child element index closest to the given offset.
0N/A * The offset is specified relative to the beginning of the
0N/A * document. Returns <code>-1</code> if the
0N/A * <code>Element</code> is a leaf, otherwise returns
0N/A * the index of the <code>Element</code> that best represents
0N/A * the given location. Returns <code>0</code> if the location
0N/A * is less than the start offset. Returns
0N/A * <code>getElementCount() - 1</code> if the location is
0N/A * greater than or equal to the end offset.
0N/A *
0N/A * @param offset the specified offset >= 0
0N/A * @return the element index >= 0
0N/A */
0N/A public int getElementIndex(int offset);
0N/A
0N/A /**
0N/A * Gets the number of child elements contained by this element.
0N/A * If this element is a leaf, a count of zero is returned.
0N/A *
0N/A * @return the number of child elements >= 0
0N/A */
0N/A public int getElementCount();
0N/A
0N/A /**
0N/A * Fetches the child element at the given index.
0N/A *
0N/A * @param index the specified index >= 0
0N/A * @return the child element
0N/A */
0N/A public Element getElement(int index);
0N/A
0N/A /**
0N/A * Is this element a leaf element? An element that
0N/A * <i>may</i> have children, even if it currently
0N/A * has no children, would return <code>false</code>.
0N/A *
0N/A * @return true if a leaf element else false
0N/A */
0N/A public boolean isLeaf();
0N/A
0N/A
0N/A}