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.8.2.2 $
21: */package java.util.regex;
22:
23: /**
24: * The node which marks end of the particular group.
25: * @author Nikolay A. Kuznetsov
26: * @version $Revision: 1.8.2.2 $
27: */
28: class FSet extends AbstractSet {
29:
30: static PossessiveFSet posFSet = new PossessiveFSet();
31:
32: boolean isBackReferenced = false;
33:
34: private int groupIndex;
35:
36: public FSet(int groupIndex) {
37: this .groupIndex = groupIndex;
38: }
39:
40: public int matches(int stringIndex, CharSequence testString,
41: MatchResultImpl matchResult) {
42: int end = matchResult.getEnd(groupIndex);
43: matchResult.setEnd(groupIndex, stringIndex);
44: int shift = next.matches(stringIndex, testString, matchResult);
45: /*
46: * if(shift >=0 && matchResult.getEnd(groupIndex) == -1) {
47: * matchResult.setEnd(groupIndex, stringIndex); }
48: */
49: if (shift < 0)
50: matchResult.setEnd(groupIndex, end);
51: return shift;
52: }
53:
54: public int getGroupIndex() {
55: return groupIndex;
56: }
57:
58: protected String getName() {
59: return "fSet"; //$NON-NLS-1$
60: }
61:
62: public boolean hasConsumed(MatchResultImpl mr) {
63: return false;
64: }
65:
66: /**
67: * Marks the end of the particular group and not take into account possible
68: * kickbacks(required for atomic groups, for instance)
69: *
70: */
71: static class PossessiveFSet extends AbstractSet {
72:
73: public int matches(int stringIndex, CharSequence testString,
74: MatchResultImpl matchResult) {
75: return stringIndex;
76: }
77:
78: protected String getName() {
79: return "posFSet"; //$NON-NLS-1$
80: }
81:
82: public boolean hasConsumed(MatchResultImpl mr) {
83: return false;
84: }
85: }
86: }
|