Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/memoire/re/RECharIndexedCharArray.java


1   
2   
3   package com.memoire.re;
4   import com.memoire.re.*;
5   
6   /*
7    *  gnu/regexp/RECharIndexedCharArray.java
8    *  Copyright (C) 1998 Wes Biggs
9    *
10   *  This library is free software; you can redistribute it and/or modify
11   *  it under the terms of the GNU Library General Public License as published
12   *  by the Free Software Foundation; either version 2 of the License, or
13   *  (at your option) any later version.
14   *
15   *  This library is distributed in the hope that it will be useful,
16   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   *  GNU Library General Public License for more details.
19   *
20   *  You should have received a copy of the GNU Library General Public License
21   *  along with this program; if not, write to the Free Software
22   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23   */
24  
25  
26  class RECharIndexedCharArray implements RECharIndexed {
27    private char[] s;
28    private int m_index;
29  
30    RECharIndexedCharArray(char[] str, int index) {
31      s = str;
32      m_index = index;
33    }
34  
35    public char charAt(int index) {
36      return ((m_index + index) < s.length) ? s[m_index + index] : RECharIndexed.OUT_OF_BOUNDS;
37    }
38  
39    public boolean isValid() {
40      return (m_index < s.length);
41    }
42  
43    public boolean move(int index) {
44      return ((m_index += index) < s.length);
45    }
46  }