Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.jr.ob

public Class JSONObjectException

extends JsonProcessingException
Class Inheritance
Imports
java.io.IOException, .Serializable, java.util.Collection, .Collections, .Iterator, .LinkedList, .List, com.fasterxml.jackson.core.JsonLocation, .JsonParser, .JsonProcessingException

Standard exception exposed by this package; equivalent of com.fasterxml.jackson.databind.JsonMappingException (and, in fact, much of implementation came from that class, but had to be cut-n-pasted since we do not depend on databind package).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JSONObjectException.Reference

Simple bean class used to contain references.

Field Summary

Modifier and TypeField and Description
protected LinkedList<JSONObjectException.Reference>
_path

Path through which problem that triggering throwing of this exception was reached.

pack-priv static final int
MAX_REFS_TO_LIST

Let's limit length of reference chain, to limit damage in cases of infinite recursion.

private static final long
Inherited from com.fasterxml.jackson.core.JsonProcessingException:
_location

Constructor Summary

AccessConstructor and Description
public
public
public
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected String
public static JSONObjectException
public static JSONObjectException
from(JsonParser p, String msg, Object... args)

public static JSONObjectException
from(JsonParser p, Throwable problem, String msg, Object... args)

public static JSONObjectException
fromUnexpectedIOE(IOException src)

Factory method used when "upgrading" an IOException into JSONObjectException: usually only needed to comply with a signature.

public String
getLocalizedMessage()

Overrides java.lang.Throwable.getLocalizedMessage.

Creates a localized description of this throwable.

public String
getMessage()

Overrides com.fasterxml.jackson.core.JsonProcessingException.getMessage.

Method is overridden so that we can properly inject description of problem path, if such is defined.

public List<JSONObjectException.Reference>
getPath()

Method for accessing full structural path within type hierarchy down to problematic property.

public String
getPathReference()

Method for accesing description of path that lead to the problem that triggered this exception

public StringBuilder
public void
prependPath(Object referrer, String fieldName)

Method called to prepend a reference information in front of current path

public void
prependPath(Object referrer, int index)

Method called to prepend a reference information in front of current path

public void
public String
toString()

Overrides com.fasterxml.jackson.core.JsonProcessingException.toString.

Returns a short description of this throwable.

public static JSONObjectException
wrapWithPath(Throwable src, Object refFrom, String refFieldName)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.

public static JSONObjectException
wrapWithPath(Throwable src, Object refFrom, int index)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.

public static JSONObjectException
wrapWithPath(Throwable src, JSONObjectException.Reference ref)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.

Inherited from com.fasterxml.jackson.core.JsonProcessingException:
clearLocationgetLocationgetMessageSuffixgetOriginalMessagegetProcessor

Field Detail

_pathback to summary
protected LinkedList<JSONObjectException.Reference> _path

Path through which problem that triggering throwing of this exception was reached.

MAX_REFS_TO_LISTback to summary
pack-priv static final int MAX_REFS_TO_LIST

Let's limit length of reference chain, to limit damage in cases of infinite recursion.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.core.JsonProcessingException.serialVersionUID.

Constructor Detail

JSONObjectExceptionback to summary
public JSONObjectException(String msg)
JSONObjectExceptionback to summary
public JSONObjectException(String msg, Throwable rootCause)
JSONObjectExceptionback to summary
public JSONObjectException(String msg, JsonLocation loc)
JSONObjectExceptionback to summary
public JSONObjectException(String msg, JsonLocation loc, Throwable rootCause)

Method Detail

_appendPathDescback to summary
protected void _appendPathDesc(StringBuilder sb)
_buildMessageback to summary
protected String _buildMessage()
fromback to summary
public static JSONObjectException from(JsonParser p, String msg)
fromback to summary
public static JSONObjectException from(JsonParser p, String msg, Object... args)
fromback to summary
public static JSONObjectException from(JsonParser p, Throwable problem, String msg, Object... args)
fromUnexpectedIOEback to summary
public static JSONObjectException fromUnexpectedIOE(IOException src)

Factory method used when "upgrading" an IOException into JSONObjectException: usually only needed to comply with a signature.

getLocalizedMessageback to summary
public String getLocalizedMessage()

