1 7 8 package java.net; 9 10 11 20 21 public class URISyntaxException 22 extends Exception 23 { 24 private String input; 25 private int index; 26 27 42 public URISyntaxException(String input, String reason, int index) { 43 super(reason); 44 if ((input == null) || (reason == null)) 45 throw new NullPointerException (); 46 if (index < -1) 47 throw new IllegalArgumentException (); 48 this.input = input; 49 this.index = index; 50 } 51 52 62 public URISyntaxException(String input, String reason) { 63 this(input, reason, -1); 64 } 65 66 71 public String getInput() { 72 return input; 73 } 74 75 80 public String getReason() { 81 return super.getMessage(); 82 } 83 84 90 public int getIndex() { 91 return index; 92 } 93 94 104 public String getMessage() { 105 StringBuffer sb = new StringBuffer (); 106 sb.append(getReason()); 107 if (index > -1) { 108 sb.append(" at index "); 109 sb.append(index); 110 } 111 sb.append(": "); 112 sb.append(input); 113 return sb.toString(); 114 } 115 116 } 117 | Popular Tags |