Stephen Haberman has submitted this change and it was merged.
Change subject: Remove unused, package-private FastStringMap.
......................................................................
Remove unused, package-private FastStringMap.
Change-Id: I8dd9f897a044ba53be5fc74fabb40a382b9ef119
---
D user/src/com/google/gwt/user/client/ui/FastStringMap.java
M user/test/com/google/gwt/user/UiPart1Suite.java
D user/test/com/google/gwt/user/client/ui/FastStringMapTest.java
D user/test/com/google/gwt/user/maptests/FastStringMapTest.java
4 files changed, 0 insertions(+), 426 deletions(-)
Approvals:
Daniel Kurka: Looks good to me, but someone else must approve
Manuel Carrasco Moñino: Looks good to me, but someone else must approve
Leeroy Jenkins: Verified
Brian Slesinsky: Looks good to me, approved
diff --git a/user/src/com/google/gwt/user/client/ui/FastStringMap.java
b/user/src/com/google/gwt/user/client/ui/FastStringMap.java
deleted file mode 100644
index 8538ccc..0000000
--- a/user/src/com/google/gwt/user/client/ui/FastStringMap.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright 2007 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.ui;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Special-case Map implementation which imposes limits on the types of
keys
- * that can be used in return for much faster speed. In specific, only
strings
- * that could be added to a JavaScript object as keys are valid.
- */
-
-class FastStringMap<T> extends AbstractMap<String, T> {
- private static class ImplMapEntry<T> implements Map.Entry<String, T> {
-
- private String key;
-
- private T value;
-
- ImplMapEntry(String key, T value) {
- this.key = key;
- this.value = value;
- }
-
- @Override
- public boolean equals(Object a) {
- if (a instanceof Map.Entry<?, ?>) {
- Map.Entry<?, ?> s = (Map.Entry<?, ?>) a;
- if (equalsWithNullCheck(key, s.getKey())
- && equalsWithNullCheck(value, s.getValue())) {
- return true;
- }
- }
- return false;
- }
-
- // strip prefix from key
- public String getKey() {
- return key;
- }
-
- public T getValue() {
- return value;
- }
-
- @Override
- public int hashCode() {
- int keyHash = 0;
- int valueHash = 0;
- if (key != null) {
- keyHash = key.hashCode();
- }
- if (value != null) {
- valueHash = value.hashCode();
- }
- return keyHash ^ valueHash;
- }
-
- public T setValue(T object) {
- T old = value;
- value = object;
- return old;
- }
-
- private boolean equalsWithNullCheck(Object a, Object b) {
- if (a == b) {
- return true;
- } else if (a == null) {
- return false;
- } else {
- return a.equals(b);
- }
- }
- }
-
- /*
- * Accesses need to be prefixed with ':' to prevent conflict with
built-in
- * JavaScript properties.
- */
- private JavaScriptObject map;
-
- public FastStringMap() {
- init();
- }
-
- @Override
- public void clear() {
- init();
- }
-
- @Override
- public boolean containsKey(Object key) {
- return containsKey(keyMustBeString(key), map);
- }
-
- @Override
- public boolean containsValue(Object arg0) {
- return values().contains(arg0);
- }
-
- @Override
- public Set<Map.Entry<String, T>> entrySet() {
- return new AbstractSet<Map.Entry<String, T>>() {
-
- @Override
- public boolean contains(Object key) {
- Map.Entry<?, ?> s = (Map.Entry<?, ?>) key;
- Object value = get(s.getKey());
- if (value == null) {
- return value == s.getValue();
- } else {
- return value.equals(s.getValue());
- }
- }
-
- @Override
- public Iterator<Map.Entry<String, T>> iterator() {
-
- Iterator<Map.Entry<String, T>> custom = new
Iterator<Map.Entry<String, T>>() {
- Iterator<String> keys = keySet().iterator();
-
- public boolean hasNext() {
- return keys.hasNext();
- }
-
- public Map.Entry<String, T> next() {
- String key = keys.next();
- return new ImplMapEntry<T>(key, get(key));
- }
-
- public void remove() {
- keys.remove();
- }
- };
- return custom;
- }
-
- @Override
- public int size() {
- return FastStringMap.this.size();
- }
-
- };
- }
-
- @Override
- public T get(Object key) {
- return get(keyMustBeString(key));
- }
-
- // Prepend ':' to avoid conflicts with built-in Object properties.
- public native T get(String key) /*-{
- return [email protected]::map[':' +
key];
- }-*/;
-
- @Override
- public boolean isEmpty() {
- return size() == 0;
- }
-
- @Override
- public Set<String> keySet() {
- return new AbstractSet<String>() {
- @Override
- public boolean contains(Object key) {
- return containsKey(key);
- }
-
- @Override
- public Iterator<String> iterator() {
- List<String> l = new ArrayList<String>();
- addAllKeysFromJavascriptObject(l, map);
- return l.iterator();
- }
-
- @Override
- public int size() {
- return FastStringMap.this.size();
- }
- };
- }
-
- // Prepend ':' to avoid conflicts with built-in Object properties.
- @Override
- public native T put(String key, T value) /*-{
- key = ':' + key;
- var map = [email protected]::map;
- var previous = map[key];
- map[key] = value;
- return previous;
- }-*/;
-
- @Override
- public void putAll(Map<? extends String, ? extends T> arg0) {
- for (Map.Entry<? extends String, ? extends T> entry : arg0.entrySet())
{
- put(entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public T remove(Object key) {
- return remove(keyMustBeString(key));
- }
-
- // only count keys with ':' prefix
- @Override
- public native int size() /*-{
- var value = [email protected]::map;
- var count = 0;
- for(var key in value) {
- if (key.charAt(0) == ':') ++count;
- }
- return count;
- }-*/;
-
- @Override
- public Collection<T> values() {
- List<T> values = new ArrayList<T>();
- addAllValuesFromJavascriptObject(values, map);
- return values;
- }
-
- // only count keys with ':' prefix
- private native void addAllKeysFromJavascriptObject(Collection<String> s,
- JavaScriptObject javaScriptObject) /*-{
- for(var key in javaScriptObject) {
- if (key.charAt(0) != ':') continue;
- [email protected]::add(Ljava/lang/Object;)(key.substring(1));
- }
- }-*/;
-
- // only count keys with ':' prefix
- private native void addAllValuesFromJavascriptObject(Collection<T> s,
- JavaScriptObject javaScriptObject) /*-{
- for(var key in javaScriptObject) {
- if (key.charAt(0) != ':') continue;
- var value = javaScriptObject[key];
- [email protected]::add(Ljava/lang/Object;)(value);
- }
- }-*/;
-
- // Prepend ':' to avoid conflicts with built-in Object properties.
- private native boolean containsKey(String key, JavaScriptObject obj)/*-{
- return (':' + key) in obj;
- }-*/;
-
- private native void init() /*-{
- [email protected]::map = {};
- }-*/;
-
- private String keyMustBeString(Object key) {
- if (key instanceof String) {
- return (String) key;
- } else {
- throw new IllegalArgumentException(this.getClass().getName()
- + " can only have Strings as keys, not" + key);
- }
- }
-
- // Prepend ':' to avoid conflicts with built-in Object properties.
- private native T remove(String key) /*-{
- key = ':' + key;
- var map = [email protected]::map;
- var previous = map[key];
- delete map[key];
- return previous;
- }-*/;
-}
diff --git a/user/test/com/google/gwt/user/UiPart1Suite.java
b/user/test/com/google/gwt/user/UiPart1Suite.java
index 74e7d67..dba4009 100644
--- a/user/test/com/google/gwt/user/UiPart1Suite.java
+++ b/user/test/com/google/gwt/user/UiPart1Suite.java
@@ -45,7 +45,6 @@
import com.google.gwt.user.client.ui.DockLayoutPanelTest;
import com.google.gwt.user.client.ui.DockPanelTest;
import com.google.gwt.user.client.ui.ElementWrappingTest;
-import com.google.gwt.user.client.ui.FastStringMapTest;
import com.google.gwt.user.client.ui.FileUploadTest;
import com.google.gwt.user.client.ui.FiniteWidgetIteratorTest;
import com.google.gwt.user.client.ui.FlexTableTest;
@@ -96,7 +95,6 @@
suite.addTestSuite(DOMTest.class);
suite.addTestSuite(DOMRtlTest.class);
suite.addTestSuite(ElementWrappingTest.class);
- suite.addTestSuite(FastStringMapTest.class);
suite.addTestSuite(FileUploadTest.class);
suite.addTestSuite(FiniteWidgetIteratorTest.class);
suite.addTestSuite(FlexTableTest.class);
diff --git a/user/test/com/google/gwt/user/client/ui/FastStringMapTest.java
b/user/test/com/google/gwt/user/client/ui/FastStringMapTest.java
deleted file mode 100644
index 420203f..0000000
--- a/user/test/com/google/gwt/user/client/ui/FastStringMapTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2007 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.ui;
-
-import com.google.gwt.junit.client.GWTTestCase;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Tests <code>FastStringMap</code>Right now, no tests are directly run
here,
- * because the tests are run in mapTest.FastStringMapTest. This is because
- * otherwise the inclusion of the map testing code causes the system to
generate
- * many compiler errors during unit testing, thereby making real errors
harder
- * to spot.
- */
-public class FastStringMapTest extends GWTTestCase {
-
- /**
- * These is an example of two correctly formatted java API specification.
- */
- public static Map<String, String> makeEmptyMap() {
- return new FastStringMap<String>();
- }
-
- public String getModuleName() {
- return "com.google.gwt.user.User";
- }
-
- public void test() {
- // Only FastStringMap specific tests should go here. Look in
- // com.google.gwt.user.maptests.FastStringMapTest for all apache Map
tests.
- }
-
- /*
- * Test for collisions between stored strings and JavaScript Object
- * properties.
- */
- public void testJSOCollision() {
- Map<String, String> map = makeEmptyMap();
- assertEquals(0, map.size());
- map.put("k1", "v1");
- assertEquals(1, map.size());
- assertEquals("v1", map.get("k1"));
- map.put("toString", "toStringVal");
- assertEquals(2, map.size());
- assertEquals("toStringVal", map.get("toString"));
- map.put("watch", "watchVal");
- Set<String> keys = map.keySet();
- assertEquals(3, keys.size());
- map.put("__proto__", "__proto__Val");
- assertEquals(4 ,map.size());
- assertEquals("__proto__Val", map.get("__proto__"));
- map.put("k1", "v1b");
- keys = map.keySet();
- assertEquals(4, keys.size());
- Collection<String> values = map.values();
- assertEquals(4, values.size());
- map.put("k2", "v1b");
- values = map.values();
- assertEquals(5, values.size());
- map.put("","empty");
- assertEquals("empty", map.get(""));
- map.remove("k2");
- assertEquals(5, values.size());
- }
-
-}
diff --git a/user/test/com/google/gwt/user/maptests/FastStringMapTest.java
b/user/test/com/google/gwt/user/maptests/FastStringMapTest.java
deleted file mode 100644
index f176661..0000000
--- a/user/test/com/google/gwt/user/maptests/FastStringMapTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007 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.maptests;
-
-import org.apache.commons.collections.TestMap;
-
-import java.util.Map;
-
-/**
- * Test class for <code>FastStringMap</code>.
- */
-public class FastStringMapTest extends TestMap {
-
- public String getModuleName() {
- return "com.google.gwt.user.FastStringMapTest";
- }
-
- protected Map makeEmptyMap() {
- return com.google.gwt.user.client.ui.FastStringMapTest.makeEmptyMap();
- }
-
- /**
- * Override if your map does not allow a <code>null</code> key. The
default
- * implementation returns <code>true</code>
- */
- protected boolean useNullKey() {
- return false;
- }
-
- /**
- * Override if your map does not allow <code>null</code> values. The
default
- * implementation returns <code>true</code>.
- */
- protected boolean useNullValue() {
- return true;
- }
-
-}
--
To view, visit https://gwt-review.googlesource.com/3280
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8dd9f897a044ba53be5fc74fabb40a382b9ef119
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Stephen Haberman <[email protected]>
Gerrit-Reviewer: Brian Slesinsky <[email protected]>
Gerrit-Reviewer: Daniel Kurka <[email protected]>
Gerrit-Reviewer: Goktug Gokdogan <[email protected]>
Gerrit-Reviewer: Leeroy Jenkins <[email protected]>
Gerrit-Reviewer: Manuel Carrasco Moñino <[email protected]>
Gerrit-Reviewer: Stephen Haberman <[email protected]>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.