Overrides java.lang.Throwable.getLocalizedMessage.

Doc from java.lang.Throwable.getLocalizedMessage.

Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method, the default implementation returns the same result as getMessage().

Returns:String

The localized description of this throwable.

Annotations
@Override
getMessageback to summary
public String getMessage()

Overrides com.fasterxml.jackson.core.JsonProcessingException.getMessage.

Method is overridden so that we can properly inject description of problem path, if such is defined.

Returns:String

Doc from com.fasterxml.jackson.core.JsonProcessingException.getMessage.

Original message preceded by optional prefix and followed by location information, message and location information separated by a linefeed

Annotations
@Override
getPathback to summary
public List<JSONObjectException.Reference> getPath()

Method for accessing full structural path within type hierarchy down to problematic property.

getPathReferenceback to summary
public String getPathReference()

Method for accesing description of path that lead to the problem that triggered this exception

getPathReferenceback to summary
public StringBuilder getPathReference(StringBuilder sb)
prependPathback to summary
public void prependPath(Object referrer, String fieldName)

Method called to prepend a reference information in front of current path

prependPathback to summary
public void prependPath(Object referrer, int index)

Method called to prepend a reference information in front of current path

prependPathback to summary
public void prependPath(JSONObjectException.Reference r)
toStringback to summary
public String toString()

Overrides com.fasterxml.jackson.core.JsonProcessingException.toString.

Doc from java.lang.Throwable.toString.

Returns a short description of this throwable. The result is the concatenation of:

  • the name of the class of this object
  • ": " (a colon and a space)
  • the result of invoking this object's getLocalizedMessage method
If getLocalizedMessage returns null, then just the class name is returned.
Returns:String

a string representation of this throwable.

Annotations
@Override
wrapWithPathback to summary
public static JSONObjectException wrapWithPath(Throwable src, Object refFrom, String refFieldName)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through a non-indexed object, such as a Map or POJO/bean.

wrapWithPathback to summary
public static JSONObjectException wrapWithPath(Throwable src, Object refFrom, int index)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through an index, which happens with arrays and Collections.

wrapWithPathback to summary
public static JSONObjectException wrapWithPath(Throwable src, JSONObjectException.Reference ref)

Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.

com.fasterxml.jackson.jr.ob back to summary

public Class JSONObjectException.Reference

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Simple bean class used to contain references. References can be added to indicate execution/reference path that lead to the problem that caused this exception to be thrown.

Field Summary

Modifier and TypeField and Description
protected String
_fieldName

Name of field (for beans) or key (for Maps) that is part of the reference.

protected Object
_from

Object through which reference was resolved.

protected int
_index

Index within a Collection instance that contained the reference; used if index is relevant and available.

private static final long

Constructor Summary

AccessConstructor and Description
protected
Reference()

Default constructor for deserialization/sub-classing purposes

public
public
Reference(Object from, String fieldName)

public
Reference(Object from, int index)

Method Summary

Modifier and TypeMethod and Description
public String
public Object
public int
public void
public void
public void
setIndex(int ix)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_fieldNameback to summary
protected String _fieldName

Name of field (for beans) or key (for Maps) that is part of the reference. May be null for Collection types (which generally have _index defined), or when resolving Map classes without (yet) having an instance to operate on.

_fromback to summary
protected Object _from

Object through which reference was resolved. Can be either actual instance (usually the case for serialization), or Class (usually the case for deserialization).

_indexback to summary
protected int _index

Index within a Collection instance that contained the reference; used if index is relevant and available. If either not applicable, or not available, -1 is used to denote "not known".

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Referenceback to summary
protected Reference()

Default constructor for deserialization/sub-classing purposes

Referenceback to summary
public Reference(Object from)
Referenceback to summary
public Reference(Object from, String fieldName)
Referenceback to summary
public Reference(Object from, int index)

Method Detail

getFieldNameback to summary
public String getFieldName()
getFromback to summary
public Object getFrom()
getIndexback to summary
public int getIndex()
setFieldNameback to summary
public void setFieldName(String n)
setFromback to summary
public void setFrom(Object o)
setIndexback to summary
public void setIndex(int ix)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override