Commit Graph

118 Commits

Author SHA1 Message Date
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
Jesse Wilson a98d6eae47 Fix the map type adapter to support array serialization natively. 2011-09-12 05:51:17 +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 e756608568 Forbid custom serializers for primitive types (so we can avoid boxing in the reflective and array adapters) 2011-09-09 06:26:21 +00:00
Jesse Wilson aa067056c3 Restore support for long serialization policy. 2011-08-04 22:57:36 +00:00
Inderjeet Singh 9196b23251 Refactoring: Separated type handler maps into two types: one for system-specified handlers and one for user-specified. system-specified handlers are the ones that Gson comes with (DefaultTypeAdapters). 2011-06-24 21:52:59 +00:00
Joel Leitch ecf137fec3 More fixes to JavaDoc. 2011-04-11 19:01:07 +00:00
Joel Leitch c5c7c5bb64 More fixes to JavaDoc. 2011-04-11 18:52:29 +00:00
Joel Leitch 49e7ee05fc Fix method name by making it singular. 2011-04-11 18:44:19 +00:00
Joel Leitch c266097310 Fix minor JavaDoc issue. 2011-04-11 18:33:46 +00:00
Joel Leitch 457b37f08e Replace var-args with single parameter. 2011-04-11 18:09:59 +00:00
Inderjeet Singh 4bd261ae06 Made FieldNamingStrategy2 and its corresponding builder method package-private. 2011-04-07 17:41:35 +00:00
Inderjeet Singh 7afda06253 Added warning in GsonBuilder regarding setting date format correctly. 2011-04-06 00:35:05 +00:00
Inderjeet Singh c8bd121db2 Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types.
Marked the two private classes in $Types as final.
2011-04-06 00:26:57 +00:00
Joel Leitch dc283e1121 Fixed comments from r774. 2011-04-05 23:36:05 +00:00
Joel Leitch f36c1bc222 Very minor cleanup. 2011-04-04 23:17:43 +00:00
Inderjeet Singh 542a17c3bc Incorporated comments from r710 2011-04-04 22:48:34 +00:00
Jesse Wilson f718784f33 Use the date format for java.sql.Date and java.sql.Timestamp.
Fixes issue 230.
2011-03-29 21:36:19 +00:00
Jesse Wilson 4efb133b4a bling bling
Prefix internal classes with $ to prevent them from interfering with IDE's auto import functionality.
2011-03-29 21:24:26 +00:00
Joel Leitch 861e047a62 Create an "internals" package for classes that we do not want to share, but is needed across multiple pacakges.
As well, move non-Gson specific classes, such as Preconditions, to this new "internals" package.
2011-03-21 22:30:35 +00:00
Joel Leitch 279c0e87ed Update Precondition checks and have it throw a NPE instead. 2011-03-16 07:23:44 +00:00
Joel Leitch 7b223a8983 Adding JavaDoc to the enableComplexMapKeySerialization method on GsonBuilder. 2011-03-16 07:05:24 +00:00
Joel Leitch e57ef0908b Add method to GsonBuilder to enable complex key serialization of maps. 2011-03-15 15:37:41 +00:00
Inderjeet Singh baf9591d3b Made constructors package private for package private classes. 2011-03-10 23:55:16 +00:00
Inderjeet Singh 52288d7127 rawtypes -> unchecked
Fixed spurious eclipse warnings on deprecation, missing classes or parameters, etc.
2011-02-24 22:47:55 +00:00
Joel Leitch 114633fbf9 Provide a means to add serialization or deserialization specific exclusion strategies. 2011-02-04 03:09:41 +00:00
Joel Leitch fb7bd7b1b7 Deprecate the old FieldNamingStrategy interface and open up the FieldNamingStrategy2 instead to take its place. 2011-01-22 22:27:30 +00:00
Joel Leitch b883f8f4aa Add new "Mode" enum and carry mode through Gson so exclusion strategies know whether it is currently serializing or deserializing.
Deprecate old ExclusionStrategy code since this new approach is more powerful.
2011-01-22 22:15:06 +00:00
Inderjeet Singh 2b9f81e8b5 Registering default type hierarchy adapters first and allow users to override them.
This allows the default EnumTypeAdapter to be overridden for a specific hierachy adapter for Enum with anonymized sub-classes.
2011-01-19 23:28:28 +00:00
Inderjeet Singh 6818edecf9 enabled GsonBuilder.registerTypeHierarchyAdapter since head is now for Gson 1.7 2010-11-25 00:16:06 +00:00
Inderjeet Singh db3f19e881 dropping GsonBuilder.registerTypeHierarchyAdapter() from 1.6 release. 2010-11-24 23:13:29 +00:00
Jesse Wilson dea7ab89fe Restore pretty printing. The pretty printing format isn't as compact as the previous format - for example arrays of integers are printed one-per-line, whereas the previous format compacted these to all sit on the same line. 2010-11-01 23:03:41 +00:00
Inderjeet Singh 2b993d83b6 Made the GsonBuilder registerTypeHierarchyAdapter a public method.
Updated the Gson version number to 1.6 and added @since tag for the new classes
2010-10-27 23:53:09 +00:00
Inderjeet Singh 2b1f3eec15 Removed a bunch of unused code and unnecessary else statements. 2010-09-28 13:42:43 +00:00
Jesse Wilson 747e3c3051 Support mixed streaming and databinding with new APIs. 2010-09-02 00:15:23 +00:00
Inderjeet Singh 24fd66f645 removed @since for non-public classes 2010-08-20 00:35:48 +00:00
Inderjeet Singh dc60cb1931 Made FieldNamingStrategy2 is package protected class.
Made type hierarchy adapter registration package protected.
Marked some of the classes final.
Minor changes in the performance tests.
2010-08-19 00:10:42 +00:00
Joel Leitch 89c18452ae Ensure date with pattern is not override with the "default" date type adapter when a custom JsonSerializer/JsonDeserializer is registered. 2010-08-18 23:58:52 +00:00
Inderjeet Singh 8aedbc84db Added a new GsonBuilder option to register a type adapter for a type hierarchy instead of a single type.
Upgraded Gson version to 1.5 since a new API call is being added.
2010-06-21 23:26:06 +00:00
Joel Leitch e3af076ff2 Deprecate the FieldNamingStrategy interface and replace it with FieldNamingStrategy2. This is the first step to help make it easy to cache field annotations across all instances of a class, etc. 2010-01-09 22:43:27 +00:00
Joel Leitch 6387c9028e Updated JavaDoc formatting 2009-10-09 15:26:34 +00:00
Joel Leitch 10c39317a1 Makes ExclusionStrategy public. 2009-10-08 21:52:56 +00:00
Joel Leitch 839b0c2f94 Refactored exclusion strategies so that they can easily be exposed as part of the public API. 2009-10-07 09:23:14 +00:00
Inderjeet Singh 8567fe6c10 Implementing code review comment from r428: Using Polymorphism for exclusion strategies for expose annotations. 2009-10-01 01:37:57 +00:00
Inderjeet Singh 3b0f8f4340 Removed all the JDK warnings about unused fields in test classes or unused constructors for use by Gson or instanceof calls on parameterized types. 2009-09-23 17:45:16 +00:00
Joel Leitch 18b301dfeb - Serializing of Object arrays.
- Fixed incorrect warning
2009-09-22 19:04:27 +00:00
Inderjeet Singh 82771f006c removed Java 1.5 warnings 2009-08-31 17:51:47 +00:00
Inderjeet Singh 6d50bcea87 Added serialize and deserialize parameters to the Expose annotation that control whether a field gets exposed during serialization or deserialization. 2009-05-19 23:47:53 +00:00
Inderjeet Singh b2b2e5dc0a Implemented enhancement request from issue 42 by supporting a new GsonBuilder setting generateNonExecutableJson() that prefixes the generated JSON with some special text that makes the output non-executable javascript. Gson now recognizes this special text in the input while parsing the JSON in fromJson and filters it out, if present. 2009-03-17 21:15:10 +00:00
Inderjeet Singh 8f456831d4 Fixed Issue 104 by making FieldNamingStrategy to be public and allowing FieldNamingStrategy to be set in GsonBuilder 2009-03-11 21:53:02 +00:00
Joel Leitch 764e4d9aca Performance fixes after doing some profiling. 2009-01-20 08:38:21 +00:00
Joel Leitch 6a80791f13 Code cleanup and some minor performance fixes. 2009-01-20 01:36:54 +00:00
Joel Leitch e2cfc0cc19 Update GsonBuilder API to accept an enum for the serialize Long as string. This will be useful if/when we implement support to serialize a long type as an array of integers. 2009-01-11 06:11:29 +00:00
Inderjeet Singh 3690d362b9 incorporated feedback from r358 2008-12-30 22:42:36 +00:00
Inderjeet Singh e839336eea Incorporated comments from the code review r355 2008-12-30 19:03:43 +00:00
Inderjeet Singh 05f54f3552 Incorporated code review comments from r350 2008-12-30 18:54:33 +00:00
Joel Leitch 73d93e3322 Provide a setting to allow a client to skip the escaping of special HTML characters.
As well, remove the "/" from the list of special HTML characters since it is causing some incompatibilities.
2008-12-28 23:05:22 +00:00
Joel Leitch 1c87bd5993 Some minor update to our JavaDoc 2008-12-28 06:51:11 +00:00
Joel Leitch f923f7f537 Add "@since" JavaDoc to the new methods in GsonBuilder. 2008-12-28 03:35:07 +00:00
Joel Leitch 458f2baa2f Added special serialization of "Long". Now the client has the ability to output a long field as a JSON "String". This is useful for JavaScript clients that need to handle long values.
As well, this change does a major clean up of the custom type adapter handling and ParameterizedTypeMap creation.
2008-12-28 03:23:36 +00:00
Joel Leitch 859af0025c Implement suggestions from self review of r350. 2008-12-28 02:05:40 +00:00
Joel Leitch 54a480774d Add the ability to configure Gson to exclude serializing and deserializing of all "Inner Classes". 2008-12-28 02:00:31 +00:00
Inderjeet Singh 51881c7f4a Added a GsonBuilder setting to enable serialization of special double types, NaN, Infinity, and -Infinity. 2008-12-20 01:26:14 +00:00
Joel Leitch cf2a457af7 Removed the TypeAdapter object from GSON now that the primitive objects and fields are created by a custom Type Adapter. 2008-11-15 05:11:28 +00:00
Inderjeet Singh bc2c25f235 Removed ExceptionWrapper from serializers.
This is done since it is improper to throw a parse exception from serializers. Moreover, the serializers dont deal with external input, they deal with classes, so they need not guard against spurious input.
2008-11-14 02:17:19 +00:00
Inderjeet Singh 9dfa454f6d Fixed issue 63 where Gson could not operate in a thread-safe manner. Resolved the issue by recreating ObjectNavigatorFactory for each call instead of reusing the same object everywhere. This is needed since ObjectNavigatorFactory had MemoryRefStack that was incorrectly being shared across calls. 2008-10-20 20:09:42 +00:00
Inderjeet Singh 2b9fd47b72 Fixed issue 53 where default date instances were not getting
serialized/deserialized properly. Added support for time style as well by using he default formatter that uses time style.
2008-10-13 18:40:20 +00:00
Inderjeet Singh 57d1f32de5 moved gson as a project under trunk 2008-09-01 03:13:32 +00:00