/interpreter/tags/at2-build270707/src/edu/vub/util/regexp/CharIndexed.java

http://ambienttalk.googlecode.com/ · Java · 96 lines · 9 code · 7 blank · 80 comment · 0 complexity · 1c3f9b4ae17a36950780dd2863fe242a MD5 · raw file

  1. /* gnu/regexp/CharIndexed.java
  2. Copyright (C) 1998-2001, 2004, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package edu.vub.util.regexp;
  32. /**
  33. * Defines the interface used internally so that different types of source
  34. * text can be accessed in the same way. Built-in concrete classes provide
  35. * support for String, StringBuffer, InputStream and char[] types.
  36. * A class that is CharIndexed supports the notion of a cursor within a
  37. * block of text. The cursor must be able to be advanced via the move()
  38. * method. The charAt() method returns the character at the cursor position
  39. * plus a given offset.
  40. *
  41. * @author <A HREF="mailto:wes@cacas.org">Wes Biggs</A>
  42. */
  43. public interface CharIndexed {
  44. /**
  45. * Defines a constant (0xFFFF was somewhat arbitrarily chosen)
  46. * that can be returned by the charAt() function indicating that
  47. * the specified index is out of range.
  48. */
  49. char OUT_OF_BOUNDS = '\uFFFF';
  50. /**
  51. * Returns the character at the given offset past the current cursor
  52. * position in the input. The index of the current position is zero.
  53. * It is possible for this method to be called with a negative index.
  54. * This happens when using the '^' operator in multiline matching mode
  55. * or the '\b' or '\<' word boundary operators. In any case, the lower
  56. * bound is currently fixed at -2 (for '^' with a two-character newline).
  57. *
  58. * @param index the offset position in the character field to examine
  59. * @return the character at the specified index, or the OUT_OF_BOUNDS
  60. * character defined by this interface.
  61. */
  62. char charAt(int index);
  63. /**
  64. * Shifts the input buffer by a given number of positions. Returns
  65. * true if the new cursor position is valid.
  66. */
  67. boolean move(int index);
  68. /**
  69. * Returns true if the most recent move() operation placed the cursor
  70. * position at a valid position in the input.
  71. */
  72. boolean isValid();
  73. /**
  74. * Returns another CharIndexed containing length characters to the left
  75. * of the given index. The given length is an expected maximum and
  76. * the returned CharIndexed may not necessarily contain so many characters.
  77. */
  78. CharIndexed lookBehind(int index, int length);
  79. /**
  80. * Returns the effective length of this CharIndexed
  81. */
  82. int length();
  83. }