Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 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.gwt.user.server.rpc.impl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.CustomFieldSerializer;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
import com.google.gwt.user.client.rpc.GwtTransient;
import com.google.gwt.user.server.rpc.SerializationPolicy;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import java.util.zip.CRC32;
/**
* Serialization utility class used by the server-side RPC code.
*/
public class SerializabilityUtil {
public static final String DEFAULT_ENCODING = "UTF-8";
/**
* Comparator used to sort fields.
*/
public static final Comparator FIELD_COMPARATOR = new Comparator() {
public int compare(Field f1, Field f2) {
return f1.getName().compareTo(f2.getName());
}
};
/**
* A permanent cache of all computed CRCs on classes. This is safe to do
* because a Class is guaranteed not to change within the lifetime of a
* ClassLoader (and thus, this Map). Access must be synchronized.
*
* NOTE: after synchronizing on this field, it's possible to additionally
* synchronize on {@link #classCustomSerializerCache} or
* {@link #classSerializableFieldsCache}, so be aware deadlock potential when
* changing this code.
*/
private static final Map, String> classCRC32Cache = new IdentityHashMap, String>();
/**
* A permanent cache of all serializable fields on classes. This is safe to do
* because a Class is guaranteed not to change within the lifetime of a
* ClassLoader (and thus, this Map). Access must be synchronized.
*
* NOTE: to prevent deadlock, you may NOT synchronize {@link #classCRC32Cache}
* after synchronizing on this field.
*/
private static final Map, Field[]> classSerializableFieldsCache = new IdentityHashMap, Field[]>();
/**
* A permanent cache of all which classes onto custom field serializers. This
* is safe to do because a Class is guaranteed not to change within the
* lifetime of a ClassLoader (and thus, this Map). Access must be
* synchronized.
*
* NOTE: to prevent deadlock, you may NOT synchronize {@link #classCRC32Cache}
* after synchronizing on this field.
*/
private static final Map, Class>> classCustomSerializerCache = new IdentityHashMap, Class>>();
/**
* Map of {@link Class} objects to singleton instances of that
* {@link CustomFieldSerializer}.
*/
private static final Map, CustomFieldSerializer>>
CLASS_TO_SERIALIZER_INSTANCE =
new IdentityHashMap, CustomFieldSerializer>>();
private static final String JRE_SERIALIZER_PACKAGE = "com.google.gwt.user.client.rpc.core";
/**
* A re-usable, non-functional {@link CustomFieldSerializer} for when the
* Custom Field Serializer does not implement the
* {@link CustomFieldSerializer} interface.
*/
private static final CustomFieldSerializer NO_SUCH_SERIALIZER =
new CustomFieldSerializer