]> granicus.if.org Git - icu/blob
be0f48d362576501b5968d0da6549145fc485e7f
[icu] /
1 /*
2  *******************************************************************************
3  * Copyright (C) 2009-2011, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.util;
8
9 /**
10  * Thrown by methods in {@link ULocale} and {@link ULocale.Builder} to
11  * indicate that an argument is not a well-formed BCP 47 tag.
12  * 
13  * @see ULocale
14  * @draft ICU 4.2
15  * @provisional This API might change or be removed in a future release.
16  */
17 public class IllformedLocaleException extends RuntimeException {
18
19     private static final long serialVersionUID = 1L;
20
21     private int _errIdx = -1;
22
23     /**
24      * Constructs a new <code>IllformedLocaleException</code> with no
25      * detail message and -1 as the error index.
26      * @draft ICU 4.6
27      * @provisional This API might change or be removed in a future release.
28      */
29     public IllformedLocaleException() {
30         super();
31     }
32
33     /**
34      * Constructs a new <code>IllformedLocaleException</code> with the
35      * given message and -1 as the error index.
36      *
37      * @param message the message
38      * @draft ICU 4.2
39      * @provisional This API might change or be removed in a future release.
40      */
41     public IllformedLocaleException(String message) {
42         super(message);
43     }
44
45     /**
46      * Constructs a new <code>IllformedLocaleException</code> with the
47      * given message and the error index.  The error index is the approximate
48      * offset from the start of the ill-formed value to the point where the
49      * parse first detected an error.  A negative error index value indicates
50      * either the error index is not applicable or unknown.
51      *
52      * @param message the message
53      * @param errorIndex the index
54      * @draft ICU 4.2
55      * @provisional This API might change or be removed in a future release.
56      */
57     public IllformedLocaleException(String message, int errorIndex) {
58         super(message + ((errorIndex < 0) ? "" : " [at index " + errorIndex + "]"));
59         _errIdx = errorIndex;
60     }
61
62     /**
63      * Returns the index where the error was found. A negative value indicates
64      * either the error index is not applicable or unknown.
65      *
66      * @return the error index
67      * @draft ICU 4.2
68      * @provisional This API might change or be removed in a future release.
69      */
70     public int getErrorIndex() {
71         return _errIdx;
72     }
73 }