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. * Represents a location within a document. It is intended to abstract away
  10. * implementation details of the document and enable specification of
  11. * positions within the document that are capable of tracking of change as
  12. * the document is edited (i.e. offsets are fragile).
  13. *
  14. * @author Timothy Prinzing
  15. * @version 1.18 12/19/03
  16. */
  17. public interface Position {
  18. /**
  19. * Fetches the current offset within the document.
  20. *
  21. * @return the offset >= 0
  22. */
  23. public int getOffset();
  24. /**
  25. * A typesafe enumeration to indicate bias to a position
  26. * in the model. A position indicates a location between
  27. * two characters. The bias can be used to indicate an
  28. * interest toward one of the two sides of the position
  29. * in boundary conditions where a simple offset is
  30. * ambiguous.
  31. */
  32. public static final class Bias {
  33. /**
  34. * Indicates to bias toward the next character
  35. * in the model.
  36. */
  37. public static final Bias Forward = new Bias("Forward");
  38. /**
  39. * Indicates a bias toward the previous character
  40. * in the model.
  41. */
  42. public static final Bias Backward = new Bias("Backward");
  43. /**
  44. * string representation
  45. */
  46. public String toString() {
  47. return name;
  48. }
  49. private Bias(String name) {
  50. this.name = name;
  51. }
  52. private String name;
  53. }
  54. }