Commit Graph

137 Commits

Author SHA1 Message Date
Inderjeet Singh
83e5a4937c Renamed Gson.getNextAdapter to getDelegateAdapter.
Deleted testParameterizedMapSubclassDeserialization which we decided to not fix.
Added simple tests for getDelegateAdapter
2012-04-12 18:49:27 +00:00
Jesse Wilson
9be0fd9ecc Make the BigDecimal and BigInteger type adapters user-overrideable. 2012-03-18 17:55:15 +00:00
Jesse Wilson
dd86d63436 Use inner classes for BigDecimal and BigInteger type adapters 2012-02-11 20:14:23 +00:00
Jesse Wilson
bb8dca71c4 Restore ability of instance creators to create collection and map types. We inadvertently lost this in Gson 2.0 and 2.1. Nobody noticed! 2012-01-01 15:46:33 +00:00
Jesse Wilson
796a381279 Kill GsonInternalAccess. Clients to this were all broken because nobody was ever assigning INSTANCE. 2012-01-01 12:42:20 +00:00
Inderjeet Singh
6c78bf5247 made toJson/fromJson/toJsonTree methods public in TypeAdapter.
made Gson.getNextAdapter method public.
2011-12-31 08:52:59 +00:00
Jesse Wilson
ecdf9150f6 Hide Gson.getNextAdapter() for the current release. 2011-12-31 05:30:40 +00:00
Jesse Wilson
4057b98bab Implement all but the most difficult part of graph type adapter's deserialization. The catch is we want to return an instance that we don't have yet. It's on the stack, but we don't have a handle to it because it's inside the 'nextTypeAdapter' who is busy populating its fields. 2011-12-30 08:27:24 +00:00
Jesse Wilson
d7fbac0384 Rename TypeAdapter.Factory to TypeAdapterFactory. 2011-12-23 18:27:13 +00:00
Inderjeet Singh
bd937fe7b5 A type adapter for Class that throws an UnsupportedOperationException. 2011-12-22 22:31:43 +00:00
Inderjeet Singh
756131d869 removed Eclipse 3.7 warnings. 2011-12-04 10:24:07 +00:00
Jesse Wilson
f602bce9f5 Nice documentation for TypeAdapter. 2011-12-03 19:46:25 +00:00
Inderjeet Singh
8ee2c24f61 renamed JsonElementReader to JsonTreeReader 2011-12-03 02:37:27 +00:00
Jesse Wilson
8f8e69a364 Add @since tags. 2011-12-02 23:11:28 +00:00
Jesse Wilson
4c06b01369 Cache all computed type adapters. On one particularly violent test (issue 375) this improves performance by 77%. 2011-11-26 15:30:38 +00:00
Jesse Wilson
bc68d7293c Comment clean up. 2011-11-23 13:39:06 +00:00
Jesse Wilson
1794182a56 Commit to factories as the mechanism to lookup type adapters. This uses factories for type hierarchy adapters. We keep a separate list of factories for tree-style adapters registered with registerTypeHierarchyAdapter to guarantee that these come after the non-hierarchy adapters.
This drops support for type hierarchy instance creators. I don't expect this to be a problem. We'll also detect fewer errors where multiple type adapters can serialize the same type. With APIs like getNextTypeAdapter, I think this might actually be an improvement!
2011-11-23 06:16:55 +00:00
Jesse Wilson
aa2f61b7d8 Rename GsonExclusionStrategy to Excluder. The new class is its own factory, which simplifies its caller in GsonBuilder. It no longer implements ExclusionStrategy, which allows the callers to pass in a boolean for serialize/deserialize. This allows us to use one excluder for both code paths. The delegate ExclusionStrategy instances might end up not being shared so it has two lists internally. 2011-11-22 07:37:13 +00:00
Jesse Wilson
fed332906d Create a single, monolithic class to manage all exclusion strategies. This gets our file size within target of 177KiB.
I intend to follow this up with a builder for our new class to avoid multiple-argument constructor calls.
2011-11-22 06:07:18 +00:00
Jesse Wilson
7def596775 Begin to tighten the ExclusionStrategy code. This replaces named classes with anonymous classes wherever we have a single instance of a type. 2011-11-21 06:14:23 +00:00
Jesse Wilson
e23973afec Smash together ReflectiveTypeAdapterFactory and its subclass. The separation was useful earlier when we were contemplating keeping Gson and MiniGson separate. 2011-11-21 05:42:30 +00:00
Jesse Wilson
f89e92aa9f Tighten up some of the fields naming policy code. The main thrust of this change is replacing classes like UpperCaseNamingPolicy with the corresponding method calls. Classes like CompositeFieldNamingPolicy are replaced by sequences of method calls. This also replaces unit tests with functional tests.
One nice benefit of this is a 3%/5.7KiB reduction in the size of gson.jar to 184KiB.
2011-11-21 05:08:23 +00:00
Jesse Wilson
d391584d48 Register Gson 1.x tree-style adapters in the TypeAdapter.Factory list rather than in the ParameterizedTypeHandlerMap.
The motivation for this change is to give tree-style adapters precedence order in registration. This fixes the test I committed earlier today, where registration order was not honored.

