Example usage for com.google.gwt.json.client JSONValue isArray

List of usage examples for com.google.gwt.json.client JSONValue isArray

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONValue isArray.

Prototype

public JSONArray isArray() 

Source Link

Document

Returns a non-null reference if this JSONValue is really a JSONArray.

Usage

From source file:lh.api.showcase.client.referencedata.airports.AirportsResponseJsonParser.java

License:Apache License

@Override
public List<Airport> parse(String json) {

    List<Airport> ret = new ArrayList<Airport>();

    JSONValue jsv = JSONParser.parseStrict(json);
    JSONObject jobj = jsv.isObject();//from  w  ww .  jav  a2  s  . c o  m

    JSONValue jsAirportResourceVal = jobj.get("AirportResource");
    JSONObject jsAirportResourceObj = jsAirportResourceVal.isObject();

    JSONValue jsAirportsVal = jsAirportResourceObj.get("Airports");
    JSONObject jsAirportsObj = jsAirportsVal.isObject();

    JSONValue jsAirportVal = jsAirportsObj.get("Airport");
    JSONObject jsAirportObj = jsAirportVal.isObject();

    if (jsAirportObj == null) {
        JSONArray jarrayAirports = jsAirportVal.isArray();
        if (jarrayAirports != null) {
            for (int i = 0; i < jarrayAirports.size(); ++i) {
                JSONObject jsAirportObject = jarrayAirports.get(i).isObject();
                if (jsAirportObject == null) {
                    continue;
                }
                Airport airport = JsonParserUtils.getAirportInfo(jsAirportObject);
                if (airport != null) {
                    ret.add(airport);
                }
            }
        }
    } else {
        Airport airport = JsonParserUtils.getAirportInfo(jsAirportObj);
        if (airport != null) {
            ret.add(airport);
        }
    }
    return ret;
}

From source file:lh.api.showcase.client.referencedata.cities.CitiesResponseJsonParser.java

License:Apache License

@Override
public ArrayList<City> parse(String json) {

    ArrayList<City> ret = new ArrayList<City>();

    JSONValue jsv = JSONParser.parseStrict(json);
    JSONObject jobj = jsv.isObject();// ww  w. jav a2s  .  c  o m

    JSONValue jsCityResourceVal = jobj.get("CityResource");
    JSONObject jsCityResourceObj = jsCityResourceVal.isObject();

    JSONValue jsCitiesVal = jsCityResourceObj.get("Cities");
    JSONObject jsCitiesObj = jsCitiesVal.isObject();

    JSONValue jsCityVal = jsCitiesObj.get("City");
    JSONObject jsCityObj = jsCityVal.isObject();

    if (jsCityObj == null) {
        JSONArray jarrayCities = jsCityVal.isArray();
        if (jarrayCities != null) {
            for (int i = 0; i < jarrayCities.size(); ++i) {
                JSONObject jsCityObject = jarrayCities.get(i).isObject();
                if (jsCityObject == null) {
                    continue;
                }
                City city = getCityInfo(jsCityObject);
                if (city != null) {
                    ret.add(city);
                }
            }
        }
    } else {
        City city = getCityInfo(jsCityObj);
        if (city != null) {
            ret.add(city);
        }
    }
    return ret;
}

From source file:lh.api.showcase.client.referencedata.cities.CitiesResponseJsonParser.java

License:Apache License

public static Set<String> getAirportInfo(JSONObject jsAirportsObj) {
    if (jsAirportsObj == null) {
        return null;
    }//  w ww.j  a  va  2  s  . c o  m
    Set<String> ret = new HashSet<String>();
    JSONValue jsAirportCodeVal = jsAirportsObj.get("AirportCode");
    JSONString jsjsAirportCodeValStr = jsAirportCodeVal.isString();

    if (jsjsAirportCodeValStr == null) {

        JSONArray jsAirportCodeArray = jsAirportCodeVal.isArray();
        if (jsAirportCodeArray != null) {
            for (int i = 0; i < jsAirportCodeArray.size(); ++i) {

                JSONString jsCodeStr = jsAirportCodeArray.get(i).isString();
                if (jsCodeStr == null) {
                    continue;
                }
                ret.add(jsCodeStr.toString().replace("\"", ""));
            }
        }
    } else {
        ret.add(jsjsAirportCodeValStr.toString().replace("\"", ""));
    }
    return ret;
}

From source file:lh.api.showcase.client.referencedata.countries.CountriesResponseJsonParser.java

License:Apache License

@Override
public List<Country> parse(String json) {
    List<Country> countries = new ArrayList<Country>();

    logger.log(Level.INFO, "JSON parsing");
    JSONValue jsv = JSONParser.parseStrict(json);
    JSONObject jobj = jsv.isObject();//from w w  w  .ja  va 2  s . c  o  m

    JSONValue jsCountriesResourceVal = jobj.get("CountryResource");
    JSONObject jsCountriesResourceObj = jsCountriesResourceVal.isObject();

    JSONValue jsCountriesVal = jsCountriesResourceObj.get("Countries");
    JSONObject jsCountriesObj = jsCountriesVal.isObject();

    JSONValue jsCountryVal = jsCountriesObj.get("Country");
    JSONObject jsCountryObj = jsCountryVal.isObject();

    if (jsCountryObj == null) {
        JSONArray jarrayCountries = jsCountryVal.isArray();
        if (jarrayCountries != null) {
            for (int i = 0; i < jarrayCountries.size(); ++i) {

                JSONObject jsCountryObject = jarrayCountries.get(i).isObject();
                if (jsCountryObject == null) {
                    continue;
                }
                getCountryInfo(jsCountryObject, countries);
            }
        }
    } else {
        getCountryInfo(jsCountryObj, countries);
    }
    return countries;
}

From source file:lh.api.showcase.client.referencedata.nearestairports.NearestAirportsResponseJsonParser.java

License:Apache License

@Override
public List<NearestAirport> parse(String json) {

    List<NearestAirport> ret = new ArrayList<NearestAirport>();

    JSONValue jsv = JSONParser.parseStrict(json);
    JSONObject jobj = jsv.isObject();//from  www.  jav a 2 s . com

    JSONValue jsAirportResourceVal = jobj.get("NearestAirportResource");
    JSONObject jsAirportResourceObj = jsAirportResourceVal.isObject();

    JSONValue jsAirportsVal = jsAirportResourceObj.get("Airports");
    JSONObject jsAirportsObj = jsAirportsVal.isObject();

    JSONValue jsAirportVal = jsAirportsObj.get("Airport");
    JSONObject jsAirportObj = jsAirportVal.isObject();

    if (jsAirportObj == null) {
        JSONArray jarrayAirports = jsAirportVal.isArray();
        if (jarrayAirports != null) {
            for (int i = 0; i < jarrayAirports.size(); ++i) {
                JSONObject jsAirportObject = jarrayAirports.get(i).isObject();
                if (jsAirportObject == null) {
                    continue;
                }
                NearestAirport na = getNearestAirportInfo(jsAirportObject);
                if (na != null) {
                    ret.add(na);
                }
            }
        }
    } else {
        NearestAirport na = getNearestAirportInfo(jsAirportObj);
        if (na != null) {
            ret.add(na);
        }
    }
    return ret;
}

From source file:my.plugin.ide.editor.StringListUnmarshaller.java

License:Open Source License

public List<String> toList(String jsonStr) {

    JSONValue parsed = JSONParser.parseStrict(jsonStr);
    JSONArray jsonArray = parsed.isArray();

    if (jsonArray == null) {
        return Collections.emptyList();
    }//w  w w  . j ava 2 s . c  o  m

    List<String> list = new ArrayList<>();
    for (int i = 0; i < jsonArray.size(); i++) {
        JSONValue jsonValue = jsonArray.get(i);
        JSONString jsonString = jsonValue.isString();
        String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
        list.add(stringValue);
    }

    return list;
}

From source file:net.opentsdb.tsd.client.QueryUi.java

License:Open Source License

/**
 * This is the entry point method.//from w ww  .j a va2s . c  o  m
 */
public void onModuleLoad() {
    asyncGetJson(AGGREGATORS_URL, new GotJsonCallback() {
        public void got(final JSONValue json) {
            // Do we need more manual type checking?  Not sure what will happen
            // in the browser if something other than an array is returned.
            final JSONArray aggs = json.isArray();
            for (int i = 0; i < aggs.size(); i++) {
                aggregators.add(aggs.get(i).isString().stringValue());
            }
            ((MetricForm) metrics.getWidget(0)).setAggregators(aggregators);
        }
    });

    // All UI elements need to regenerate the graph when changed.
    {
        final ValueChangeHandler<Date> vch = new ValueChangeHandler<Date>() {
            public void onValueChange(final ValueChangeEvent<Date> event) {
                refreshGraph();
            }
        };
        TextBox tb = start_datebox.getTextBox();
        tb.addBlurHandler(refreshgraph);
        tb.addKeyPressHandler(refreshgraph);
        start_datebox.addValueChangeHandler(vch);
        tb = end_datebox.getTextBox();
        tb.addBlurHandler(refreshgraph);
        tb.addKeyPressHandler(refreshgraph);
        end_datebox.addValueChangeHandler(vch);
    }
    autoreoload_interval.addBlurHandler(refreshgraph);
    autoreoload_interval.addKeyPressHandler(refreshgraph);
    yrange.addBlurHandler(refreshgraph);
    yrange.addKeyPressHandler(refreshgraph);
    y2range.addBlurHandler(refreshgraph);
    y2range.addKeyPressHandler(refreshgraph);
    ylog.addClickHandler(new AdjustYRangeCheckOnClick(ylog, yrange));
    y2log.addClickHandler(new AdjustYRangeCheckOnClick(y2log, y2range));
    ylog.addClickHandler(refreshgraph);
    y2log.addClickHandler(refreshgraph);
    ylabel.addBlurHandler(refreshgraph);
    ylabel.addKeyPressHandler(refreshgraph);
    y2label.addBlurHandler(refreshgraph);
    y2label.addKeyPressHandler(refreshgraph);
    yformat.addBlurHandler(refreshgraph);
    yformat.addKeyPressHandler(refreshgraph);
    y2format.addBlurHandler(refreshgraph);
    y2format.addKeyPressHandler(refreshgraph);
    wxh.addBlurHandler(refreshgraph);
    wxh.addKeyPressHandler(refreshgraph);
    horizontalkey.addClickHandler(refreshgraph);
    keybox.addClickHandler(refreshgraph);
    nokey.addClickHandler(refreshgraph);

    yrange.setValidationRegexp("^(" // Nothing or
            + "|\\[([-+.0-9eE]+|\\*)?" // "[start
            + ":([-+.0-9eE]+|\\*)?\\])$"); //   :end]"
    yrange.setVisibleLength(5);
    yrange.setMaxLength(44); // MAX=2^26=20 chars: "[-$MAX:$MAX]"
    yrange.setText("[0:]");

    y2range.setValidationRegexp("^(" // Nothing or
            + "|\\[([-+.0-9eE]+|\\*)?" // "[start
            + ":([-+.0-9eE]+|\\*)?\\])$"); //   :end]"
    y2range.setVisibleLength(5);
    y2range.setMaxLength(44); // MAX=2^26=20 chars: "[-$MAX:$MAX]"
    y2range.setText("[0:]");
    y2range.setEnabled(false);
    y2log.setEnabled(false);

    ylabel.setVisibleLength(10);
    ylabel.setMaxLength(50); // Arbitrary limit.
    y2label.setVisibleLength(10);
    y2label.setMaxLength(50); // Arbitrary limit.
    y2label.setEnabled(false);

    yformat.setValidationRegexp("^(|.*%..*)$"); // Nothing or at least one %?
    yformat.setVisibleLength(10);
    yformat.setMaxLength(16); // Arbitrary limit.
    y2format.setValidationRegexp("^(|.*%..*)$"); // Nothing or at least one %?
    y2format.setVisibleLength(10);
    y2format.setMaxLength(16); // Arbitrary limit.
    y2format.setEnabled(false);

    wxh.setValidationRegexp("^[1-9][0-9]{2,}x[1-9][0-9]{2,}$"); // 100x100
    wxh.setVisibleLength(9);
    wxh.setMaxLength(11); // 99999x99999
    wxh.setText((Window.getClientWidth() - 20) + "x" + (Window.getClientHeight() * 4 / 5));

    final FlexTable table = new FlexTable();
    table.setText(0, 0, "From");
    {
        final HorizontalPanel hbox = new HorizontalPanel();
        hbox.add(new InlineLabel("To"));
        final Anchor now = new Anchor("(now)");
        now.addClickHandler(new ClickHandler() {
            public void onClick(final ClickEvent event) {
                end_datebox.setValue(new Date());
                refreshGraph();
            }
        });
        hbox.add(now);
        hbox.add(autoreoload);
        hbox.setWidth("100%");
        table.setWidget(0, 1, hbox);
    }
    autoreoload.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            if (autoreoload.isChecked()) {
                final HorizontalPanel hbox = new HorizontalPanel();
                hbox.setWidth("100%");
                hbox.add(new InlineLabel("Every:"));
                hbox.add(autoreoload_interval);
                hbox.add(new InlineLabel("seconds"));
                table.setWidget(1, 1, hbox);
                if (autoreoload_interval.getValue().isEmpty()) {
                    autoreoload_interval.setValue("15");
                }
                autoreoload_interval.setFocus(true);
                lastgraphuri = ""; // Force refreshGraph.
                refreshGraph(); // Trigger the 1st auto-reload
            } else {
                table.setWidget(1, 1, end_datebox);
            }
        }
    });
    autoreoload_interval.setValidationRegexp("^([5-9]|[1-9][0-9]+)$"); // >=5s
    autoreoload_interval.setMaxLength(4);
    autoreoload_interval.setVisibleLength(8);

    table.setWidget(1, 0, start_datebox);
    table.setWidget(1, 1, end_datebox);
    {
        final HorizontalPanel hbox = new HorizontalPanel();
        hbox.add(new InlineLabel("WxH:"));
        hbox.add(wxh);
        table.setWidget(0, 3, hbox);
    }
    {
        final MetricForm.MetricChangeHandler metric_change_handler = new MetricForm.MetricChangeHandler() {
            public void onMetricChange(final MetricForm metric) {
                final int index = metrics.getWidgetIndex(metric);
                metrics.getTabBar().setTabText(index, getTabTitle(metric));
            }

            private String getTabTitle(final MetricForm metric) {
                final String metrictext = metric.getMetric();
                final int last_period = metrictext.lastIndexOf('.');
                if (last_period < 0) {
                    return metrictext;
                }
                return metrictext.substring(last_period + 1);
            }
        };
        final EventsHandler updatey2range = new EventsHandler() {
            protected <H extends EventHandler> void onEvent(final DomEvent<H> event) {
                for (final Widget metric : metrics) {
                    if (!(metric instanceof MetricForm)) {
                        continue;
                    }
                    if (((MetricForm) metric).x1y2().getValue()) {
                        y2range.setEnabled(true);
                        y2log.setEnabled(true);
                        y2label.setEnabled(true);
                        y2format.setEnabled(true);
                        return;
                    }
                }
                y2range.setEnabled(false);
                y2log.setEnabled(false);
                y2label.setEnabled(false);
                y2format.setEnabled(false);
            }
        };
        final MetricForm metric = new MetricForm(refreshgraph);
        metric.x1y2().addClickHandler(updatey2range);
        metric.setMetricChangeHandler(metric_change_handler);
        metrics.add(metric, "metric 1");
        metrics.selectTab(0);
        metrics.add(new InlineLabel("Loading..."), "+");
        metrics.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
            public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) {
                final int item = event.getItem();
                final int nitems = metrics.getWidgetCount();
                if (item == nitems - 1) { // Last item: the "+" was clicked.
                    event.cancel();
                    final MetricForm metric = new MetricForm(refreshgraph);
                    metric.x1y2().addClickHandler(updatey2range);
                    metric.setMetricChangeHandler(metric_change_handler);
                    metric.setAggregators(aggregators);
                    metrics.insert(metric, "metric " + nitems, item);
                    metrics.selectTab(item);
                    metric.setFocus(true);
                }
            }
        });
        table.setWidget(2, 0, metrics);
    }
    table.getFlexCellFormatter().setColSpan(2, 0, 2);
    table.getFlexCellFormatter().setRowSpan(1, 3, 2);
    final DecoratedTabPanel optpanel = new DecoratedTabPanel();
    optpanel.add(makeAxesPanel(), "Axes");
    optpanel.add(makeKeyPanel(), "Key");
    optpanel.selectTab(0);
    table.setWidget(1, 3, optpanel);

    final DecoratorPanel decorator = new DecoratorPanel();
    decorator.setWidget(table);
    final VerticalPanel graphpanel = new VerticalPanel();
    graphpanel.add(decorator);
    {
        final VerticalPanel graphvbox = new VerticalPanel();
        graphvbox.add(graphstatus);
        graph.setVisible(false);
        graphvbox.add(graph);
        graph.addErrorHandler(new ErrorHandler() {
            public void onError(final ErrorEvent event) {
                graphstatus.setText("Oops, failed to load the graph.");
            }
        });
        graphpanel.add(graphvbox);
    }
    final DecoratedTabPanel mainpanel = new DecoratedTabPanel();
    mainpanel.setWidth("100%");
    mainpanel.add(graphpanel, "Graph");
    mainpanel.add(stats_table, "Stats");
    mainpanel.add(logs, "Logs");
    mainpanel.add(build_data, "Version");
    mainpanel.selectTab(0);
    mainpanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) {
            clearError();
            final int item = event.getItem();
            switch (item) {
            case 1:
                refreshStats();
                return;
            case 2:
                refreshLogs();
                return;
            case 3:
                refreshVersion();
                return;
            }
        }
    });
    final VerticalPanel root = new VerticalPanel();
    root.setWidth("100%");
    root.add(current_error);
    current_error.setVisible(false);
    current_error.addStyleName("dateBoxFormatError");
    root.add(mainpanel);
    RootPanel.get("queryuimain").add(root);
    // Must be done at the end, once all the widgets are attached.
    ensureSameWidgetSize(optpanel);
}

From source file:net.opentsdb.tsd.client.QueryUi.java

License:Open Source License

private void refreshStats() {
    asyncGetJson(STATS_URL, new GotJsonCallback() {
        public void got(final JSONValue json) {
            final JSONArray stats = json.isArray();
            final int nstats = stats.size();
            for (int i = 0; i < nstats; i++) {
                final String stat = stats.get(i).isString().stringValue();
                String part = stat.substring(0, stat.indexOf(' '));
                stats_table.setText(i, 0, part); // metric
                int pos = part.length() + 1;
                part = stat.substring(pos, stat.indexOf(' ', pos));
                stats_table.setText(i, 1, part); // timestamp
                pos += part.length() + 1;
                part = stat.substring(pos, stat.indexOf(' ', pos));
                stats_table.setText(i, 2, part); // value
                pos += part.length() + 1;
                stats_table.setText(i, 3, stat.substring(pos)); // tags
            }/*  w w  w  .ja  v  a  2  s .  com*/
        }
    });
}

From source file:net.opentsdb.tsd.client.QueryUi.java

License:Open Source License

private void refreshLogs() {
    asyncGetJson(LOGS_URL, new GotJsonCallback() {
        public void got(final JSONValue json) {
            final JSONArray logmsgs = json.isArray();
            final int nmsgs = logmsgs.size();
            final FlexTable.FlexCellFormatter fcf = logs.getFlexCellFormatter();
            final FlexTable.RowFormatter rf = logs.getRowFormatter();
            for (int i = 0; i < nmsgs; i++) {
                final String msg = logmsgs.get(i).isString().stringValue();
                String part = msg.substring(0, msg.indexOf('\t'));
                logs.setText(i * 2, 0, new Date(Integer.valueOf(part) * 1000L).toString());
                logs.setText(i * 2 + 1, 0, ""); // So we can change the style ahead.
                int pos = part.length() + 1;
                part = msg.substring(pos, msg.indexOf('\t', pos));
                if ("WARN".equals(part)) {
                    rf.getElement(i * 2).getStyle().setBackgroundColor("#FCC");
                    rf.getElement(i * 2 + 1).getStyle().setBackgroundColor("#FCC");
                } else if ("ERROR".equals(part)) {
                    rf.getElement(i * 2).getStyle().setBackgroundColor("#F99");
                    rf.getElement(i * 2 + 1).getStyle().setBackgroundColor("#F99");
                } else {
                    rf.getElement(i * 2).getStyle().clearBackgroundColor();
                    rf.getElement(i * 2 + 1).getStyle().clearBackgroundColor();
                    if ((i % 2) == 0) {
                        rf.addStyleName(i * 2, "subg");
                        rf.addStyleName(i * 2 + 1, "subg");
                    }//from www  .  j av  a 2 s .  co  m
                }
                pos += part.length() + 1;
                logs.setText(i * 2, 1, part); // level
                part = msg.substring(pos, msg.indexOf('\t', pos));
                pos += part.length() + 1;
                logs.setText(i * 2, 2, part); // thread
                part = msg.substring(pos, msg.indexOf('\t', pos));
                pos += part.length() + 1;
                if (part.startsWith("net.opentsdb.")) {
                    part = part.substring(13);
                } else if (part.startsWith("org.hbase.")) {
                    part = part.substring(10);
                }
                logs.setText(i * 2, 3, part); // logger
                logs.setText(i * 2 + 1, 0, msg.substring(pos)); // message
                fcf.setColSpan(i * 2 + 1, 0, 4);
                rf.addStyleName(i * 2, "fwf");
                rf.addStyleName(i * 2 + 1, "fwf");
            }
        }
    });
}

