0N/A/*
2362N/A * Copyright (c) 1997, 2006, 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 * Represents a location within a document. It is intended to abstract away
0N/A * implementation details of the document and enable specification of
0N/A * positions within the document that are capable of tracking of change as
0N/A * the document is edited.
0N/A * <p>
0N/A * A {@code Position} object points at a location between two characters.
0N/A * As the surrounding content is altered, the {@code Position} object
0N/A * adjusts its offset automatically to reflect the changes. If content is
0N/A * inserted or removed before the {@code Position} object's location, then the
0N/A * {@code Position} increments or decrements its offset, respectively,
0N/A * so as to point to the same location. If a portion of the document is removed
0N/A * that contains a {@code Position}'s offset, then the {@code Position}'s
0N/A * offset becomes that of the beginning of the removed region. For example, if
0N/A * a {@code Position} has an offset of 5 and the region 2-10 is removed, then
0N/A * the {@code Position}'s offset becomes 2.
0N/A * <p>
0N/A * {@code Position} with an offset of 0 is a special case. It never changes its
0N/A * offset while document content is altered.
0N/A *
0N/A * @author Timothy Prinzing
0N/A */
0N/Apublic interface Position {
0N/A
0N/A /**
0N/A * Fetches the current offset within the document.
0N/A *
0N/A * @return the offset >= 0
0N/A */
0N/A public int getOffset();
0N/A
0N/A /**
0N/A * A typesafe enumeration to indicate bias to a position
0N/A * in the model. A position indicates a location between
0N/A * two characters. The bias can be used to indicate an
0N/A * interest toward one of the two sides of the position
0N/A * in boundary conditions where a simple offset is
0N/A * ambiguous.
0N/A */
0N/A public static final class Bias {
0N/A
0N/A /**
0N/A * Indicates to bias toward the next character
0N/A * in the model.
0N/A */
0N/A public static final Bias Forward = new Bias("Forward");
0N/A
0N/A /**
0N/A * Indicates a bias toward the previous character
0N/A * in the model.
0N/A */
0N/A public static final Bias Backward = new Bias("Backward");
0N/A
0N/A /**
0N/A * string representation
0N/A */
0N/A public String toString() {
0N/A return name;
0N/A }
0N/A
0N/A private Bias(String name) {
0N/A this.name = name;
0N/A }
0N/A
0N/A private String name;
0N/A }
0N/A}