Java tutorial
/* * Copyright 2009 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.gdata.client.gbase; import com.google.gwt.gdata.client.GDataRequestParameters; import com.google.gwt.gdata.client.GoogleService; /** * Google Base service. */ public class GoogleBaseService extends GoogleService { /** * Google Base service name. */ public static final String SERVICE_NAME = getConstant("SERVICE_NAME"); /** * Constructs a Google Base service. * * @param applicationName Name of application (used for tracking). * @return A GoogleBaseService object. */ public static native GoogleBaseService newInstance(String applicationName) /*-{ return new $wnd.google.gdata.gbase.GoogleBaseService(applicationName); }-*/; private static native String getConstant(String name) /*-{ return $wnd.google.gdata.gbase.GoogleBaseService[name]; }-*/; protected GoogleBaseService() { } /** * Retrieves a Google Base attribute entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getAttributesEntry(String uri, AttributesEntryCallback callback) { this.getAttributesEntry(uri, callback, null); } /** * Retrieves a Google Base attribute entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getAttributesEntry(String uri, AttributesEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getAttributesEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of public attributes. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getAttributesFeed(AttributesQuery query, AttributesFeedCallback callback) { this.getAttributesFeed(query, callback, null); } /** * Retrieves the feed of public attributes. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getAttributesFeed(AttributesQuery query, AttributesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getAttributesFeed( query, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of public attributes. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getAttributesFeed(String uri, AttributesFeedCallback callback) { this.getAttributesFeed(uri, callback, null); } /** * Retrieves the feed of public attributes. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getAttributesFeed(String uri, AttributesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getAttributesFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves a Google Base item entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemsEntry(String uri, ItemsEntryCallback callback) { this.getItemsEntry(uri, callback, null); } /** * Retrieves a Google Base item entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemsEntry(String uri, ItemsEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getItemsEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of a user's private items. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemsFeed(ItemsQuery query, ItemsFeedCallback callback) { this.getItemsFeed(query, callback, null); } /** * Retrieves the feed of a user's private items. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemsFeed(ItemsQuery query, ItemsFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getItemsFeed( query, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of a user's private items. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemsFeed(String uri, ItemsFeedCallback callback) { this.getItemsFeed(uri, callback, null); } /** * Retrieves the feed of a user's private items. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemsFeed(String uri, ItemsFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getItemsFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves a Google Base item type entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemTypesEntry(String uri, ItemTypesEntryCallback callback) { this.getItemTypesEntry(uri, callback, null); } /** * Retrieves a Google Base item type entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemTypesEntry(String uri, ItemTypesEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getItemTypesEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of public item types. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemTypesFeed(ItemTypesQuery query, ItemTypesFeedCallback callback) { this.getItemTypesFeed(query, callback, null); } /** * Retrieves the feed of public item types. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemTypesFeed(ItemTypesQuery query, ItemTypesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getItemTypesFeed( query, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of public item types. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getItemTypesFeed(String uri, ItemTypesFeedCallback callback) { this.getItemTypesFeed(uri, callback, null); } /** * Retrieves the feed of public item types. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getItemTypesFeed(String uri, ItemTypesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getItemTypesFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves a Google Base locale entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getLocalesEntry(String uri, LocalesEntryCallback callback) { this.getLocalesEntry(uri, callback, null); } /** * Retrieves a Google Base locale entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getLocalesEntry(String uri, LocalesEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getLocalesEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of locales. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getLocalesFeed(LocalesQuery query, LocalesFeedCallback callback) { this.getLocalesFeed(query, callback, null); } /** * Retrieves the feed of locales. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getLocalesFeed(LocalesQuery query, LocalesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getLocalesFeed( query, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of locales. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getLocalesFeed(String uri, LocalesFeedCallback callback) { this.getLocalesFeed(uri, callback, null); } /** * Retrieves the feed of locales. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getLocalesFeed(String uri, LocalesFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getLocalesFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves a Google Base media entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getMediaEntry(String uri, MediaEntryCallback callback) { this.getMediaEntry(uri, callback, null); } /** * Retrieves a Google Base media entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getMediaEntry(String uri, MediaEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getMediaEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the media feed used for managing the media attachments for one * Google Base Item. * * @param uri URI of feed. * @param callback Callback defining success and failure handlers for this * command. */ public final void getMediaFeed(String uri, MediaFeedCallback callback) { this.getMediaFeed(uri, callback, null); } /** * Retrieves the media feed used for managing the media attachments for one * Google Base Item. * * @param uri URI of feed. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getMediaFeed(String uri, MediaFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getMediaFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves a Google Base snippet entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. */ public final void getSnippetsEntry(String uri, SnippetsEntryCallback callback) { this.getSnippetsEntry(uri, callback, null); } /** * Retrieves a Google Base snippet entry. * * @param uri URI of entry. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getSnippetsEntry(String uri, SnippetsEntryCallback callback, GDataRequestParameters parameters) /*-{ this.getSnippetsEntry( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.entry : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of snippets of public items. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getSnippetsFeed(SnippetsQuery query, SnippetsFeedCallback callback) { this.getSnippetsFeed(query, callback, null); } /** * Retrieves the feed of snippets of public items. * * @param query URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getSnippetsFeed(SnippetsQuery query, SnippetsFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getSnippetsFeed( query, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; /** * Retrieves the feed of snippets of public items. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. */ public final void getSnippetsFeed(String uri, SnippetsFeedCallback callback) { this.getSnippetsFeed(uri, callback, null); } /** * Retrieves the feed of snippets of public items. * * @param uri URI of feed or query. * @param callback Callback defining success and failure handlers for this * command. * @param parameters The request parameters. */ public final native void getSnippetsFeed(String uri, SnippetsFeedCallback callback, GDataRequestParameters parameters) /*-{ this.getSnippetsFeed( uri, function(result) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleSuccessCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback, result ? result.feed : result); }, function(error) { @com.google.gwt.gdata.client.impl.CallbackHelper::handleFailureCallback(Lcom/google/gwt/gdata/client/impl/Callback;Lcom/google/gwt/gdata/client/Error;)(callback, error); }, parameters ); }-*/; }