/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson;
import com.google.gson.internal.$Gson$Types;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.TreeSet;
import java.util.UUID;
/**
* List of all the default type adapters ({@link JsonSerializer}s, {@link JsonDeserializer}s,
* and {@link InstanceCreator}s.
*
* @author Inderjeet Singh
* @author Joel Leitch
*/
final class DefaultTypeAdapters {
private static final DefaultDateTypeAdapter DATE_TYPE_ADAPTER = new DefaultDateTypeAdapter();
private static final DefaultJavaSqlDateTypeAdapter JAVA_SQL_DATE_TYPE_ADAPTER =
new DefaultJavaSqlDateTypeAdapter();
private static final DefaultTimeTypeAdapter TIME_TYPE_ADAPTER =
new DefaultTimeTypeAdapter();
private static final DefaultTimestampDeserializer TIMESTAMP_DESERIALIZER =
new DefaultTimestampDeserializer();
@SuppressWarnings("unchecked")
private static final EnumTypeAdapter ENUM_TYPE_ADAPTER = new EnumTypeAdapter();
private static final UrlTypeAdapter URL_TYPE_ADAPTER = new UrlTypeAdapter();
private static final UriTypeAdapter URI_TYPE_ADAPTER = new UriTypeAdapter();
private static final UuidTypeAdapter UUUID_TYPE_ADAPTER = new UuidTypeAdapter();
private static final LocaleTypeAdapter LOCALE_TYPE_ADAPTER = new LocaleTypeAdapter();
private static final BitSetTypeAdapter BIT_SET_ADAPTER = new BitSetTypeAdapter();
private static final DefaultInetAddressAdapter INET_ADDRESS_ADAPTER =
new DefaultInetAddressAdapter();
private static final CollectionTypeAdapter COLLECTION_TYPE_ADAPTER = new CollectionTypeAdapter();
private static final MapTypeAdapter MAP_TYPE_ADAPTER = new MapTypeAdapter();
private static final BigDecimalTypeAdapter BIG_DECIMAL_TYPE_ADAPTER = new BigDecimalTypeAdapter();
private static final BigIntegerTypeAdapter BIG_INTEGER_TYPE_ADAPTER = new BigIntegerTypeAdapter();
private static final BooleanTypeAdapter BOOLEAN_TYPE_ADAPTER = new BooleanTypeAdapter();
private static final ByteTypeAdapter BYTE_TYPE_ADAPTER = new ByteTypeAdapter();
private static final CharacterTypeAdapter CHARACTER_TYPE_ADAPTER = new CharacterTypeAdapter();
private static final DoubleDeserializer DOUBLE_TYPE_ADAPTER = new DoubleDeserializer();
private static final FloatDeserializer FLOAT_TYPE_ADAPTER = new FloatDeserializer();
private static final IntegerTypeAdapter INTEGER_TYPE_ADAPTER = new IntegerTypeAdapter();
private static final LongDeserializer LONG_DESERIALIZER = new LongDeserializer();
private static final NumberTypeAdapter NUMBER_TYPE_ADAPTER = new NumberTypeAdapter();
private static final ShortTypeAdapter SHORT_TYPE_ADAPTER = new ShortTypeAdapter();
private static final StringTypeAdapter STRING_TYPE_ADAPTER = new StringTypeAdapter();
private static final StringBuilderTypeAdapter STRING_BUILDER_TYPE_ADAPTER =
new StringBuilderTypeAdapter();
private static final StringBufferTypeAdapter STRING_BUFFER_TYPE_ADAPTER =
new StringBufferTypeAdapter();
private static final GregorianCalendarTypeAdapter GREGORIAN_CALENDAR_TYPE_ADAPTER =
new GregorianCalendarTypeAdapter();
// The constants DEFAULT_SERIALIZERS, DEFAULT_DESERIALIZERS, and DEFAULT_INSTANCE_CREATORS
// must be defined after the constants for the type adapters. Otherwise, the type adapter
// constants will appear as nulls.
private static final ParameterizedTypeHandlerMap<JsonSerializer<?>> DEFAULT_SERIALIZERS =
createDefaultSerializers();
static final ParameterizedTypeHandlerMap<JsonSerializer<?>> DEFAULT_HIERARCHY_SERIALIZERS =
createDefaultHierarchySerializers();
private static final ParameterizedTypeHandlerMap<JsonDeserializer<?>> DEFAULT_DESERIALIZERS =
createDefaultDeserializers();
static final ParameterizedTypeHandlerMap<JsonDeserializer<?>> DEFAULT_HIERARCHY_DESERIALIZERS =
createDefaultHierarchyDeserializers();
private static final ParameterizedTypeHandlerMap<InstanceCreator<?>> DEFAULT_INSTANCE_CREATORS =
createDefaultInstanceCreators();
private static ParameterizedTypeHandlerMap<JsonSerializer<?>> createDefaultSerializers() {
ParameterizedTypeHandlerMap<JsonSerializer<?>> map =
new ParameterizedTypeHandlerMap<JsonSerializer<?>>();
map.register(URL.class, URL_TYPE_ADAPTER, true);
map.register(URI.class, URI_TYPE_ADAPTER, true);
map.register(UUID.class, UUUID_TYPE_ADAPTER, true);
map.register(Locale.class, LOCALE_TYPE_ADAPTER, true);
map.register(Date.class, DATE_TYPE_ADAPTER, true);
map.register(java.sql.Date.class, JAVA_SQL_DATE_TYPE_ADAPTER, true);
map.register(Timestamp.class, DATE_TYPE_ADAPTER, true);
map.register(Time.class, TIME_TYPE_ADAPTER, true);
map.register(Calendar.class, GREGORIAN_CALENDAR_TYPE_ADAPTER, true);
map.register(GregorianCalendar.class, GREGORIAN_CALENDAR_TYPE_ADAPTER, true);
map.register(BigDecimal.class, BIG_DECIMAL_TYPE_ADAPTER, true);
map.register(BigInteger.class, BIG_INTEGER_TYPE_ADAPTER, true);
map.register(BitSet.class, BIT_SET_ADAPTER, true);
// Add primitive serializers
map.register(Boolean.class, BOOLEAN_TYPE_ADAPTER, true);
map.register(boolean.class, BOOLEAN_TYPE_ADAPTER, true);
map.register(Byte.class, BYTE_TYPE_ADAPTER, true);
map.register(byte.class, BYTE_TYPE_ADAPTER, true);
map.register(Character.class, CHARACTER_TYPE_ADAPTER, true);
map.register(char.class, CHARACTER_TYPE_ADAPTER, true);
map.register(Integer.class, INTEGER_TYPE_ADAPTER, true);
map.register(int.class, INTEGER_TYPE_ADAPTER, true);
map.register(Number.class, NUMBER_TYPE_ADAPTER, true);
map.register(Short.class, SHORT_TYPE_ADAPTER, true);
map.register(short.class, SHORT_TYPE_ADAPTER, true);
map.register(String.class, STRING_TYPE_ADAPTER, true);
map.register(StringBuilder.class, STRING_BUILDER_TYPE_ADAPTER, true);
map.register(StringBuffer.class, STRING_BUFFER_TYPE_ADAPTER, true);
map.makeUnmodifiable();
return map;
}
private static ParameterizedTypeHandlerMap<JsonSerializer<?>> createDefaultHierarchySerializers() {
ParameterizedTypeHandlerMap<JsonSerializer<?>> map =
new ParameterizedTypeHandlerMap<JsonSerializer<?>>();
map.registerForTypeHierarchy(Enum.class, ENUM_TYPE_ADAPTER, true);
map.registerForTypeHierarchy(InetAddress.class, INET_ADDRESS_ADAPTER, true);
map.registerForTypeHierarchy(Collection.class, COLLECTION_TYPE_ADAPTER, true);
map.registerForTypeHierarchy(Map.class, MAP_TYPE_ADAPTER, true);
map.makeUnmodifiable();
return map;
}
没有合适的资源?快使用搜索试试~ 我知道了~
AndroidJSON解析框架GSON
共295个文件
java:185个
html:97个
xml:7个
需积分: 10 16 下载量 99 浏览量
2015-07-03
10:57:48
上传
评论
收藏 573KB ZIP 举报
温馨提示
AndroidJSON解析框架GSON,可以方便的解析JSON,提高效率,欢迎大家下载使用。
资源推荐
资源详情
资源评论
收起资源包目录
AndroidJSON解析框架GSON (295个子文件)
stylesheet.css 1KB
inherit.gif 57B
index-all.html 93KB
Gson.html 63KB
GsonBuilder.html 52KB
JsonElement.html 43KB
JsonReader.html 42KB
JsonArray.html 41KB
JsonWriter.html 39KB
JsonPrimitive.html 35KB
JsonObject.html 32KB
$Gson$Types.html 30KB
JsonElement.html 28KB
JsonToken.html 23KB
FieldNamingPolicy.html 21KB
GsonBuilder.html 21KB
TypeToken.html 21KB
LongSerializationPolicy.html 19KB
JsonParseException.html 18KB
JsonStreamParser.html 18KB
FieldAttributes.html 18KB
JsonSyntaxException.html 17KB
JsonParser.html 17KB
JsonIOException.html 17KB
MalformedJsonException.html 16KB
JsonWriter.html 16KB
JsonSyntaxException.html 16KB
JsonIOException.html 15KB
JsonNull.html 15KB
package-summary.html 14KB
overview-tree.html 14KB
ExclusionStrategy.html 13KB
$Gson$Preconditions.html 13KB
JsonDeserializer.html 12KB
package-use.html 12KB
Expose.html 12KB
JsonSerializer.html 12KB
InstanceCreator.html 12KB
JsonSerializationContext.html 12KB
SerializedName.html 11KB
JsonParseException.html 11KB
package-tree.html 11KB
Until.html 11KB
Since.html 11KB
JsonDeserializationContext.html 10KB
TypeToken.html 10KB
LongSerializationPolicy.html 10KB
help-doc.html 10KB
FieldNamingPolicy.html 10KB
ExclusionStrategy.html 9KB
JsonArray.html 9KB
FieldNamingStrategy.html 9KB
JsonReader.html 9KB
JsonToken.html 9KB
JsonDeserializationContext.html 9KB
JsonPrimitive.html 9KB
package-use.html 9KB
JsonSerializationContext.html 8KB
JsonObject.html 8KB
package-tree.html 8KB
FieldNamingStrategy.html 8KB
serialized-form.html 8KB
package-summary.html 8KB
FieldAttributes.html 8KB
JsonNull.html 8KB
Gson.html 8KB
package-summary.html 7KB
package-tree.html 7KB
package-summary.html 7KB
package-use.html 7KB
package-summary.html 7KB
overview-summary.html 7KB
deprecated-list.html 7KB
package-tree.html 6KB
package-tree.html 6KB
MalformedJsonException.html 6KB
$Gson$Preconditions.html 6KB
SerializedName.html 6KB
$Gson$Types.html 6KB
Expose.html 6KB
Since.html 6KB
Until.html 6KB
JsonDeserializer.html 6KB
InstanceCreator.html 6KB
JsonSerializer.html 6KB
JsonStreamParser.html 6KB
JsonParser.html 6KB
package-use.html 6KB
package-use.html 6KB
constant-values.html 5KB
allclasses-frame.html 5KB
allclasses-noframe.html 4KB
package-frame.html 4KB
package-frame.html 2KB
overview-frame.html 2KB
index.html 1KB
package-frame.html 1KB
package-frame.html 1KB
package-frame.html 965B
DefaultTypeAdapters.java 42KB
共 295 条
- 1
- 2
- 3
资源评论
预见才能遇见
- 粉丝: 171
- 资源: 93
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功