Commit Graph

40 Commits

Author SHA1 Message Date
Inderjeet Singh
b5ae3c945a Incorporated code review from r949 2011-12-16 19:10:54 +00:00
Jesse Wilson
a3ca4e1312 Admit to a mistake in InetAddress' type adapter 2011-12-16 19:05:10 +00:00
Jesse Wilson
c01fc5c935 Fix tests broken by r1078. 2011-12-16 14:12:34 +00:00
Jesse Wilson
214234e202 Support @SerializedName on annotations.
Fixes issue 347.
2011-12-16 05:32:50 +00:00
Jesse Wilson
f602bce9f5 Nice documentation for TypeAdapter. 2011-12-03 19:46:25 +00:00
Jesse Wilson
26ab404599 Cleanup names for TypeAdapters. 2011-12-02 22:57:30 +00:00
Jesse Wilson
f777a192ee Remove dead code and fold contents of single-member helper classes into their clients. 2011-11-20 21:02:26 +00:00
Jesse Wilson
7e760143fd Smash together MiniGson and Gson. This changes Gson to be the MiniGson rather than delegating to the MiniGson. It means that the MiniGson objects passed into streaming type adapters are now fully-capable 'Gson' objects.
The most notable impact of this change is that it adds several new public APIs:
 - The TypeAdapter abstract class
 - The TypeAdapter.Factory interface
 - Four new methods on GsonBuilder to register streaming TypeAdapters (via Factory, via Class, via TypeToken, and as a type hierarchy)
 - Three new methods on Gson to lookup streaming TypeAdapters (by type, by class, and to get the next type adapter) 

Still outstanding:
 - Write beautiful prose to document the new APIs above
 - Change GsonBuilder's precedence so that both old and new-style type adapters are registered in one lot
2011-11-20 15:23:08 +00:00
Jesse Wilson
0340e01f98 Support booleans as strings in stream binding. Remove support for interpreting "1" as true.
Interpreting '1' as true was not backwards compatible.
2011-10-23 21:41:30 +00:00
Jesse Wilson
94d59b550e Give a nice toString on type adapter factories to make debugging easier. 2011-10-22 19:26:15 +00:00
Inderjeet Singh
31964507c1 Updated SuppressWarnings annotations to Eclipse 3.6/3.7 which is unfortunately incompatible with Eclipse 3.5 (rawtypes vs unchecked)
This CL eliminates all eclipse warnings.
2011-10-20 21:32:46 +00:00
Jesse Wilson
194c18d20c Be backwards-compatible for serialization of maps whose keys aren't primitives. 2011-10-20 04:24:27 +00:00
Jesse Wilson
0e02cbb33e Nulls are here to stay. Sigh. 2011-10-14 03:20:05 +00:00
Jesse Wilson
5db4caeec5 A whole bunch of tests for support for null elements.
Fixes bug 369
2011-10-14 03:17:12 +00:00
Jesse Wilson
65df3b97ba Add a type adapter for JsonElement, so it serializes just like everything else.
Fixes issue 362.
2011-10-02 16:59:56 +00:00
Jesse Wilson
3f26144165 Fix date adapters to work when run in any time zone. 2011-09-28 17:56:54 +00:00
Jesse Wilson
3b3a60d301 Use new instances of DateTypeAdapter and TimeTypeAdapter for each GSON; this guarantees that the TimeZone and Locale are what they should be 2011-09-26 21:44:08 +00:00
Inderjeet Singh
c1bac6debf Converted Date type adapter to the new style. This was the last remaining old style default type adapter. 2011-09-25 21:51:28 +00:00
Inderjeet Singh
81854db4ac Converted java.sql.Timestamp type adapter to the new style. 2011-09-25 21:35:36 +00:00
Inderjeet Singh
f9b6c2095f Converted java.sql.Time type adapter to the new style. 2011-09-23 18:42:45 +00:00
Inderjeet Singh
8217aca925 Converted java.sql.Date type adapters to the new style. 2011-09-20 00:26:37 +00:00
Inderjeet Singh
d20df34b8b Converted Calendar/GregorianCalendar type adapters to the new style. 2011-09-20 00:08:33 +00:00
Inderjeet Singh
4402240294 Converted Number type adapter to the new style. 2011-09-19 17:02:02 +00:00
Inderjeet Singh
b5f8ef6e16 Converted CharacterTypeAdapter to the new style. 2011-09-16 05:58:41 +00:00
Inderjeet Singh
c71e61cf48 Converted EnumTypeAdapter to new style.
Got rid of default Hierarchy Serializer/Deserializers from DefaultTypeAdapters.
Got rid of methods for gettting default serializers/deserializers/instance creators. Instead we reuse the static final instances.
Fixed warnings in TypeAdapters where a parameterized type T was hiding the parameterized T in methods.
Removed support to unwrap single element array of enums into enum values. Also removed the test that verifies this behavior.
2011-09-16 05:40:05 +00:00
Inderjeet Singh
915c5d4d6f Converted BitSetTypeAdapter to the new style. 2011-09-16 05:02:30 +00:00
Joel Leitch
b90b43ea47 A few minor fixes and one incompatible Java 1.6 API call. 2011-09-16 04:55:52 +00:00
Jesse Wilson
25c6ae177b Down to 22 failing tests.
Consolidated all of the different code paths that we use to construct instances. We now have an ObjectConstructor class that knows what type it constructs; this means that we don't need to ever do reflection to lookup a constructor at construction time.

