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.12.2.2 $
21: */package java.util.regex;
22:
23: /**
24: * Node accepting any character except line terminators;
25: *
26: * @author Nikolay A. Kuznetsov
27: * @version $Revision: 1.12.2.2 $
28: */
29: final class DotSet extends JointSet {
30:
31: AbstractLineTerminator lt;
32:
33: public DotSet(AbstractLineTerminator lt) {
34: super ();
35: this .lt = lt;
36: }
37:
38: public int matches(int stringIndex, CharSequence testString,
39: MatchResultImpl matchResult) {
40: int strLength = matchResult.getRightBound();
41:
42: if (stringIndex + 1 > strLength) {
43: matchResult.hitEnd = true;
44: return -1;
45: }
46: char high = testString.charAt(stringIndex);
47:
48: if (Character.isHighSurrogate(high)
49: && (stringIndex + 2 <= strLength)) {
50: char low = testString.charAt(stringIndex + 1);
51:
52: if (Character.isSurrogatePair(high, low)) {
53: return lt.isLineTerminator(Character.toCodePoint(high,
54: low)) ? -1 : next.matches(stringIndex + 2,
55: testString, matchResult);
56: }
57: }
58:
59: return lt.isLineTerminator(high) ? -1 : next.matches(
60: stringIndex + 1, testString, matchResult);
61: }
62:
63: protected String getName() {
64: return "."; //$NON-NLS-1$
65: }
66:
67: public AbstractSet getNext() {
68: return this .next;
69: }
70:
71: public void setNext(AbstractSet next) {
72: this .next = next;
73: }
74:
75: public int getType() {
76: return AbstractSet.TYPE_DOTSET;
77: }
78:
79: public boolean hasConsumed(MatchResultImpl matchResult) {
80: return true;
81: }
82: }
|