From source file:net.opentsdb.tsd.client.RemoteOracle.java

License:Open Source License

@Override
public void requestSuggestions(final Request request, final Callback callback) {
    if (current != null) {
        pending_req = request;/*from   ww w .  j av  a 2 s  .  c  o m*/
        pending_cb = callback;
        return;
    }
    current = callback;
    {
        final String this_query = request.getQuery();
        // Check if we can serve this from our local cache, without even talking
        // to the server.  This is possible if either of those is true:
        //   1. We've already seen this query recently.
        //   2. This new query precedes another one and the user basically just
        //      typed another letter, so if the new query is "less than" the last
        //      result we got from the server, we know we already cached the full
        //      range of results covering the new request.
        if ((last_query != null && last_query.compareTo(this_query) <= 0
                && this_query.compareTo(last_suggestion) < 0) || queries_seen.check(this_query)) {
            current = null;
            cache.requestSuggestions(request, callback);
            return;
        }
        last_query = this_query;
    }

    final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
            SUGGEST_URL + type + "&q=" + last_query);
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(final com.google.gwt.http.client.Request r, final Throwable e) {
                current = null; // Something bad happened, drop the current request.
                if (pending_req != null) { // But if we have another waiting...
                    requestSuggestions(pending_req, pending_cb); // ... try it now.
                }
            }

            // Need to use fully-qualified names as this class inherits already
            // from a pair of inner classes called Request / Response :-/
            public void onResponseReceived(final com.google.gwt.http.client.Request r,
                    final com.google.gwt.http.client.Response response) {
                if (response.getStatusCode() == com.google.gwt.http.client.Response.SC_OK
                        // Is this response still relevant to what the requester wants?
                        && requester.getText().startsWith(last_query)) {
                    final JSONValue json = JSONParser.parse(response.getText());
                    // In case this request returned nothing, we pretend the last
                    // suggestion ended with the largest character possible, so we
                    // won't send more requests to the server if the user keeps
                    // adding extra characters.
                    last_suggestion = last_query + "\377";
                    if (json != null && json.isArray() != null) {
                        final JSONArray results = json.isArray();
                        final int n = Math.min(request.getLimit(), results.size());
                        for (int i = 0; i < n; i++) {
                            final JSONValue suggestion = results.get(i);
                            if (suggestion == null || suggestion.isString() == null) {
                                continue;
                            }
                            final String suggestionstr = suggestion.isString().stringValue();
                            last_suggestion = suggestionstr;
                            cache.add(suggestionstr);
                        }
                        cache.requestSuggestions(request, callback);
                        pending_req = null;
                        pending_cb = null;
                    }
                }
                current = null; // Regardless of what happened above, this is done.
                if (pending_req != null) {
                    final Request req = pending_req;
                    final Callback cb = pending_cb;
                    pending_req = null;
                    pending_cb = null;
                    requestSuggestions(req, cb);
                }
            }
        });
    } catch (RequestException ignore) {
    }
}