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.6.2.2 $
21: */package java.util.regex;
22:
23: /**
24: * Represents RE quantifier; contains two fields responsible for min and max
25: * number of repetitions. Negative value for maximum number of repetition
26: * represents infinity(i.e. +,*)
27: *
28: * @author Nikolay A. Kuznetsov
29: * @version $Revision: 1.6.2.2 $
30: */
31: class Quantifier extends SpecialToken implements Cloneable {
32:
33: private int min;
34:
35: private int max;
36:
37: private int counter = 0;
38:
39: public Quantifier(int min) {
40: this .min = this .max = min;
41: }
42:
43: public Quantifier(int min, int max) {
44: this .min = min;
45: this .max = max;
46: }
47:
48: public void resetCounter() {
49: counter = 0;
50: }
51:
52: public int getCounter() {
53: return counter;
54: }
55:
56: public void setCounter(int counter) {
57: this .counter = counter;
58: }
59:
60: public int min() {
61: return min;
62: }
63:
64: public int max() {
65: return max;
66: }
67:
68: public String toString() {
69: return "{" //$NON-NLS-1$
70: + min + "," //$NON-NLS-1$
71: + ((max == Integer.MAX_VALUE) ? "" : new Integer(max) //$NON-NLS-1$
72: .toString()) + "}"; //$NON-NLS-1$
73: }
74:
75: public int getType() {
76: return SpecialToken.TOK_QUANTIFIER;
77: }
78:
79: public Object clone() {
80: return new Quantifier(min, max);
81: }
82: }
|