gson-2.2.4

16:36:12.792 INFO  jd.cli.Main - Decompiling gson-2.2.4.jar
package com.google.gson;

public abstract interface ExclusionStrategy
{
  public abstract boolean shouldSkipField(FieldAttributes paramFieldAttributes);
  
  public abstract boolean shouldSkipClass(Class<?> paramClass);
}

/* Location:
 * Qualified Name:     com.google.gson.ExclusionStrategy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

class Gson$4
  extends TypeAdapter<Number>
{
  Gson$4(Gson paramGson) {}
  
  public Float read(JsonReader in)
    throws IOException
  {
    if (in.peek() == JsonToken.NULL)
    {
      in.nextNull();
      return null;
    }
    return Float.valueOf((float)in.nextDouble());
  }
  
  public void write(JsonWriter out, Number value)
    throws IOException
  {
    if (value == null)
    {
      out.nullValue();
      return;
    }
    float floatValue = value.floatValue();
    Gson.access$000(this$0, floatValue);
    out.value(value);
  }
}

/* Location:
 * Qualified Name:     com.google.gson.Gson.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public final class JsonArray
  extends JsonElement
  implements Iterable<JsonElement>
{
  private final List<JsonElement> elements;
  
  public JsonArray()
  {
    elements = new ArrayList();
  }
  
  JsonArray deepCopy()
  {
    JsonArray result = new JsonArray();
    for (JsonElement element : elements) {
      result.add(element.deepCopy());
    }
    return result;
  }
  
  public void add(JsonElement element)
  {
    if (element == null) {
      element = JsonNull.INSTANCE;
    }
    elements.add(element);
  }
  
  public void addAll(JsonArray array)
  {
    elements.addAll(elements);
  }
  
  public int size()
  {
    return elements.size();
  }
  
  public Iterator<JsonElement> iterator()
  {
    return elements.iterator();
  }
  
  public JsonElement get(int i)
  {
    return (JsonElement)elements.get(i);
  }
  
  public Number getAsNumber()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsNumber();
    }
    throw new IllegalStateException();
  }
  
  public String getAsString()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsString();
    }
    throw new IllegalStateException();
  }
  
  public double getAsDouble()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsDouble();
    }
    throw new IllegalStateException();
  }
  
  public BigDecimal getAsBigDecimal()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsBigDecimal();
    }
    throw new IllegalStateException();
  }
  
  public BigInteger getAsBigInteger()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsBigInteger();
    }
    throw new IllegalStateException();
  }
  
  public float getAsFloat()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsFloat();
    }
    throw new IllegalStateException();
  }
  
  public long getAsLong()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsLong();
    }
    throw new IllegalStateException();
  }
  
  public int getAsInt()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsInt();
    }
    throw new IllegalStateException();
  }
  
  public byte getAsByte()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsByte();
    }
    throw new IllegalStateException();
  }
  
  public char getAsCharacter()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsCharacter();
    }
    throw new IllegalStateException();
  }
  
  public short getAsShort()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsShort();
    }
    throw new IllegalStateException();
  }
  
  public boolean getAsBoolean()
  {
    if (elements.size() == 1) {
      return ((JsonElement)elements.get(0)).getAsBoolean();
    }
    throw new IllegalStateException();
  }
  
  public boolean equals(Object o)
  {
    return (o == this) || (((o instanceof JsonArray)) && (elements.equals(elements)));
  }
  
  public int hashCode()
  {
    return elements.hashCode();
  }
}

/* Location:
 * Qualified Name:     com.google.gson.JsonArray
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import com.google.gson.internal..Gson.Preconditions;
import com.google.gson.internal.LazilyParsedNumber;
import java.math.BigDecimal;
import java.math.BigInteger;

public final class JsonPrimitive
  extends JsonElement
{
  private static final Class<?>[] PRIMITIVE_TYPES = { Integer.TYPE, Long.TYPE, Short.TYPE, Float.TYPE, Double.TYPE, Byte.TYPE, Boolean.TYPE, Character.TYPE, Integer.class, Long.class, Short.class, Float.class, Double.class, Byte.class, Boolean.class, Character.class };
  private Object value;
  
  public JsonPrimitive(Boolean bool)
  {
    setValue(bool);
  }
  
  public JsonPrimitive(Number number)
  {
    setValue(number);
  }
  
  public JsonPrimitive(String string)
  {
    setValue(string);
  }
  
  public JsonPrimitive(Character c)
  {
    setValue(c);
  }
  
  JsonPrimitive(Object primitive)
  {
    setValue(primitive);
  }
  
  JsonPrimitive deepCopy()
  {
    return this;
  }
  
  void setValue(Object primitive)
  {
    if ((primitive instanceof Character))
    {
      char c = ((Character)primitive).charValue();
      value = String.valueOf(c);
    }
    else
    {
      .Gson.Preconditions.checkArgument(((primitive instanceof Number)) || (isPrimitiveOrString(primitive)));
      
      value = primitive;
    }
  }
  
  public boolean isBoolean()
  {
    return value instanceof Boolean;
  }
  
  Boolean getAsBooleanWrapper()
  {
    return (Boolean)value;
  }
  
  public boolean getAsBoolean()
  {
    if (isBoolean()) {
      return getAsBooleanWrapper().booleanValue();
    }
    return Boolean.parseBoolean(getAsString());
  }
  
  public boolean isNumber()
  {
    return value instanceof Number;
  }
  
  public Number getAsNumber()
  {
    return (value instanceof String) ? new LazilyParsedNumber((String)value) : (Number)value;
  }
  
  public boolean isString()
  {
    return value instanceof String;
  }
  
  public String getAsString()
  {
    if (isNumber()) {
      return getAsNumber().toString();
    }
    if (isBoolean()) {
      return getAsBooleanWrapper().toString();
    }
    return (String)value;
  }
  
  public double getAsDouble()
  {
    return isNumber() ? getAsNumber().doubleValue() : Double.parseDouble(getAsString());
  }
  
  public BigDecimal getAsBigDecimal()
  {
    return (value instanceof BigDecimal) ? (BigDecimal)value : new BigDecimal(value.toString());
  }
  
  public BigInteger getAsBigInteger()
  {
    return (value instanceof BigInteger) ? (BigInteger)value : new BigInteger(value.toString());
  }
  
  public float getAsFloat()
  {
    return isNumber() ? getAsNumber().floatValue() : Float.parseFloat(getAsString());
  }
  
  public long getAsLong()
  {
    return isNumber() ? getAsNumber().longValue() : Long.parseLong(getAsString());
  }
  
  public short getAsShort()
  {
    return isNumber() ? getAsNumber().shortValue() : Short.parseShort(getAsString());
  }
  
  public int getAsInt()
  {
    return isNumber() ? getAsNumber().intValue() : Integer.parseInt(getAsString());
  }
  
  public byte getAsByte()
  {
    return isNumber() ? getAsNumber().byteValue() : Byte.parseByte(getAsString());
  }
  
  public char getAsCharacter()
  {
    return getAsString().charAt(0);
  }
  
  private static boolean isPrimitiveOrString(Object target)
  {
    if ((target instanceof String)) {
      return true;
    }
    Class<?> classOfPrimitive = target.getClass();
    for (Class<?> standardPrimitive : PRIMITIVE_TYPES) {
      if (standardPrimitive.isAssignableFrom(classOfPrimitive)) {
        return true;
      }
    }
    return false;
  }
  
  public int hashCode()
  {
    if (this.value == null) {
      return 31;
    }
    if (isIntegral(this))
    {
      long value = getAsNumber().longValue();
      return (int)(value ^ value >>> 32);
    }
    if ((this.value instanceof Number))
    {
      long value = Double.doubleToLongBits(getAsNumber().doubleValue());
      return (int)(value ^ value >>> 32);
    }
    return this.value.hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if ((obj == null) || (getClass() != obj.getClass())) {
      return false;
    }
    JsonPrimitive other = (JsonPrimitive)obj;
    if (value == null) {
      return value == null;
    }
    if ((isIntegral(this)) && (isIntegral(other))) {
      return getAsNumber().longValue() == other.getAsNumber().longValue();
    }
    if (((value instanceof Number)) && ((value instanceof Number)))
    {
      double a = getAsNumber().doubleValue();
      
      double b = other.getAsNumber().doubleValue();
      return (a == b) || ((Double.isNaN(a)) && (Double.isNaN(b)));
    }
    return value.equals(value);
  }
  
  private static boolean isIntegral(JsonPrimitive primitive)
  {
    if ((value instanceof Number))
    {
      Number number = (Number)value;
      return ((number instanceof BigInteger)) || ((number instanceof Long)) || ((number instanceof Integer)) || ((number instanceof Short)) || ((number instanceof Byte));
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     com.google.gson.JsonPrimitive
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;

final class DefaultDateTypeAdapter
  implements JsonSerializer<java.util.Date>, JsonDeserializer<java.util.Date>
{
  private final DateFormat enUsFormat;
  private final DateFormat localFormat;
  private final DateFormat iso8601Format;
  
  DefaultDateTypeAdapter()
  {
    this(DateFormat.getDateTimeInstance(2, 2, Locale.US), DateFormat.getDateTimeInstance(2, 2));
  }
  
  DefaultDateTypeAdapter(String datePattern)
  {
    this(new SimpleDateFormat(datePattern, Locale.US), new SimpleDateFormat(datePattern));
  }
  
  DefaultDateTypeAdapter(int style)
  {
    this(DateFormat.getDateInstance(style, Locale.US), DateFormat.getDateInstance(style));
  }
  
  public DefaultDateTypeAdapter(int dateStyle, int timeStyle)
  {
    this(DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.US), DateFormat.getDateTimeInstance(dateStyle, timeStyle));
  }
  
  DefaultDateTypeAdapter(DateFormat enUsFormat, DateFormat localFormat)
  {
    this.enUsFormat = enUsFormat;
    this.localFormat = localFormat;
    iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
    iso8601Format.setTimeZone(TimeZone.getTimeZone("UTC"));
  }
  
  public JsonElement serialize(java.util.Date src, Type typeOfSrc, JsonSerializationContext context)
  {
    synchronized (localFormat)
    {
      String dateFormatAsString = enUsFormat.format(src);
      return new JsonPrimitive(dateFormatAsString);
    }
  }
  
  public java.util.Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
    throws JsonParseException
  {
    if (!(json instanceof JsonPrimitive)) {
      throw new JsonParseException("The date should be a string value");
    }
    java.util.Date date = deserializeToDate(json);
    if (typeOfT == java.util.Date.class) {
      return date;
    }
    if (typeOfT == Timestamp.class) {
      return new Timestamp(date.getTime());
    }
    if (typeOfT == java.sql.Date.class) {
      return new java.sql.Date(date.getTime());
    }
    throw new IllegalArgumentException(getClass() + " cannot deserialize to " + typeOfT);
  }
  
  private java.util.Date deserializeToDate(JsonElement json)
  {
    synchronized (localFormat)
    {
      try
      {
        return localFormat.parse(json.getAsString());
      }
      catch (ParseException ignored)
      {
        try
        {
          return enUsFormat.parse(json.getAsString());
        }
        catch (ParseException ignored)
        {
          try
          {
            return iso8601Format.parse(json.getAsString());
          }
          catch (ParseException e)
          {
            throw new JsonSyntaxException(json.getAsString(), e);
          }
        }
      }
    }
  }
  
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    sb.append(DefaultDateTypeAdapter.class.getSimpleName());
    sb.append('(').append(localFormat.getClass().getSimpleName()).append(')');
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     com.google.gson.DefaultDateTypeAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import com.google.gson.internal..Gson.Preconditions;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

final class TreeTypeAdapter<T>
  extends TypeAdapter<T>
{
  private final JsonSerializer<T> serializer;
  private final JsonDeserializer<T> deserializer;
  private final Gson gson;
  private final TypeToken<T> typeToken;
  private final TypeAdapterFactory skipPast;
  private TypeAdapter<T> delegate;
  
  private TreeTypeAdapter(JsonSerializer<T> serializer, JsonDeserializer<T> deserializer, Gson gson, TypeToken<T> typeToken, TypeAdapterFactory skipPast)
  {
    this.serializer = serializer;
    this.deserializer = deserializer;
    this.gson = gson;
    this.typeToken = typeToken;
    this.skipPast = skipPast;
  }
  
  public T read(JsonReader in)
    throws IOException
  {
    if (deserializer == null) {
      return (T)delegate().read(in);
    }
    JsonElement value = Streams.parse(in);
    if (value.isJsonNull()) {
      return null;
    }
    return (T)deserializer.deserialize(value, typeToken.getType(), gson.deserializationContext);
  }
  
  public void write(JsonWriter out, T value)
    throws IOException
  {
    if (serializer == null)
    {
      delegate().write(out, value);
      return;
    }
    if (value == null)
    {
      out.nullValue();
      return;
    }
    JsonElement tree = serializer.serialize(value, typeToken.getType(), gson.serializationContext);
    Streams.write(tree, out);
  }
  
  private TypeAdapter<T> delegate()
  {
    TypeAdapter<T> d = delegate;
    return d != null ? d : (delegate = gson.getDelegateAdapter(skipPast, typeToken));
  }
  
  public static TypeAdapterFactory newFactory(TypeToken<?> exactType, Object typeAdapter)
  {
    return new SingleTypeFactory(typeAdapter, exactType, false, null, null);
  }
  
  public static TypeAdapterFactory newFactoryWithMatchRawType(TypeToken<?> exactType, Object typeAdapter)
  {
    boolean matchRawType = exactType.getType() == exactType.getRawType();
    return new SingleTypeFactory(typeAdapter, exactType, matchRawType, null, null);
  }
  
  public static TypeAdapterFactory newTypeHierarchyFactory(Class<?> hierarchyType, Object typeAdapter)
  {
    return new SingleTypeFactory(typeAdapter, null, false, hierarchyType, null);
  }
  
  private static class SingleTypeFactory
    implements TypeAdapterFactory
  {
    private final TypeToken<?> exactType;
    private final boolean matchRawType;
    private final Class<?> hierarchyType;
    private final JsonSerializer<?> serializer;
    private final JsonDeserializer<?> deserializer;
    
    private SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType, Class<?> hierarchyType)
    {
      serializer = ((typeAdapter instanceof JsonSerializer) ? (JsonSerializer)typeAdapter : null);
      
      deserializer = ((typeAdapter instanceof JsonDeserializer) ? (JsonDeserializer)typeAdapter : null);
      
      .Gson.Preconditions.checkArgument((serializer != null) || (deserializer != null));
      this.exactType = exactType;
      this.matchRawType = matchRawType;
      this.hierarchyType = hierarchyType;
    }
    
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
    {
      boolean matches = exactType != null ? false : (exactType.equals(type)) || ((matchRawType) && (exactType.getType() == type.getRawType())) ? true : hierarchyType.isAssignableFrom(type.getRawType());
      
      return matches ? new TreeTypeAdapter(serializer, deserializer, gson, type, this, null) : null;
    }
  }
}

/* Location:
 * Qualified Name:     com.google.gson.TreeTypeAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import java.lang.reflect.Field;

 enum FieldNamingPolicy$2
{
  FieldNamingPolicy$2()
  {
    super(paramString, paramInt, null);
  }
  
  public String translateName(Field f)
  {
    return FieldNamingPolicy.access$100(f.getName());
  }
}

/* Location:
 * Qualified Name:     com.google.gson.FieldNamingPolicy.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

 enum LongSerializationPolicy$1
{
  LongSerializationPolicy$1()
  {
    super(paramString, paramInt, null);
  }
  
  public JsonElement serialize(Long value)
  {
    return new JsonPrimitive(value);
  }
}

/* Location:
 * Qualified Name:     com.google.gson.LongSerializationPolicy.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson.reflect;

import com.google.gson.internal..Gson.Preconditions;
import com.google.gson.internal..Gson.Types;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.HashMap;
import java.util.Map;

public class TypeToken<T>
{
  final Class<? super T> rawType;
  final Type type;
  final int hashCode;
  
  protected TypeToken()
  {
    type = getSuperclassTypeParameter(getClass());
    rawType = .Gson.Types.getRawType(type);
    hashCode = type.hashCode();
  }
  
  TypeToken(Type type)
  {
    this.type = .Gson.Types.canonicalize((Type).Gson.Preconditions.checkNotNull(type));
    rawType = .Gson.Types.getRawType(this.type);
    hashCode = this.type.hashCode();
  }
  
  static Type getSuperclassTypeParameter(Class<?> subclass)
  {
    Type superclass = subclass.getGenericSuperclass();
    if ((superclass instanceof Class)) {
      throw new RuntimeException("Missing type parameter.");
    }
    ParameterizedType parameterized = (ParameterizedType)superclass;
    return .Gson.Types.canonicalize(parameterized.getActualTypeArguments()[0]);
  }
  
  public final Class<? super T> getRawType()
  {
    return rawType;
  }
  
  public final Type getType()
  {
    return type;
  }
  
  @Deprecated
  public boolean isAssignableFrom(Class<?> cls)
  {
    return isAssignableFrom(cls);
  }
  
  @Deprecated
  public boolean isAssignableFrom(Type from)
  {
    if (from == null) {
      return false;
    }
    if (type.equals(from)) {
      return true;
    }
    if ((type instanceof Class)) {
      return rawType.isAssignableFrom(.Gson.Types.getRawType(from));
    }
    if ((type instanceof ParameterizedType)) {
      return isAssignableFrom(from, (ParameterizedType)type, new HashMap());
    }
    if ((type instanceof GenericArrayType)) {
      return (rawType.isAssignableFrom(.Gson.Types.getRawType(from))) && (isAssignableFrom(from, (GenericArrayType)type));
    }
    throw buildUnexpectedTypeError(type, new Class[] { Class.class, ParameterizedType.class, GenericArrayType.class });
  }
  
  @Deprecated
  public boolean isAssignableFrom(TypeToken<?> token)
  {
    return isAssignableFrom(token.getType());
  }
  
  private static boolean isAssignableFrom(Type from, GenericArrayType to)
  {
    Type toGenericComponentType = to.getGenericComponentType();
    if ((toGenericComponentType instanceof ParameterizedType))
    {
      Type t = from;
      if ((from instanceof GenericArrayType))
      {
        t = ((GenericArrayType)from).getGenericComponentType();
      }
      else if ((from instanceof Class))
      {
        Class<?> classType = (Class)from;
        while (classType.isArray()) {
          classType = classType.getComponentType();
        }
        t = classType;
      }
      return isAssignableFrom(t, (ParameterizedType)toGenericComponentType, new HashMap());
    }
    return true;
  }
  
  private static boolean isAssignableFrom(Type from, ParameterizedType to, Map<String, Type> typeVarMap)
  {
    if (from == null) {
      return false;
    }
    if (to.equals(from)) {
      return true;
    }
    Class<?> clazz = .Gson.Types.getRawType(from);
    ParameterizedType ptype = null;
    if ((from instanceof ParameterizedType)) {
      ptype = (ParameterizedType)from;
    }
    if (ptype != null)
    {
      Type[] tArgs = ptype.getActualTypeArguments();
      TypeVariable<?>[] tParams = clazz.getTypeParameters();
      for (int i = 0; i < tArgs.length; i++)
      {
        Type arg = tArgs[i];
        TypeVariable<?> var = tParams[i];
        while ((arg instanceof TypeVariable))
        {
          TypeVariable<?> v = (TypeVariable)arg;
          arg = (Type)typeVarMap.get(v.getName());
        }
        typeVarMap.put(var.getName(), arg);
      }
      if (typeEquals(ptype, to, typeVarMap)) {
        return true;
      }
    }
    for (Type itype : clazz.getGenericInterfaces()) {
      if (isAssignableFrom(itype, to, new HashMap(typeVarMap))) {
        return true;
      }
    }
    Type sType = clazz.getGenericSuperclass();
    return isAssignableFrom(sType, to, new HashMap(typeVarMap));
  }
  
  private static boolean typeEquals(ParameterizedType from, ParameterizedType to, Map<String, Type> typeVarMap)
  {
    if (from.getRawType().equals(to.getRawType()))
    {
      Type[] fromArgs = from.getActualTypeArguments();
      Type[] toArgs = to.getActualTypeArguments();
      for (int i = 0; i < fromArgs.length; i++) {
        if (!matches(fromArgs[i], toArgs[i], typeVarMap)) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
  
  private static AssertionError buildUnexpectedTypeError(Type token, Class<?>... expected)
  {
    StringBuilder exceptionMessage = new StringBuilder("Unexpected type. Expected one of: ");
    for (Class<?> clazz : expected) {
      exceptionMessage.append(clazz.getName()).append(", ");
    }
    exceptionMessage.append("but got: ").append(token.getClass().getName()).append(", for type token: ").append(token.toString()).append('.');
    
    return new AssertionError(exceptionMessage.toString());
  }
  
  private static boolean matches(Type from, Type to, Map<String, Type> typeMap)
  {
    return (to.equals(from)) || (((from instanceof TypeVariable)) && (to.equals(typeMap.get(((TypeVariable)from).getName()))));
  }
  
  public final int hashCode()
  {
    return hashCode;
  }
  
  public final boolean equals(Object o)
  {
    return ((o instanceof TypeToken)) && (.Gson.Types.equals(type, type));
  }
  
  public final String toString()
  {
    return .Gson.Types.typeToString(type);
  }
  
  public static TypeToken<?> get(Type type)
  {
    return new TypeToken(type);
  }
  
  public static <T> TypeToken<T> get(Class<T> type)
  {
    return new TypeToken(type);
  }
}

/* Location:
 * Qualified Name:     com.google.gson.reflect.TypeToken
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson;

import com.google.gson.internal.LinkedTreeMap;
import java.util.Map.Entry;
import java.util.Set;

public final class JsonObject
  extends JsonElement
{
  private final LinkedTreeMap<String, JsonElement> members = new LinkedTreeMap();
  
  JsonObject deepCopy()
  {
    JsonObject result = new JsonObject();
    for (Map.Entry<String, JsonElement> entry : members.entrySet()) {
      result.add((String)entry.getKey(), ((JsonElement)entry.getValue()).deepCopy());
    }
    return result;
  }
  
  public void add(String property, JsonElement value)
  {
    if (value == null) {
      value = JsonNull.INSTANCE;
    }
    members.put(property, value);
  }
  
  public JsonElement remove(String property)
  {
    return (JsonElement)members.remove(property);
  }
  
  public void addProperty(String property, String value)
  {
    add(property, createJsonElement(value));
  }
  
  public void addProperty(String property, Number value)
  {
    add(property, createJsonElement(value));
  }
  
  public void addProperty(String property, Boolean value)
  {
    add(property, createJsonElement(value));
  }
  
  public void addProperty(String property, Character value)
  {
    add(property, createJsonElement(value));
  }
  
  private JsonElement createJsonElement(Object value)
  {
    return value == null ? JsonNull.INSTANCE : new JsonPrimitive(value);
  }
  
  public Set<Map.Entry<String, JsonElement>> entrySet()
  {
    return members.entrySet();
  }
  
  public boolean has(String memberName)
  {
    return members.containsKey(memberName);
  }
  
  public JsonElement get(String memberName)
  {
    return (JsonElement)members.get(memberName);
  }
  
  public JsonPrimitive getAsJsonPrimitive(String memberName)
  {
    return (JsonPrimitive)members.get(memberName);
  }
  
  public JsonArray getAsJsonArray(String memberName)
  {
    return (JsonArray)members.get(memberName);
  }
  
  public JsonObject getAsJsonObject(String memberName)
  {
    return (JsonObject)members.get(memberName);
  }
  
  public boolean equals(Object o)
  {
    return (o == this) || (((o instanceof JsonObject)) && (members.equals(members)));
  }
  
  public int hashCode()
  {
    return members.hashCode();
  }
}

/* Location:
 * Qualified Name:     com.google.gson.JsonObject
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson.internal;

public final class $Gson$Preconditions
{
  public static <T> T checkNotNull(T obj)
  {
    if (obj == null) {
      throw new NullPointerException();
    }
    return obj;
  }
  
  public static void checkArgument(boolean condition)
  {
    if (!condition) {
      throw new IllegalArgumentException();
    }
  }
}

/* Location:
 * Qualified Name:     com.google.gson.internal..Gson.Preconditions
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson.internal;

public abstract interface ObjectConstructor<T>
{
  public abstract T construct();
}

/* Location:
 * Qualified Name:     com.google.gson.internal.ObjectConstructor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.google.gson.internal;

import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;

public final class $Gson$Types
{
  static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
  
  public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
  {
    return new ParameterizedTypeImpl(ownerType, rawType, typeArguments);
  }
  
  public static GenericArrayType arrayOf(Type componentType)
  {
    return new GenericArrayTypeImpl(componentType);
  }
  
  public static WildcardType subtypeOf(Type bound)
  {
    return new WildcardTypeImpl(new Type[] { bound }, EMPTY_TYPE_ARRAY);
  }
  
  public static WildcardType supertypeOf(Type bound)
  {
    return new WildcardTypeImpl(new Type[] { Object.class }, new Type[] { bound });
  }
  
  public static Type canonicalize(Type type)
  {
    if ((type instanceof Class))
    {
      Class<?> c = (Class)type;
      return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
    }
    if ((type instanceof ParameterizedType))
    {
      ParameterizedType p = (ParameterizedType)type;
      return new ParameterizedTypeImpl(p.getOwnerType(), p.getRawType(), p.getActualTypeArguments());
    }
    if ((type instanceof GenericArrayType))
    {
      GenericArrayType g = (GenericArrayType)type;
      return new GenericArrayTypeImpl(g.getGenericComponentType());
    }
    if ((type instanceof WildcardType))
    {
      WildcardType w = (WildcardType)type;
      return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
    }
    return type;
  }
  
  public static Class<?> getRawType(Type type)
  {
    if ((type instanceof Class)) {
      return (Class)type;
    }
    if ((type instanceof ParameterizedType))
    {
      ParameterizedType parameterizedType = (ParameterizedType)type;
      
      Type rawType = parameterizedType.getRawType();
      .Gson.Preconditions.checkArgument(rawType instanceof Class);
      return (Class)rawType;
    }
    if ((type instanceof GenericArrayType))
    {
      Type componentType = ((GenericArrayType)type).getGenericComponentType();
      return Array.newInstance(getRawType(componentType), 0).getClass();
    }
    if ((type instanceof TypeVariable)) {
      return Object.class;
    }
    if ((type instanceof WildcardType)) {
      return getRawType(((WildcardType)type).getUpperBounds()[0]);
    }
    String className = type == null ? "null" : type.getClass().getName();
    throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + className);
  }
  
  static boolean equal(Object a, Object b)
  {
    return (a == b) || ((a != null) && (a.equals(b)));
  }
  
  public static boolean equals(Type a, Type b)
  {
    if (a == b) {
      return true;
    }
    if ((a instanceof Class)) {
      return a.equals(b);
    }
    if ((a instanceof ParameterizedType))
    {
      if (!(b instanceof ParameterizedType)) {
        return false;
      }
      ParameterizedType pa = (ParameterizedType)a;
      ParameterizedType pb = (ParameterizedType)b;
      return (equal(pa.getOwnerType(), pb.getOwnerType())) && (pa.getRawType().equals(pb.getRawType())) && (Arrays.equals(pa.getActualTypeArguments(), pb.getActualTypeArguments()));
    }
    if ((a instanceof GenericArrayType))
    {
      if (!(b instanceof GenericArrayType)) {
        return false;
      }
      GenericArrayType ga = (GenericArrayType)a;
      GenericArrayType gb = (GenericArrayType)b;
      return equals(ga.getGenericComponentType(), gb.getGenericComponentType());
    }
    if ((a instanceof WildcardType))
    {
      if (!(b instanceof WildcardType)) {
        return false;
      }
      WildcardType wa = (WildcardType)a;
      WildcardType wb = (WildcardType)b;
      return (Arrays.equals(wa.getUpperBounds(), wb.getUpperBounds())) && (Arrays.equals(wa.getLowerBounds(), wb.getLowerBounds()));
    }
    if ((a instanceof TypeVariable))
    {
      if (!(b instanceof TypeVariable)) {
        return false;
      }
      TypeVariable<?> va = (TypeVariable)a;
      TypeVariable<?> vb = (TypeVariable)b;
      return (va.getGenericDeclaration() == vb.getGenericDeclaration()) && (va.getName().equals(vb.getName()));
    }
    return false;
  }
  
  private static int hashCodeOrZero(Object o)
  {
    return o != null ? o.hashCode() : 0;
  }
  
  public static String typeToString(Type type)
  {
    return (type instanceof Class) ? ((Class)type).getName() : type.toString();
  }
  
  static Type getGenericSupertype(Type context, Class<?> rawType, Class<?> toResolve)
  {
    if (toResolve == rawType) {
      return context;
    }
    if (toResolve.isInterface())
    {
      Class<?>[] interfaces = rawType.getInterfaces();
      int i = 0;
      for (int length = interfaces.length; i < length; i++)
      {
        if (interfaces[i] == toResolve) {
          return rawType.getGenericInterfaces()[i];
        }
        if (toResolve.isAssignableFrom(interfaces[i])) {
          return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve);
        }
      }
    }
    if (!rawType.isInterface()) {
      while (rawType != Object.class)
      {
        Class<?> rawSupertype = rawType.getSuperclass();
        if (rawSupertype == toResolve) {
          return rawType.getGenericSuperclass();
        }
        if (toResolve.isAssignableFrom(rawSupertype)) {
          return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
        }
        rawType = rawSupertype;
      }
    }
    return toResolve;
  }
  
  static Type getSupertype(Type context, Class<?> contextRawType, Class<?> supertype)
  {
    .Gson.Preconditions.checkArgument(supertype.isAssignableFrom(contextRawType));
    return resolve(context, contextRawType, getGenericSupertype(context, contextRawType, supertype));
  }
  
  public static Type getArrayComponentType(Type array)
  {
    return (array instanceof GenericArrayType) ? ((GenericArrayType)array).getGenericComponentType() : ((Class)array).getComponentType();
  }
  
  public static Type getCollectionElementType(Type context, Class<?> contextRawType)
  {
    Type collectionType = getSupertype(context, contextRawType, Collection.class);
    if ((collectionType instanceof WildcardType)) {
      collectionType = ((WildcardType)collectionType).getUpperBounds()[0];
    }
    if ((collectionType instanceof ParameterizedType)) {
      return ((ParameterizedType)collectionType).getActualTypeArguments()[0];
    }
    return Object.class;
  }
  
  public static Type[] getMapKeyAndValueTypes(Type context, Class<?> contextRawType)
  {
    if (context == Properties.class) {
      return new Type[] { String.class, String.class };
    }
    Type mapType = getSupertype(context, contextRawType, Map.class);
    if ((mapType instanceof ParameterizedType))
    {
      ParameterizedType mapParameterizedType = (ParameterizedType)mapType;
      return mapParameterizedType.getActualTypeArguments();
    }
    return new Type[] { Object.class, Object.class };
  }
  
  public static Type resolve(Type context, Class<?> contextRawType, Type toResolve)
  {
    while ((toResolve instanceof TypeVariable))
    {
      TypeVariable<?> typeVariable = (TypeVariable)toResolve;
      toResolve = resolveTypeVariable(context, contextRawType, typeVariable);
      if (toResolve == typeVariable) {
        return toResolve;
      }
    }
    if (((toResolve instanceof Class)) && (((Class)toResolve).isArray()))
    {
      Class<?> original = (Class)toResolve;
      Type componentType = original.getComponentType();
      Type newComponentType = resolve(context, contextRawType, componentType);
      return componentType == newComponentType ? original : arrayOf(newComponentType);
    }
    if ((toResolve instanceof GenericArrayType))
    {
      GenericArrayType original = (GenericArrayType)toResolve;
      Type componentType = original.getGenericComponentType();
      Type newComponentType = resolve(context, contextRawType, componentType);
      return componentType == newComponentType ? original : arrayOf(newComponentType);
    }
    if ((toResolve instanceof ParameterizedType))
    {
      ParameterizedType original = (ParameterizedType)toResolve;
      Type ownerType = original.getOwnerType();
      Type newOwnerType = resolve(context, contextRawType, ownerType);
      boolean changed = newOwnerType != ownerType;
      
      Type[] args = original.getActualTypeArguments();
      int t = 0;
      for (int length = args.length; t < length; t++)
      {
        Type resolvedTypeArgument = resolve(context, contextRawType, args[t]);
        if (resolvedTypeArgument != args[t])
        {
          if (!changed)
          {
            args = (Type[])args.clone();
            changed = true;
          }
          args[t] = resolvedTypeArgument;
        }
      }
      return changed ? newParameterizedTypeWithOwner(newOwnerType, original.getRawType(), args) : original;
    }
    if ((toResolve instanceof WildcardType))
    {
      WildcardType original = (WildcardType)toResolve;
      Type[] originalLowerBound = original.getLowerBounds();
      Type[] originalUpperBound = original.getUpperBounds();
      if (originalLowerBound.length == 1)
      {
        Type lowerBound = resolve(context, contextRawType, originalLowerBound[0]);
        if (lowerBound != originalLowerBound[0]) {
          return supertypeOf(lowerBound);
        }
      }
      else if (originalUpperBound.length == 1)
      {
        Type upperBound = resolve(context, contextRawType, originalUpperBound[0]);
        if (upperBound != originalUpperBound[0]) {
          return subtypeOf(upperBound);
        }
      }
      return original;
    }
    return toResolve;
  }
  
  static Type resolveTypeVariable(Type context, Class<?> contextRawType, TypeVariable<?> unknown)
  {
    Class<?> declaredByRaw = declaringClassOf(unknown);
    if (declaredByRaw == null) {
      return unknown;
    }
    Type declaredBy = getGenericSupertype(context, contextRawType, declaredByRaw);
    if ((declaredBy instanceof ParameterizedType))
    {
      int index = indexOf(declaredByRaw.getTypeParameters(), unknown);
      return ((ParameterizedType)declaredBy).getActualTypeArguments()[index];
    }
    return unknown;
  }
  
  private static int indexOf(Object[] array, Object toFind)
  {
    for (int i = 0; i < array.length; i++) {
      if (toFind.equals(array[i])) {
        return i;
      }
    }
    throw new NoSuchElementException();
  }
  
  private static Class<?> declaringClassOf(TypeVariable<?> typeVariable)
  {
    GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
    return (genericDeclaration instanceof Class) ? (Class)genericDeclaration : null;
  }
  
  private static void checkNotPrimitive(Type type)
  {
    .Gson.Preconditions.checkArgument((!(type instanceof Class)) || (!((Class)type).isPrimitive()));
  }
  
  private static final class ParameterizedTypeImpl
    implements ParameterizedType, Serializable
  {
    private final Type ownerType;
    private final Type rawType;
    private final Type[] typeArguments;
    private static final long serialVersionUID = 0L;
    
    public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments)
    {
      if ((rawType instanceof Class))
      {
        Class<?> rawTypeAsClass = (Class)rawType;
        .Gson.Preconditions.checkArgument((ownerType != null) || (rawTypeAsClass.getEnclosingClass() == null));
        .Gson.Preconditions.checkArgument((ownerType == null) || (rawTypeAsClass.getEnclosingClass() != null));
      }
      this.ownerType = (ownerType == null ? null : .Gson.Types.canonicalize(ownerType));
      this.rawType = .Gson.Types.canonicalize(rawType);
      this.typeArguments = ((Type[])typeArguments.clone());
      for (int t = 0; t < this.typeArguments.length; t++)
      {
        .Gson.Preconditions.checkNotNull(this.typeArguments[t]);
        .Gson.Types.checkNotPrimitive(this.typeArguments[t]);
        this.typeArguments[t] = .Gson.Types.canonicalize(this.typeArguments[t]);
      }
    }
    
    public Type[] getActualTypeArguments()
    {
      return (Type[])typeArguments.clone();
    }
    
    public Type getRawType()
    {
      return rawType;
    }
    
    public Type getOwnerType()
    {
      return ownerType;
    }
    
    public boolean equals(Object other)
    {
      return ((other instanceof ParameterizedType)) && (.Gson.Types.equals(this, (ParameterizedType)other));
    }
    
    public int hashCode()
    {
      return Arrays.hashCode(typeArguments) ^ rawType.hashCode() ^ .Gson.Types.hashC
1 2 3 4 5 6 7 8

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd