Convert ApiParseException to Kotlin.

Test: existing tests
Bug: 153691074
(bug number is for CP)

Merged-in: I9e3153433b2614ba9ce18d83986b3a909dd915b4
Change-Id: I5e2a2ebded4e4550e77f163e956bebc380abd1e3
diff --git a/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.java b/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.java
deleted file mode 100644
index 0b3a658..0000000
--- a/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.metalava.doclava1;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-//
-// Copied from doclava1, but adapted to metalava's code model
-//
-public final class ApiParseException extends Exception {
-    private String file;
-    private int line;
-
-    ApiParseException(@NotNull String message) {
-        super(message);
-    }
-
-    ApiParseException(@NotNull String message, Exception cause) {
-        super(message, cause);
-        if (cause instanceof ApiParseException) {
-            this.file = ((ApiParseException) cause).file;
-            this.line = ((ApiParseException) cause).line;
-        }
-    }
-
-    ApiParseException(@NotNull String message, @NotNull ApiFile.Tokenizer tokenizer) {
-        this(message, tokenizer.getFileName(), tokenizer.getLine());
-    }
-
-    private ApiParseException(@NotNull String message, @Nullable String file, int line) {
-        super(message);
-        this.file = file;
-        this.line = line;
-    }
-
-    ApiParseException(@NotNull String message, int line) {
-        this(message, null, line);
-    }
-
-    public String getMessage() {
-        StringBuilder sb = new StringBuilder();
-        if (file != null) {
-            sb.append(file).append(':');
-        }
-        if (line > 0) {
-            sb.append(line).append(':');
-        }
-        if (sb.length() > 0) {
-            sb.append(' ');
-        }
-        sb.append(super.getMessage());
-        return sb.toString();
-    }
-}
diff --git a/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.kt b/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.kt
new file mode 100644
index 0000000..9e5f97b
--- /dev/null
+++ b/src/main/java/com/android/tools/metalava/doclava1/ApiParseException.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tools.metalava.doclava1
+
+class ApiParseException : Exception {
+    private var file: String? = null
+    private var line = 0
+
+    internal constructor(message: String) : super(message) {}
+    internal constructor(message: String, cause: Exception?) : super(message, cause) {
+        if (cause is ApiParseException) {
+            file = cause.file
+            line = cause.line
+        }
+    }
+
+    internal constructor(message: String, tokenizer: ApiFile.Tokenizer) : this(
+        message,
+        tokenizer.fileName,
+        tokenizer.line
+    )
+
+    private constructor(message: String, file: String?, line: Int) : super(
+        message
+    ) {
+        this.file = file
+        this.line = line
+    }
+
+    internal constructor(message: String, line: Int) : this(message, null, line)
+
+    override val message: String
+        get() {
+            val sb = StringBuilder()
+            if (file != null) {
+                sb.append(file).append(':')
+            }
+            if (line > 0) {
+                sb.append(line).append(':')
+            }
+            if (sb.isNotEmpty()) {
+                sb.append(' ')
+            }
+            sb.append(super.message)
+            return sb.toString()
+        }
+}
\ No newline at end of file