0N/A/*
2362N/A * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.nio.file;
0N/A
0N/A/**
0N/A * Unchecked exception thrown when path string cannot be converted into a
0N/A * {@link Path} because the path string contains invalid characters, or
0N/A * the path string is invalid for other file system specific reasons.
0N/A */
0N/A
0N/Apublic class InvalidPathException
0N/A extends IllegalArgumentException
0N/A{
0N/A static final long serialVersionUID = 4355821422286746137L;
0N/A
0N/A private String input;
0N/A private int index;
0N/A
0N/A /**
0N/A * Constructs an instance from the given input string, reason, and error
0N/A * index.
0N/A *
0N/A * @param input the input string
0N/A * @param reason a string explaining why the input was rejected
0N/A * @param index the index at which the error occurred,
0N/A * or <tt>-1</tt> if the index is not known
0N/A *
0N/A * @throws NullPointerException
0N/A * if either the input or reason strings are <tt>null</tt>
0N/A *
0N/A * @throws IllegalArgumentException
0N/A * if the error index is less than <tt>-1</tt>
0N/A */
0N/A public InvalidPathException(String input, String reason, int index) {
0N/A super(reason);
0N/A if ((input == null) || (reason == null))
0N/A throw new NullPointerException();
0N/A if (index < -1)
0N/A throw new IllegalArgumentException();
0N/A this.input = input;
0N/A this.index = index;
0N/A }
0N/A
0N/A /**
0N/A * Constructs an instance from the given input string and reason. The
0N/A * resulting object will have an error index of <tt>-1</tt>.
0N/A *
0N/A * @param input the input string
0N/A * @param reason a string explaining why the input was rejected
0N/A *
0N/A * @throws NullPointerException
0N/A * if either the input or reason strings are <tt>null</tt>
0N/A */
0N/A public InvalidPathException(String input, String reason) {
0N/A this(input, reason, -1);
0N/A }
0N/A
0N/A /**
0N/A * Returns the input string.
0N/A *
0N/A * @return the input string
0N/A */
0N/A public String getInput() {
0N/A return input;
0N/A }
0N/A
0N/A /**
0N/A * Returns a string explaining why the input string was rejected.
0N/A *
0N/A * @return the reason string
0N/A */
0N/A public String getReason() {
0N/A return super.getMessage();
0N/A }
0N/A
0N/A /**
0N/A * Returns an index into the input string of the position at which the
0N/A * error occurred, or <tt>-1</tt> if this position is not known.
0N/A *
0N/A * @return the error index
0N/A */
0N/A public int getIndex() {
0N/A return index;
0N/A }
0N/A
0N/A /**
0N/A * Returns a string describing the error. The resulting string
0N/A * consists of the reason string followed by a colon character
0N/A * (<tt>':'</tt>), a space, and the input string. If the error index is
0N/A * defined then the string <tt>" at index "</tt> followed by the index, in
0N/A * decimal, is inserted after the reason string and before the colon
0N/A * character.
0N/A *
0N/A * @return a string describing the error
0N/A */
0N/A public String getMessage() {
0N/A StringBuffer sb = new StringBuffer();
0N/A sb.append(getReason());
0N/A if (index > -1) {
0N/A sb.append(" at index ");
0N/A sb.append(index);
0N/A }
0N/A sb.append(": ");
0N/A sb.append(input);
0N/A return sb.toString();
0N/A }
0N/A}
0N/A