jdk/src/share/classes/java/nio/file/InvalidPathException.java
changeset 2072 80dfe4469bbd
parent 2057 3acf8e5e2ca0
child 5506 202f599c92aa
equal deleted inserted replaced
2071:5e6af6d106cb 2072:80dfe4469bbd
    41 
    41 
    42     /**
    42     /**
    43      * Constructs an instance from the given input string, reason, and error
    43      * Constructs an instance from the given input string, reason, and error
    44      * index.
    44      * index.
    45      *
    45      *
    46      * @param  input   The input string
    46      * @param  input   the input string
    47      * @param  reason  A string explaining why the input was rejected
    47      * @param  reason  a string explaining why the input was rejected
    48      * @param  index   The index at which the error occurred,
    48      * @param  index   the index at which the error occurred,
    49      *                 or <tt>-1</tt> if the index is not known
    49      *                 or <tt>-1</tt> if the index is not known
    50      *
    50      *
    51      * @throws  NullPointerException
    51      * @throws  NullPointerException
    52      *          If either the input or reason strings are <tt>null</tt>
    52      *          if either the input or reason strings are <tt>null</tt>
    53      *
    53      *
    54      * @throws  IllegalArgumentException
    54      * @throws  IllegalArgumentException
    55      *          If the error index is less than <tt>-1</tt>
    55      *          if the error index is less than <tt>-1</tt>
    56      */
    56      */
    57     public InvalidPathException(String input, String reason, int index) {
    57     public InvalidPathException(String input, String reason, int index) {
    58         super(reason);
    58         super(reason);
    59         if ((input == null) || (reason == null))
    59         if ((input == null) || (reason == null))
    60             throw new NullPointerException();
    60             throw new NullPointerException();
    66 
    66 
    67     /**
    67     /**
    68      * Constructs an instance from the given input string and reason.  The
    68      * Constructs an instance from the given input string and reason.  The
    69      * resulting object will have an error index of <tt>-1</tt>.
    69      * resulting object will have an error index of <tt>-1</tt>.
    70      *
    70      *
    71      * @param  input   The input string
    71      * @param  input   the input string
    72      * @param  reason  A string explaining why the input was rejected
    72      * @param  reason  a string explaining why the input was rejected
    73      *
    73      *
    74      * @throws  NullPointerException
    74      * @throws  NullPointerException
    75      *          If either the input or reason strings are <tt>null</tt>
    75      *          if either the input or reason strings are <tt>null</tt>
    76      */
    76      */
    77     public InvalidPathException(String input, String reason) {
    77     public InvalidPathException(String input, String reason) {
    78         this(input, reason, -1);
    78         this(input, reason, -1);
    79     }
    79     }
    80 
    80 
    81     /**
    81     /**
    82      * Returns the input string.
    82      * Returns the input string.
    83      *
    83      *
    84      * @return  The input string
    84      * @return  the input string
    85      */
    85      */
    86     public String getInput() {
    86     public String getInput() {
    87         return input;
    87         return input;
    88     }
    88     }
    89 
    89 
    90     /**
    90     /**
    91      * Returns a string explaining why the input string was rejected.
    91      * Returns a string explaining why the input string was rejected.
    92      *
    92      *
    93      * @return  The reason string
    93      * @return  the reason string
    94      */
    94      */
    95     public String getReason() {
    95     public String getReason() {
    96         return super.getMessage();
    96         return super.getMessage();
    97     }
    97     }
    98 
    98 
    99     /**
    99     /**
   100      * Returns an index into the input string of the position at which the
   100      * Returns an index into the input string of the position at which the
   101      * error occurred, or <tt>-1</tt> if this position is not known.
   101      * error occurred, or <tt>-1</tt> if this position is not known.
   102      *
   102      *
   103      * @return  The error index
   103      * @return  the error index
   104      */
   104      */
   105     public int getIndex() {
   105     public int getIndex() {
   106         return index;
   106         return index;
   107     }
   107     }
   108 
   108 
   112      * (<tt>':'</tt>), a space, and the input string.  If the error index is
   112      * (<tt>':'</tt>), a space, and the input string.  If the error index is
   113      * defined then the string <tt>" at index "</tt> followed by the index, in
   113      * defined then the string <tt>" at index "</tt> followed by the index, in
   114      * decimal, is inserted after the reason string and before the colon
   114      * decimal, is inserted after the reason string and before the colon
   115      * character.
   115      * character.
   116      *
   116      *
   117      * @return  A string describing the error
   117      * @return  a string describing the error
   118      */
   118      */
   119     public String getMessage() {
   119     public String getMessage() {
   120         StringBuffer sb = new StringBuffer();
   120         StringBuffer sb = new StringBuffer();
   121         sb.append(getReason());
   121         sb.append(getReason());
   122         if (index > -1) {
   122         if (index > -1) {