All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.appengine.api.datastore.Key_CustomFieldSerializer Maven / Gradle / Ivy

Go to download

*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore

The newest version!
package com.google.appengine.api.datastore;

import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;

/**
 * Custom field serializer for the datastore Key class.
 * Does not transmit appid, just parent/kind/id/name.
 */
public class Key_CustomFieldSerializer
{
	public static void deserialize(SerializationStreamReader streamReader, Key instance)
			throws SerializationException
	{
		// already handled in instantiate
	}

	public static Key instantiate(SerializationStreamReader streamReader)
			throws SerializationException
	{
		Key parent = (Key) streamReader.readObject();
		String kind = streamReader.readString();
		long id = streamReader.readLong();
		String name = streamReader.readString();

		if (name == null)
			return KeyFactory.createKey(parent, kind, id);
		else
			return KeyFactory.createKey(parent, kind, name);
	}

	public static void serialize(SerializationStreamWriter streamWriter, Key instance)
			throws SerializationException
	{
		streamWriter.writeObject(instance.getParent());
		streamWriter.writeString(instance.getKind());
		streamWriter.writeLong(instance.getId());
		streamWriter.writeString(instance.getName());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy