KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > text > Position


1 /*
2  * @(#)Position.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.text;
8
9 /**
10  * Represents a location within a document. It is intended to abstract away
11  * implementation details of the document and enable specification of
12  * positions within the document that are capable of tracking of change as
13  * the document is edited (i.e. offsets are fragile).
14  *
15  * @author Timothy Prinzing
16  * @version 1.18 12/19/03
17  */

18 public interface Position {
19
20     /**
21      * Fetches the current offset within the document.
22      *
23      * @return the offset >= 0
24      */

25     public int getOffset();
26
27     /**
28      * A typesafe enumeration to indicate bias to a position
29      * in the model. A position indicates a location between
30      * two characters. The bias can be used to indicate an
31      * interest toward one of the two sides of the position
32      * in boundary conditions where a simple offset is
33      * ambiguous.
34      */

35     public static final class Bias {
36
37     /**
38      * Indicates to bias toward the next character
39      * in the model.
40      */

41     public static final Bias Forward = new Bias("Forward");
42
43     /**
44      * Indicates a bias toward the previous character
45      * in the model.
46      */

47     public static final Bias Backward = new Bias("Backward");
48
49     /**
50      * string representation
51      */

52         public String JavaDoc toString() {
53         return name;
54     }
55
56         private Bias(String JavaDoc name) {
57         this.name = name;
58     }
59
60     private String JavaDoc name;
61     }
62 }
63
Popular Tags