View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.settings.io;
20  
21  import java.io.IOException;
22  
23  /**
24   * Signals a failure to parse the settings due to invalid syntax (e.g. non well formed XML or unknown elements).
25   *
26   */
27  public class SettingsParseException extends IOException {
28  
29      /**
30       * The one-based index of the line containing the error.
31       */
32      private final int lineNumber;
33  
34      /**
35       * The one-based index of the column containing the error.
36       */
37      private final int columnNumber;
38  
39      /**
40       * Creates a new parser exception with the specified details.
41       *
42       * @param message The error message, may be {@code null}.
43       * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown.
44       * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown.
45       */
46      public SettingsParseException(String message, int lineNumber, int columnNumber) {
47          super(message);
48          this.lineNumber = lineNumber;
49          this.columnNumber = columnNumber;
50      }
51  
52      /**
53       * Creates a new parser exception with the specified details.
54       *
55       * @param message The error message, may be {@code null}.
56       * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown.
57       * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown.
58       * @param cause The nested cause of this error, may be {@code null}.
59       */
60      public SettingsParseException(String message, int lineNumber, int columnNumber, Throwable cause) {
61          super(message);
62          initCause(cause);
63          this.lineNumber = lineNumber;
64          this.columnNumber = columnNumber;
65      }
66  
67      /**
68       * Gets the one-based index of the line containing the error.
69       *
70       * @return The one-based index of the line containing the error or a non-positive value if unknown.
71       */
72      public int getLineNumber() {
73          return lineNumber;
74      }
75  
76      /**
77       * Gets the one-based index of the column containing the error.
78       *
79       * @return The one-based index of the column containing the error or non-positive value if unknown.
80       */
81      public int getColumnNumber() {
82          return columnNumber;
83      }
84  }