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: import java.util.Arrays;
24:
25: import org.apache.harmony.regex.internal.nls.Messages;
26:
27: /**
28: * @com.intel.drl.spec_ref
29: *
30: * @author Nikolay A. Kuznetsov
31: * @version $Revision: 1.7.2.2 $
32: */
33: public class PatternSyntaxException extends IllegalArgumentException {
34:
35: private static final long serialVersionUID = -3864639126226059218L;
36:
37: private String desc;
38:
39: private String pattern;
40:
41: private int index = -1;
42:
43: /**
44: * @com.intel.drl.spec_ref
45: */
46: public PatternSyntaxException(String desc, String pattern, int index) {
47: this .desc = desc;
48: this .pattern = pattern;
49: this .index = index;
50: }
51:
52: /**
53: * @com.intel.drl.spec_ref
54: */
55: public String getPattern() {
56: return pattern;
57: }
58:
59: /**
60: * @com.intel.drl.spec_ref
61: */
62: public String getMessage() {
63: String filler = ""; //$NON-NLS-1$
64: if (index >= 1) {
65: char[] temp = new char[index];
66: Arrays.fill(temp, ' ');
67: filler = new String(temp);
68: }
69: return desc
70: + ((pattern != null && pattern.length() != 0) ? Messages
71: .getString("regex.07", //$NON-NLS-1$
72: new Object[] { index, pattern, filler })
73: : ""); //$NON-NLS-1$
74: }
75:
76: /**
77: * @com.intel.drl.spec_ref
78: */
79: public String getDescription() {
80: return desc;
81: }
82:
83: /**
84: * @com.intel.drl.spec_ref
85: */
86: public int getIndex() {
87: return index;
88: }
89: }
|