01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Nikolay A. Kuznetsov
20: * @version $Revision: 1.7.2.2 $
21: */package java.util.regex;
22:
23: /**
24: * Unicode case insensitive back reference (i.e. \1-9) node.
25: *
26: * @author Nikolay A. Kuznetsov
27: * @version $Revision: 1.7.2.2 $
28: */
29: class UCIBackReferenceSet extends CIBackReferenceSet {
30:
31: int groupIndex;
32:
33: public UCIBackReferenceSet(int groupIndex, int consCounter) {
34: super (groupIndex, consCounter);
35: }
36:
37: public int matches(int stringIndex, CharSequence testString,
38: MatchResultImpl matchResult) {
39: String group = getString(matchResult);
40:
41: if (group == null
42: || (stringIndex + group.length()) > matchResult
43: .getRightBound())
44: return -1;
45:
46: for (int i = 0; i < group.length(); i++) {
47: if (Character.toLowerCase(Character.toUpperCase(group
48: .charAt(i))) != Character.toLowerCase(Character
49: .toUpperCase(testString.charAt(stringIndex + i)))) {
50: return -1;
51: }
52: }
53: matchResult.setConsumed(consCounter, group.length());
54: return next.matches(stringIndex + group.length(), testString,
55: matchResult);
56: }
57:
58: public String getName() {
59: return "UCI back reference: " + this .groupIndex; //$NON-NLS-1$
60: }
61: }
|