com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client Show documentation
Show all versions of vaadin-client Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/*
* 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.client.rpc.impl;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
/**
* Base class for the client and server serialization streams. This class
* handles the basic serialization and deserialization formatting for primitive
* types since these are common between the client and the server. It also
* handles Object- and String-tracking for building graph references.
*/
public abstract class AbstractSerializationStreamWriter extends
AbstractSerializationStream implements SerializationStreamWriter {
private static final double TWO_PWR_16_DBL = 0x10000;
private static final double TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
/**
* Return a pair of doubles { low, high } that add up to the given number,
* such that "low" is always between 0 and 2^32-1 inclusive and "high" is
* always between -2^63 and 2^63-2^32 inclusive and is a multiple of 2^32.
*/
public static double[] getAsDoubleArray(long value) {
int lowBits = (int) (value & 0xffffffff);
int highBits = (int) (value >> 32);
return makeLongComponents(lowBits, highBits);
}
// Equivalent to getAsDoubleArray((long) highBits << 32 | lowBits);
protected static double[] makeLongComponents(int lowBits, int highBits) {
double high = highBits * TWO_PWR_32_DBL;
double low = lowBits;
if (lowBits < 0) {
low += TWO_PWR_32_DBL;
}
return new double[] {low, high};
}
private int objectCount;
private Map