Cleaned up some buggy type adapters, particularly around handling of null.

Removed dead code for object graph navigation.

Moved some classes into 'internal' so they are visible to the 'bind' subpackage.

Turned some TypeAdapterFactory/TypeAdapter pairs inside out so that the TypeAdapter is now the inner class. This is necessary so that the factories can take parameters.

Added an API to request the 'next' type adapter for a type. This allows type adapters to compose other type adapters. We're using this in two places:
 - where the user has excluded a type from serialization but not deserialization, we need to use the "default" deserialization but interpose null on serialization. We create a type adapter that delegates for one and returns null for the other.
 - similarly when a DOM type serializer is registered but no deserializer, or vice versa.
This is the biggest change to the MiniGson core.

For backwards compatibility, return null for the empty string.

Simplify JsonSerializationContext/JsonDeserializationContext to simply call through to GSON. SerializeDefault is currently unsupported.

More useful error messages when calling getAsBoolean on a JsonNull.

Remove currently unused MemoryRefStack. We might need this back again, though wiring it back in will be much more difficult because we don't interject ourselves between the users' various type adapters.
2011-09-11 07:04:56 +00:00
Jesse Wilson
f3c0a96f44 Support incoming nulls in all default type adapters 2011-09-09 05:46:50 +00:00
Jesse Wilson
e19672d0a3 Throw the right exceptions when primitives fail to parse. 2011-09-09 05:04:24 +00:00
Jesse Wilson
9db0c53217 Adapt bytes 2011-09-09 04:39:29 +00:00
Inderjeet Singh
ea9c0236c7 Converted InetAddress type adapter to new style. 2011-09-09 04:02:12 +00:00
Jesse Wilson
4f6a36d68f Support reading nulls into strings 2011-09-09 03:40:39 +00:00
Inderjeet Singh
9fb39c89ea Switched Locale type adapter to new-style. 2011-08-26 03:14:01 +00:00
Inderjeet Singh
f9976f4b01 Switched Short, URI, URL, UUID, StringBuilder and StringBuffer type adapters to new-style. 2011-08-26 02:33:54 +00:00
Jesse Wilson
fc99556f22 Support type exclusion strategies. 2011-08-05 00:25:49 +00:00
Jesse Wilson
1885ba7dec Restore support for serializeSpecialFloatingPointValues. 2011-08-04 23:12:49 +00:00
Jesse Wilson
aa067056c3 Restore support for long serialization policy. 2011-08-04 22:57:36 +00:00
Inderjeet Singh
f276d13827 Added support for deserialization exclusion strategy. 2011-08-03 01:19:26 +00:00
Jesse Wilson
60e6ed912d Promote MiniGson to gson.internal.bind 2011-08-03 00:25:10 +00:00