DESCRIPTION

JCBC-624: improve JsonObject.getNUMBER methods

Motivation
----------
When stored and read back, a JsonObject long field for example can be
restored as an Integer (because it is small enough). This leads to a
ClassCastException when calling the getLong method.
Same is true for the three Number-related get methods : getLong, getInt
and getDouble.
This is also true for equivalent JsonArray methods.

Modifications
-------------
The methods getLong, getInt and getDouble now all expect just a Number
instance in the Json content. If the Number is of the asked type, or if
it is null, it is returned directly. Otherwise it is converted to the
asked type by calling e.g. Number.longValue() method and letting Java
autobox the value.

This modification has been made in both JsonObject and JsonArray.

An integration test  was added (because this is only visible when
storing and transcoding the document), along with two new unit tests in
JsonObjectTest (for conversion and null management).

Documentation on getNUMBER methods reflect the fact that conversion
could induce rounding or truncation (eg going from double to long).

Result
------
Putting a number in a JsonDocument, storing it and getting it back in
any numerical form now works correctly. Nulls are returned correctly
when value is not present. No more ClassCastExceptions occur as long as
the value is numerical. Same for JsonArrayDocuments.
All tests pass.

Change-Id: Ia3ad4e7b7ee9f0b74499aeec0067c88ef9b5925a
Reviewed-on: http://review.couchbase.org/43359
Tested-by: Estrella Humphrey xxx@xxx.xxx
Reviewed-by: Cory Peck xxx@xxx.xxx


COMMENTS

author: Estrella Humphrey
date: 2014-11-18 13:51:14.277000000

Change has been successfully cherry-picked as 77063b116167879ce7497534e669014ad8a12066

-------------------------------------
