Example usage for com.google.gwt.gdata.client.gbase SnippetsQuery newInstance

List of usage examples for com.google.gwt.gdata.client.gbase SnippetsQuery newInstance

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase SnippetsQuery newInstance.

Prototype

public static native SnippetsQuery newInstance(String feedUri) ;

Source Link

Document

Constructs a Snippets query.

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseQuerySnippetsForCamerasDemo.java

License:Apache License

/**
 * Retrieves a snippets feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the snippets feed, the snippet entries 
 * are displayed to the user via the showData method.
 * We set the BQ parameter to search for digital cameras.
 * //from  w  w  w.j  a v  a 2s . c  o  m
 * @param itemsFeedUri The items feed uri.
 */
private void querySnippets(String itemsFeedUri) {
    showStatus("Loading snippets feed...", false);
    SnippetsQuery query = SnippetsQuery.newInstance(itemsFeedUri);
    query.setMaxResults(25);
    query.setBq("digital camera [megapixels >= 4][price < 200.0][condition:new]");
    service.getSnippetsFeed(query, new SnippetsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the snippets feed: " + caught.getMessage(), true);
        }

        public void onSuccess(SnippetsFeed result) {
            SnippetsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No snippets matched the search criteria.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseQuerySnippetsForConvertiblesDemo.java

License:Apache License

/**
 * Retrieves a snippets feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the snippets feed, the snippet entries 
 * are displayed to the user via the showData method.
 * We set the BQ parameter to search for convertibles.
 * /*www . j a  v a 2 s.  c  o m*/
 * @param itemsFeedUri The items feed uri.
 */
private void querySnippets(String itemsFeedUri) {
    showStatus("Loading snippets feed...", false);
    SnippetsQuery query = SnippetsQuery.newInstance(itemsFeedUri);
    query.setMaxResults(25);
    query.setBq("convertible [brand:Volkswagen][year >=2003]" + "[color:red][vehicle type:car]");
    service.getSnippetsFeed(query, new SnippetsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the snippets feed: " + caught.getMessage(), true);
        }

        public void onSuccess(SnippetsFeed result) {
            SnippetsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No snippets matched the search criteria.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseQuerySnippetsForHousingDemo.java

License:Apache License

/**
 * Retrieves a snippets feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the snippets feed, the snippet entries 
 * are displayed to the user via the showData method.
 * We set the BQ parameter to search for housing.
 * /*from   w w w  .ja va 2  s .  co  m*/
 * @param itemsFeedUri The items feed uri.
 */
private void querySnippets(String itemsFeedUri) {
    showStatus("Loading snippets feed...", false);
    SnippetsQuery query = SnippetsQuery.newInstance(itemsFeedUri);
    query.setMaxResults(25);
    query.setBq("[item type:housing][listing type:for sale]"
            + "[location:@\"San Jose, CA, USA\"+15mi][price < 700000 USD]");
    service.getSnippetsFeed(query, new SnippetsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the snippets feed: " + caught.getMessage(), true);
        }

        public void onSuccess(SnippetsFeed result) {
            SnippetsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No snippets matched the search criteria.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseQuerySnippetsForJobsDemo.java

License:Apache License

/**
 * Retrieves a snippets feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the snippets feed, the snippet entries 
 * are displayed to the user via the showData method.
 * We set the BQ query string to search for jobs.
 * /*from  www.  ja v  a 2s.  c  o  m*/
 * @param itemsFeedUri The items feed uri.
 */
private void querySnippets(String itemsFeedUri) {
    showStatus("Loading snippets feed...", false);
    SnippetsQuery query = SnippetsQuery.newInstance(itemsFeedUri);
    query.setMaxResults(25);
    query.setBq("[employer: Google][job type:full-time][job function:Marketing]");
    service.getSnippetsFeed(query, new SnippetsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the snippets feed: " + caught.getMessage(), true);
        }

        public void onSuccess(SnippetsFeed result) {
            SnippetsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No snippets matched the search criteria.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseQuerySnippetsForRecipesDemo.java

License:Apache License

/**
 * Retrieves a snippets feed using a Query object.
 * In GData, feed URIs can contain query string parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the snippets feed, the snippet entries 
 * are displayed to the user via the showData method.
 * We set the BQ parameter to search for recipes.
 * //from  w w  w. jav  a2 s  . c  o m
 * @param itemsFeedUri The items feed uri.
 */
private void querySnippets(String itemsFeedUri) {
    showStatus("Loading snippets feed...", false);
    SnippetsQuery query = SnippetsQuery.newInstance(itemsFeedUri);
    query.setMaxResults(25);
    query.setBq("[item type:recipes][cuisine:chinese][course:main]" + "[main ingredient:chicken]");
    service.getSnippetsFeed(query, new SnippetsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the snippets feed: " + caught.getMessage(), true);
        }

        public void onSuccess(SnippetsFeed result) {
            SnippetsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("No snippets matched the search criteria.", false);
            } else {
                showData(entries);
            }
        }
    });
}