PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/gnu/regexp/CharIndexed.java

#
Java | 65 lines | 7 code | 4 blank | 54 comment | 0 complexity | 5682dc9596eac9d979b8c7878e9d8806 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * gnu/regexp/CharIndexed.java
  3. * Copyright (C) 1998-2001 Wes Biggs
  4. *
  5. * This library is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published
  7. * by the Free Software Foundation; either version 2.1 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. package gnu.regexp;
  20. /**
  21. * Defines the interface used internally so that different types of source
  22. * text can be accessed in the same way. Built-in concrete classes provide
  23. * support for String, StringBuffer, InputStream and char[] types.
  24. * A class that is CharIndexed supports the notion of a cursor within a
  25. * block of text. The cursor must be able to be advanced via the move()
  26. * method. The charAt() method returns the character at the cursor position
  27. * plus a given offset.
  28. *
  29. * @author <A HREF="mailto:wes@cacas.org">Wes Biggs</A>
  30. */
  31. public interface CharIndexed {
  32. /**
  33. * Defines a constant (0xFFFF was somewhat arbitrarily chosen)
  34. * that can be returned by the charAt() function indicating that
  35. * the specified index is out of range.
  36. */
  37. char OUT_OF_BOUNDS = '\uFFFF';
  38. /**
  39. * Returns the character at the given offset past the current cursor
  40. * position in the input. The index of the current position is zero.
  41. * It is possible for this method to be called with a negative index.
  42. * This happens when using the '^' operator in multiline matching mode
  43. * or the '\b' or '\<' word boundary operators. In any case, the lower
  44. * bound is currently fixed at -2 (for '^' with a two-character newline).
  45. *
  46. * @param index the offset position in the character field to examine
  47. * @return the character at the specified index, or the OUT_OF_BOUNDS
  48. * character defined by this interface.
  49. */
  50. char charAt(int index);
  51. /**
  52. * Shifts the input buffer by a given number of positions. Returns
  53. * true if the new cursor position is valid.
  54. */
  55. boolean move(int index);
  56. /**
  57. * Returns true if the most recent move() operation placed the cursor
  58. * position at a valid position in the input.
  59. */
  60. boolean isValid();
  61. }