1. /*
  2. * @(#)Position.java 1.15 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.text;
  11. /**
  12. * Represents a location within a document. It is intended to abstract away
  13. * implementation details of the document and enable specification of
  14. * positions within the document that are capable of tracking of change as
  15. * the document is edited (i.e. offsets are fragile).
  16. *
  17. * @author Timothy Prinzing
  18. * @version 1.15 02/02/00
  19. */
  20. public interface Position {
  21. /**
  22. * Fetches the current offset within the document.
  23. *
  24. * @return the offset >= 0
  25. */
  26. public int getOffset();
  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. * Indicates to bias toward the next character
  38. * in the model.
  39. */
  40. public static final Bias Forward = new Bias("Forward");
  41. /**
  42. * Indicates a bias toward the previous character
  43. * in the model.
  44. */
  45. public static final Bias Backward = new Bias("Backward");
  46. /**
  47. * string representation
  48. */
  49. public String toString() {
  50. return name;
  51. }
  52. private Bias(String name) {
  53. this.name = name;
  54. }
  55. private String name;
  56. }
  57. }