Author: [EMAIL PROTECTED]
Date: Thu Nov 13 20:25:01 2008
New Revision: 4074

Modified:
     
branches/1_6_clean_events/user/src/com/google/gwt/event/shared/HandlerManager.java

Log:
busting down the public methods in Js and Java handle registries to be  
private.

Modified:  
branches/1_6_clean_events/user/src/com/google/gwt/event/shared/HandlerManager.java
==============================================================================
---  
branches/1_6_clean_events/user/src/com/google/gwt/event/shared/HandlerManager.java
       
(original)
+++  
branches/1_6_clean_events/user/src/com/google/gwt/event/shared/HandlerManager.java
       
Thu Nov 13 20:25:01 2008
@@ -35,7 +35,7 @@
    private static class JavaHandlerRegistry extends
        HashMap<GwtEvent.Type<?>, ArrayList<?>> {

-    public <H extends EventHandler> void addHandler(Type<H> type, H  
handler) {
+    private <H extends EventHandler> void addHandler(Type<H> type, H  
handler) {
        ArrayList<H> l = get(type);
        if (l == null) {
          l = new ArrayList<H>();
@@ -44,7 +44,7 @@
        l.add(handler);
      }

-    public <H extends EventHandler> void fireEvent(GwtEvent<H> event) {
+    private <H extends EventHandler> void fireEvent(GwtEvent<H> event) {
        Type<H> type = event.getAssociatedType();
        int count = getHandlerCount(type);
        for (int i = 0; i < count; i++) {
@@ -53,13 +53,19 @@
        }
      }

-    public <H extends EventHandler> H getHandler(GwtEvent.Type<H> eventKey,
+    @SuppressWarnings("unchecked")
+    private <H> ArrayList<H> get(GwtEvent.Type<H> type) {
+      // This cast is safe because we control the puts.
+      return (ArrayList<H>) super.get(type);
+    }
+
+    private <H extends EventHandler> H getHandler(GwtEvent.Type<H>  
eventKey,
          int index) {
        ArrayList<H> l = get(eventKey);
        return l.get(index);
      }

-    public int getHandlerCount(GwtEvent.Type<?> eventKey) {
+    private int getHandlerCount(GwtEvent.Type<?> eventKey) {
        ArrayList<?> l = super.get(eventKey);
        if (l == null) {
          return 0;
@@ -68,19 +74,13 @@
        }
      }

-    public <H> void removeHandler(GwtEvent.Type<H> eventKey, H handler) {
+    private <H> void removeHandler(GwtEvent.Type<H> eventKey, H handler) {
        ArrayList<H> l = get(eventKey);
        if (l != null) {
          boolean result = l.remove(handler);
          assert result : "Tried to remove unknown handler";
        }
      }
-
-    @SuppressWarnings("unchecked")
-    private <H> ArrayList<H> get(GwtEvent.Type<H> type) {
-      // This cast is safe because we control the puts.
-      return (ArrayList<H>) super.get(type);
-    }
    }

    /**
@@ -101,7 +101,7 @@
      protected JsHandlerRegistry() {
      }

-    public final <H extends EventHandler> void addHandler(
+    private <H extends EventHandler> void addHandler(
          Type<H> type, H myHandler) {

        // The base is the equivalent to a c pointer into the flattened  
handler
@@ -125,7 +125,7 @@
        setCount(base, count + 1);
      }

-    public final <H extends EventHandler> void fireEvent(GwtEvent<H>  
event) {
+    private <H extends EventHandler> void fireEvent(GwtEvent<H> event) {
        Type<H> type = event.getAssociatedType();
        int base = type.hashCode();
        int count = getCount(base);
@@ -150,35 +150,6 @@
        }
      }

-    public final <H extends EventHandler> H getHandler(GwtEvent.Type<H>  
type,
-        int index) {
-      int base = type.hashCode();
-      int count = getCount(base);
-      if (index >= count) {
-        throw new IndexOutOfBoundsException("index: " + index);
-      }
-      return getHandler(base, index, isFlattened(base));
-    }
-
-    public final int getHandlerCount(GwtEvent.Type<?> eventKey) {
-      return getCount(eventKey.hashCode());
-    }
-
-    public final <H> void removeHandler(GwtEvent.Type<H> eventKey,
-        EventHandler handler) {
-      int base = eventKey.hashCode();
-
-      // Removing a handler is unusual, so smaller code is preferable to
-      // handling both flat and dangling list of pointers.
-      if (isFlattened(base)) {
-        unflatten(base);
-      }
-      boolean result = removeHelper(base, handler);
-      // Hiding this behind an assertion as we'd rather not force the  
compiler
-      // to have to include all handler.toString() instances.
-      assert result : handler + " did not exist";
-    }
-
      private native int getCount(int index) /*-{
        var count = this[index];
        return count == null? 0:count;
@@ -188,6 +159,16 @@
        return this[base + 2 + index];
      }-*/;

+    private <H extends EventHandler> H getHandler(GwtEvent.Type<H> type,
+        int index) {
+      int base = type.hashCode();
+      int count = getCount(base);
+      if (index >= count) {
+        throw new IndexOutOfBoundsException("index: " + index);
+      }
+      return getHandler(base, index, isFlattened(base));
+    }
+
      private native <H extends EventHandler> H getHandler(int base, int  
index,
          boolean flattened) /*-{
        return flattened? this[base + 2 + index]: this[base + 1][index];
@@ -198,6 +179,10 @@
        return handlers[index];
      }-*/;

+    private int getHandlerCount(GwtEvent.Type<?> eventKey) {
+      return getCount(eventKey.hashCode());
+    }
+
      private native JavaScriptObject getHandlers(int base) /*-{
        return  this[base + 1];
      }-*/;
@@ -205,6 +190,21 @@
      private native boolean isFlattened(int base) /*-{
        return this[base + 1] == null;
      }-*/;
+
+    private <H> void removeHandler(GwtEvent.Type<H> eventKey,
+        EventHandler handler) {
+      int base = eventKey.hashCode();
+
+      // Removing a handler is unusual, so smaller code is preferable to
+      // handling both flat and dangling list of pointers.
+      if (isFlattened(base)) {
+        unflatten(base);
+      }
+      boolean result = removeHelper(base, handler);
+      // Hiding this behind an assertion as we'd rather not force the  
compiler
+      // to have to include all handler.toString() instances.
+      assert result : handler + " did not exist";
+    }

      private native boolean removeHelper(int base, EventHandler handler)  
/*-{
        // Find the handler.

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to