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

Quick Search    Search Deep

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


1   
2   
3   package com.memoire.re;
4   import com.memoire.re.*;
5   
6   /*
7    *  gnu/regexp/RETokenRange.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  
27  class RETokenRange extends REToken {
28    private char lo, hi;
29    private boolean insens;
30  
31    RETokenRange(int f_subIndex, char f_lo, char f_hi, boolean ins) {
32      super(f_subIndex);
33      lo = (insens = ins) ? Character.toLowerCase(f_lo) : f_lo;
34      hi = ins ? Character.toLowerCase(f_hi) : f_hi;
35    }
36  
37    int getMinimumLength() {
38      return 1;
39    }
40  
41    int[] match(RECharIndexed input, int index, int eflags, REMatch mymatch) {
42      char c = input.charAt(index);
43      if (c == RECharIndexed.OUT_OF_BOUNDS) return null;
44      if (insens) c = Character.toLowerCase(c);
45      return ((c >= lo) && (c <= hi)) ? 
46        next(input,index+1,eflags,mymatch) : null;
47    }
48  
49    void dump(StringBuffer os) {
50      os.append(lo).append('-').append(hi);
51    }
52  }
53