This is the gwt-gdata project http://code.google.com/p/gwt-gdata/. The
code auto-generated from the JS Docs is available:
http://code.google.com/p/gwt-gdata/source/browse/

I uploaded that code mostly for the sake of pointing to it and getting
feedback, there are corrections to be made - though it does compile
and of the unit tests (1 per class) most succeed (187/239) though
these unit tests aren't that involved. It should be a good starting
point.

I still need to plug the ExceptionHelper and ArrayHelper from the
AjaxLoader (have a few questions on this one) into the code and
extract the parameter and return value comments from the JS Docs.

Currently i'm not handling Arrays properly and this came out in the
unit tests. For example in the RecurrenceExceptionEntry (http://
code.google.com/p/gwt-gdata/source/browse/trunk/gdata/src/com/google/
gwt/gdata/client/RecurrenceExceptionEntry.java), the getWhen,
getWhere, getWho, setWhen, setWhere, setWho have return and receive
Java arrays - needs to use JsArray<T> instead (through the
ArrayHelper).

I should probably create a new thread for discussing the GWT-GData
project in specific.

Bobby

On May 25, 11:32 pm, Bobby <bobbysoa...@gmail.com> wrote:
> Eric, what is the svn:externals read-only path for the AjaxLoader
> source? I tried the following with no success (probably because the
> link is not read-only and i don't have checkout access):
>
> ajaxloaderhttp://gwt-google-apis.googlecode.com/svn/trunk/ajaxloader/src/
>
> Bobby
>
> On May 20, 5:21 pm, Bobby <bobbysoa...@gmail.com> wrote:
>
>
>
> > Thanks for the tips Eric.
>
> > - I noticed that newInstance was used in Google Maps so i'm adopted
> > the same convention.
>
> > - I see what you mean about exception handling. I'll make use of your
> > ExceptionHelper for Runnables. For the AsyncCallbacks, i'll try to
> > mirror your ExceptionHelper implementation.
>
> > - When generating the overloads i plug "undefined" in place of omitted
> > optional parameters. Methods with only one parameter were causing the
> > single "undefined" parameter you pointed out, this will be gone after
> > polishing.
>
> > I have another batch of questions/comments coming up - there's one
> > class in GData, the base class for all service classes, which requires
> > some thought since it has methods that may receive constructors (for
> > example GetFeed, which receives the constructor of the feed to be
> > returned). How this class is implemented has some implications on the
> > classes that extend it. I'll have the auto-generated GWT library up
> > sometime next week, this way i'll be able to link to the GWT and JS
> > classes and hopefully get some more feedback on the implementation -
> > not so much on the JSNI code but on the architecture/structure of the
> > library.
>
> > I'm also attempting to auto-generating base Unit tests for each class
> > - most classes are data classes, so Unit tests are straightforward
> > enough (e.g. call each setter, call the corresponding getter, check
> > that the gotten value is the set value). The service classes
> > themselves, which retrieve and update data in the various systems are
> > more difficult, i don't have a plan for those, there will probably be
> > some manual labor but it's not the end of the world if it comes to
> > that.
>
> > Bobby
>
> > On May 18, 3:30 pm, Eric Ayers <zun...@google.com> wrote:
>
> > > Hi Bobby,
>
> > > Thanks for the update, here is some feedback inline.  Sorry for the
> > > delay, I was out last week.
>
> > > On Mon, May 11, 2009 at 3:17 AM, Bobby <bobbysoa...@gmail.com> wrote:
>
> > > > I'm very close, i've just compiled a GData JS example via the GData
> > > > GWT library - which retrieves a Calendar feed - and it worked.
>
> > > > Here are some of the implementation choices i've made so far:
> > > > - map all namespaces to be under com.google.gwt.gdata.client.*
> > > > - map all Object parameters to JavaScriptObject (some GData functions
> > > > receive generic JS objects for initialization purposes).
> > > > - implement JS classes as Overlay Types
> > > > - implement class constants as JSNI methods, for example:
> > > >  public static native String REL_MESSAGE_TO() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_TO; }-*/;
> > > > - implement constructors as JSNI methods (since i'm using Overlay
> > > > Types), for example:
> > > >  public static native Who construct() /*-{ return new
> > > > $wnd.google.gdata.Who(undefined); }-*/;
>
> > > In the gwt-google-apis, I have been naming these factory methods
> > > newInstance() or getInstance() for constructing singletons.  This
> > > comes from convention in the JRE and Joshua Bloch's "Effective Java".
>
> > > > - generate overloads for methods that have optional parameters or
> > > > multi-type parameters in JS, for example:
> > > >  public final native void setValueString(String valueString) /*-
> > > > { this.setValueString(valueString); }-*/;
> > > >  public final native void setValueString() /*-{ this.setValueString
> > > > (undefined); }-*/;
> > > > - implement continuation callbacks (non success/failure) as Runnable,
> > > > for example:
> > > >  public static final native boolean getInfo(Runnable callback) /*-
> > > > { return $wnd.google.accounts.user.getInfo(function()
> > > > { callba...@java.lang.runnable::run()(); }); }-*/;
>
> > > This is good, but in order to display exceptions in Hosted mode, a
> > > more complex pattern is needed.  Essentially, you need to call a
> > > special handler for exceptions in hosted mode.  A particularly nice
> > > implementation of this is the Handler class in gwt-visualization which
> > > uses the ExceptionHelper class in the ajaxloader package.
>
> > >http://code.google.com/p/gwt-google-apis/source/browse/releases/visua......
>
> > > I usually pull the ajaxloader class into the other gwt-google-api
> > > projects using an svn:externals property if you haven't done that
> > > already.
>
> > > > - implement success/failure callbacks as AsyncCallback<T>, for
> > > > example:
> > > >  public final native CalendarAclFeed getAclFeed(String uri,
> > > > AsyncCallback<CalendarAclFeed> callback) /*-{
> > > >       return this.getAclFeed(uri, function(result)
> > > > { @com.google.gwt.gdata.client.impl.Utils::handleSuccessCallback(Lcom/
> > > > google/gwt/user/client/rpc/AsyncCallback;Ljava/lang/Object;)(callback,
> > > > result); }, function(error)
> > > > { @com.google.gwt.gdata.client.impl.Utils::handleFailureCallback(Lcom/
> > > > google/gwt/user/client/rpc/AsyncCallback;Ljava/lang/String;)(callback,
> > > > error); });
> > > > }-*/;
>
> > > Same comment here - if you don't add the UncaughtExceptionHandler
> > > stuff, hosted mode will miss exceptions that occur in the callback.
>
> > > > - ignore all instance fields, since GData implements getters and
> > > > setters.
> > > > - use the existing AjaxLoader to loading the JS libraries.
>
> > > > Pending testing. Adding overloads has been interesting, for a given
> > > > method with n optional parameters there are 2^n overloads to be added
> > > > - plus some JS methods have multi-type parameters so those need to be
> > > > defined as well.
>
> > > > Here's a class from the GWT GData library (corresponds to
> > > >http://code.google.com/apis/gdata/jsdoc/1.8/google/gdata/Who.html):
>
> > > > package com.google.gwt.gdata.client;
> > > > import com.google.gwt.gdata.client.EntryLink;
> > > > import com.google.gwt.gdata.client.AttendeeType;
> > > > import com.google.gwt.gdata.client.AttendeeStatus;
> > > > import com.google.gwt.core.client.JavaScriptObject;
>
> > > > public class Who extends com.google.gwt.core.client.JavaScriptObject {
> > > >        public static native String REL_EVENT_ATTENDEE() /*-{ return
> > > > $wnd.google.gdata.Who.REL_EVENT_ATTENDEE; }-*/;
> > > >        public static native String REL_EVENT_ORGANIZER() /*-{ return
> > > > $wnd.google.gdata.Who.REL_EVENT_ORGANIZER; }-*/;
> > > >        public static native String REL_EVENT_PERFORMER() /*-{ return
> > > > $wnd.google.gdata.Who.REL_EVENT_PERFORMER; }-*/;
> > > >        public static native String REL_EVENT_SPEAKER() /*-{ return
> > > > $wnd.google.gdata.Who.REL_EVENT_SPEAKER; }-*/;
> > > >        public static native String REL_MESSAGE_BCC() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_BCC; }-*/;
> > > >        public static native String REL_MESSAGE_CC() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_CC; }-*/;
> > > >        public static native String REL_MESSAGE_FROM() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_FROM; }-*/;
> > > >        public static native String REL_MESSAGE_REPLY_TO() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_REPLY_TO; }-*/;
> > > >        public static native String REL_MESSAGE_TO() /*-{ return
> > > > $wnd.google.gdata.Who.REL_MESSAGE_TO; }-*/;
> > > >        public static native String REL_TASK_ASSIGNED_TO() /*-{ return
> > > > $wnd.google.gdata.Who.REL_TASK_ASSIGNED_TO; }-*/;
>
> > > >        protected Who() { }
>
> > > >        public static native Who construct(JavaScriptObject opt_params) 
> > > > /*-
> > > > { return new $wnd.google.gdata.Who(opt_params); }-*/;
> > > >        public static native Who construct() /*-{ return new
> > > > $wnd.google.gdata.Who(undefined); }-*/;
>
> > > I believe that passing 'undefined' as a parameter is the same as
> > > passing no parameters at all.  In general, making the JavaScript less
> > > verbose will make the resulting compiled code smaller to download.
> > > Every bit helps!
>
> > > >        public final native AttendeeStatus getAttendeeStatus() /*-{ 
> > > > return
> > > > this.getAttendeeStatus(); }-*/;
> > > >        public final native AttendeeType getAttendeeType() /*-{ return
> > > > this.getAttendeeType(); }-*/;
> > > >        public final native String getEmail() /*-{ return 
> > > > this.getEmail(); }-
> > > > */;
> > > >        public final native EntryLink getEntryLink() /*-{ return
> > > > this.getEntryLink(); }-*/;
> > > >        public final native String getRel() /*-{ return this.getRel(); 
> > > > }-*/;
> > > >        public final native String getValueString() /*-{ return
> > > > this.getValueString(); }-*/;
> > > >        public final native void setAttendeeStatus(JavaScriptObject
> > > > attendeeStatus) /*-{ this.setAttendeeStatus(attendeeStatus); }-*/;
> > > >        public final native void setAttendeeStatus() /*-
> > > > { this.setAttendeeStatus(undefined); }-*/;
> > > >        public final native void setAttendeeStatus(AttendeeStatus
> > > > attendeeStatus) /*-{ this.setAttendeeStatus(attendeeStatus); }-*/;
> > > >        public final native void setAttendeeType(JavaScriptObject
> > > > attendeeType) /*-{ this.setAttendeeType(attendeeType); }-*/;
> > > >        public final native void setAttendeeType() /*-{ 
> > > > this.setAttendeeType
> > > > (undefined); }-*/;
> > > >        public final native void setAttendeeType(AttendeeType 
> > > > attendeeType) /
> > > > *-{ this.setAttendeeType(attendeeType); }-*/;
> > > >        public final native void setEmail(String email) /*-{ 
> > > > this.setEmail
> > > > (email); }-*/;
> > > >        public final native void setEmail() /*-{ 
> > > > this.setEmail(undefined); }-
> > > > */;
> > > >        public final native void
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to