Blame |
Last modification |
View Log
| RSS feed
package com.owlike.genson.stream;
/**
* JsonStreamException are thrown by ObjectWriter and ObjectReader implementations. They indicate
* that there was a syntax error or a state error (calling endObject when it should be endArray
* etc).
*
* @author eugen
*/
public final class JsonStreamException
extends 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException {
private static final long serialVersionUID = 8033784054415043293L
;
private final int column
;
private final int row
;
public JsonStreamException
(1.5.0/docs/api/java/lang/String.html">String message,
1.5.0/docs/api/java/lang/Throwable.html">Throwable cause
) {
this(message, cause, -1, -1
);
}
public JsonStreamException
(1.5.0/docs/api/java/lang/String.html">String message
) {
this(message,
null);
}
public JsonStreamException
(1.5.0/docs/api/java/lang/Throwable.html">Throwable cause
) {
this(null, cause
);
}
// package visibility, api users are not supposed to use it
JsonStreamException
(1.5.0/docs/api/java/lang/String.html">String message,
1.5.0/docs/api/java/lang/Throwable.html">Throwable cause,
int row,
int col
) {
super(message, cause
);
this.
column = col
;
this.
row = row
;
}
public int getColumn
() {
return column
;
}
public int getRow
() {
return row
;
}
public static <T
extends Exception
> T niceTrace
(T exception
) {
final 1.5.0/docs/api/java/lang/StackTraceElement.html">StackTraceElement[] stackTrace = exception.
getStackTrace();
final 1.5.0/docs/api/java/lang/StackTraceElement.html">StackTraceElement[] newStackTrace =
new 1.5.0/docs/api/java/lang/StackTraceElement.html">StackTraceElement[stackTrace.
length - 1
];
1.5.0/docs/api/java/lang/System.html">System.
arraycopy(stackTrace, 1, newStackTrace, 0, stackTrace.
length - 1
);
exception.
setStackTrace(newStackTrace
);
return exception
;
}
public JsonStreamException niceTrace
() {
return niceTrace
(this);
}
static class Builder
{
private int col
;
private int row
;
private 1.5.0/docs/api/java/lang/String.html">String message
;
private 1.5.0/docs/api/java/lang/Throwable.html">Throwable cause
;
public JsonStreamException create
() {
return new JsonStreamException
(message, cause, row, col
);
}
Builder locate
(int row,
int col
) {
this.
row = row
;
this.
col = col
;
return this;
}
public Builder message
(1.5.0/docs/api/java/lang/String.html">String message
) {
this.
message = message
;
return this;
}
public Builder cause
(1.5.0/docs/api/java/lang/Throwable.html">Throwable th
) {
this.
cause = th
;
return this;
}
}
}