jdk/src/share/classes/java/util/IllformedLocaleException.java
author darcy
Wed, 10 Jul 2013 11:05:39 -0700
changeset 18796 486b43748d9b
parent 6501 684810d882b3
permissions -rw-r--r--
8020294: Fix doclint issues in java.util.Spliterator Reviewed-by: psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     1
/*
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     4
 *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    10
 *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    15
 * accompanied this code).
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    16
 *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    20
 *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    23
 * questions.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    24
 */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    25
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    26
/*
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    27
 *******************************************************************************
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    28
 * Copyright (C) 2009-2010, International Business Machines Corporation and    *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    29
 * others. All Rights Reserved.                                                *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    30
 *******************************************************************************
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    31
 */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    32
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    33
package java.util;
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    34
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    35
/**
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    36
 * Thrown by methods in {@link Locale} and {@link Locale.Builder} to
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    37
 * indicate that an argument is not a well-formed BCP 47 tag.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    38
 *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    39
 * @see Locale
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    40
 * @since 1.7
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    41
 */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    42
public class IllformedLocaleException extends RuntimeException {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    43
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    44
    private static final long serialVersionUID = -5245986824925681401L;
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    45
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    46
    private int _errIdx = -1;
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    47
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    48
    /**
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    49
     * Constructs a new <code>IllformedLocaleException</code> with no
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    50
     * detail message and -1 as the error index.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    51
     */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    52
    public IllformedLocaleException() {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    53
        super();
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    54
    }
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    55
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    56
    /**
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    57
     * Constructs a new <code>IllformedLocaleException</code> with the
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    58
     * given message and -1 as the error index.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    59
     *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    60
     * @param message the message
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    61
     */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    62
    public IllformedLocaleException(String message) {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    63
        super(message);
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    64
    }
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    65
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    66
    /**
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    67
     * Constructs a new <code>IllformedLocaleException</code> with the
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    68
     * given message and the error index.  The error index is the approximate
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    69
     * offset from the start of the ill-formed value to the point where the
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    70
     * parse first detected an error.  A negative error index value indicates
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    71
     * either the error index is not applicable or unknown.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    72
     *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    73
     * @param message the message
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    74
     * @param errorIndex the index
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    75
     */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    76
    public IllformedLocaleException(String message, int errorIndex) {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    77
        super(message + ((errorIndex < 0) ? "" : " [at index " + errorIndex + "]"));
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    78
        _errIdx = errorIndex;
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    79
    }
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    80
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    81
    /**
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    82
     * Returns the index where the error was found. A negative value indicates
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    83
     * either the error index is not applicable or unknown.
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    84
     *
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    85
     * @return the error index
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    86
     */
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    87
    public int getErrorIndex() {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    88
        return _errIdx;
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    89
    }
684810d882b3 6875847: Java Locale Enhancement
naoto
parents:
diff changeset
    90
}