This renamed ParameterizedTypeHandlerMap to the shorter 'TypeMap'. For type adapters, this is now only used for type hierarchy. We still need non-hierarchy support in TypeMap for instance creators; I'll be looking for workarounds to see if further simplification is possible here.
2011-11-20 19:55:01 +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
Joel Leitch
a92cf394e8 Fix compile issues found during release. 2011-11-13 20:04:29 +00:00
Joel Leitch
2cbddbbbc5 - Remove unnecessary catch block 2011-11-13 00:04:39 +00:00
Jesse Wilson
016261d9cf Throw JsonParseException in event of binding failures like type mismatches. 2011-10-24 01:32:46 +00:00
Jesse Wilson
052c9ce0ce Honor our 'ignore nulls' policy when converting objects to JSON trees. 2011-10-23 20:28:04 +00:00
Jesse Wilson
90c9eadda1 custom-collections 2011-10-22 19:25:30 +00:00
Inderjeet Singh
339d3dd4d0 The real reason for this CL is to claim commit #1000 :)
Tiny performance enhancement: Reordered type orders to move up String and Integer which are likely to be most common fields.
2011-10-20 21:42:45 +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
0e02cbb33e Nulls are here to stay. Sigh. 2011-10-14 03:20:05 +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
de727d8c48 Delete dead code found by coverage 2011-10-01 02:04:48 +00:00
Jesse Wilson
38ce53766e More consistency on serializeNulls: we never emit the empty string for top-level objects. 2011-10-01 01:10:11 +00:00
Jesse Wilson
de835d4dcd Roll back JsonSerializationContext and JsonDeserializationContext to their 1.7.2 API. 2011-10-01 00:58:25 +00:00
Inderjeet Singh
d3f927eb42 Pure refactorings:
Replaced DEFAULT_SERIALIZERS, DEFAULT_DESERIALIZERS and DEFAULT_INSTANCE_CREATORS with a single EMPTY_MAP.
Removed obsoleted TODO from Gson.
made ParameterizedTypeHandlerMap.makeUnmodifiable a builder method that returns this instance.
2011-09-30 17:56:40 +00:00
Inderjeet Singh
1470f20fc0 Removed unused field 2011-09-30 17:11:44 +00:00
Inderjeet Singh
47a36fd095 Fixed Eclipse warnings 2011-09-30 17:08:35 +00:00
Jesse Wilson
cf15565243 Don't round trip through strings 2011-09-30 07:24:07 +00:00
Jesse Wilson
bb7f0b6bb0 Adopt JsonElementWriter in GSON.
Add setSerializeNulls() to JsonWriter, so nulls can be skipped from serialization. This does not yet impact JsonElementWriter.

One change in behavior: if the only value is skipped, we now emit "null" rather than "".
2011-09-30 07:08:44 +00:00
Jesse Wilson
46e65a77c5 Convert RuntimeTypeAdapter to a TypeAdapterFactory; this avoids the need for serializeDefault() 2011-09-28 19:14:46 +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
467011c7ab Allowed users to override default type adapters for various classes. 2011-09-20 00:27:33 +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