| 1 |
|
package org.json.simple.parser; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
@author |
| 7 |
|
|
| 8 |
|
|
| |
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 13 |
Complexity Density: 0.5 |
|
| 9 |
|
public class ParseException extends Exception |
| 10 |
|
{ |
| 11 |
|
private static final long serialVersionUID = -7880698968187728547L; |
| 12 |
|
|
| 13 |
|
public static final int ERROR_UNEXPECTED_CHAR = 0; |
| 14 |
|
|
| 15 |
|
public static final int ERROR_UNEXPECTED_TOKEN = 1; |
| 16 |
|
|
| 17 |
|
public static final int ERROR_UNEXPECTED_EXCEPTION = 2; |
| 18 |
|
|
| 19 |
|
private int errorType; |
| 20 |
|
|
| 21 |
|
private Object unexpectedObject; |
| 22 |
|
|
| 23 |
|
private int position; |
| 24 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 25 |
0 |
public ParseException(int errorType)... |
| 26 |
|
{ |
| 27 |
0 |
this(-1, errorType, null); |
| 28 |
|
} |
| 29 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 30 |
0 |
public ParseException(int errorType, Object unexpectedObject)... |
| 31 |
|
{ |
| 32 |
0 |
this(-1, errorType, unexpectedObject); |
| 33 |
|
} |
| 34 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 35 |
0 |
public ParseException(int position, int errorType,... |
| 36 |
|
Object unexpectedObject) |
| 37 |
|
{ |
| 38 |
0 |
this.position = position; |
| 39 |
0 |
this.errorType = errorType; |
| 40 |
0 |
this.unexpectedObject = unexpectedObject; |
| 41 |
|
} |
| 42 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
0 |
public int getErrorType()... |
| 44 |
|
{ |
| 45 |
0 |
return errorType; |
| 46 |
|
} |
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0 |
public void setErrorType(int errorType)... |
| 49 |
|
{ |
| 50 |
0 |
this.errorType = errorType; |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@see |
| 55 |
|
|
| 56 |
|
@return |
| 57 |
|
|
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
0 |
public int getPosition()... |
| 60 |
|
{ |
| 61 |
0 |
return position; |
| 62 |
|
} |
| 63 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 64 |
0 |
public void setPosition(int position)... |
| 65 |
|
{ |
| 66 |
0 |
this.position = position; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@see |
| 71 |
|
|
| 72 |
|
@return |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
0 |
public Object getUnexpectedObject()... |
| 78 |
|
{ |
| 79 |
0 |
return unexpectedObject; |
| 80 |
|
} |
| 81 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0 |
public void setUnexpectedObject(Object unexpectedObject)... |
| 83 |
|
{ |
| 84 |
0 |
this.unexpectedObject = unexpectedObject; |
| 85 |
|
} |
| 86 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.27 |
|
| 87 |
0 |
public String getMessage()... |
| 88 |
|
{ |
| 89 |
0 |
StringBuffer sb = new StringBuffer(); |
| 90 |
|
|
| 91 |
0 |
switch (errorType) |
| 92 |
|
{ |
| 93 |
0 |
case ERROR_UNEXPECTED_CHAR: |
| 94 |
0 |
sb.append("Unexpected character (").append(unexpectedObject) |
| 95 |
|
.append(") at position ").append(position).append("."); |
| 96 |
0 |
break; |
| 97 |
0 |
case ERROR_UNEXPECTED_TOKEN: |
| 98 |
0 |
sb.append("Unexpected token ").append(unexpectedObject) |
| 99 |
|
.append(" at position ").append(position).append("."); |
| 100 |
0 |
break; |
| 101 |
0 |
case ERROR_UNEXPECTED_EXCEPTION: |
| 102 |
0 |
sb.append("Unexpected exception at position ").append(position) |
| 103 |
|
.append(": ").append(unexpectedObject); |
| 104 |
0 |
break; |
| 105 |
0 |
default: |
| 106 |
0 |
sb.append("Unkown error at position ").append(position).append("."); |
| 107 |
0 |
break; |
| 108 |
|
} |
| 109 |
0 |
return sb.toString(); |
| 110 |
|
} |
| 111 |
|
} |