Android Open Source - dashclock-gerrit Query Builder






From Project

Back to project page dashclock-gerrit.

License

The source code is released under:

Apache License

If you think the Android project dashclock-gerrit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.plusonelabs.dashclock.gerrit;
/*from w  ww  . j  a v a 2  s.c  om*/
import static com.plusonelabs.dashclock.gerrit.util.ParamCheck.*;
import static com.plusonelabs.dashclock.gerrit.util.StringUtil.*;

import com.plusonelabs.dashclock.gerrit.util.UrlUtil;

public class QueryBuilder {

  private final String baseUrl;
  private final boolean anonymous;
  private String branch;
  private String project;
  private String reviewer;

  public QueryBuilder(String baseUrl, boolean anonymous) {
    paramNotNull(baseUrl, "baseUrl");
    this.baseUrl = baseUrl;
    this.anonymous = anonymous;
  }

  public void setProject(String project) {
    this.project = project;
  }

  public void setBranch(String branch) {
    this.branch = branch;
  }

  public void setReviewer(String reviewer) {
    this.reviewer = reviewer;
  }

  public String createQueryUrl() {
    String queryUrl = UrlUtil.appendPath(baseUrl, "changes/?");
    queryUrl += createQueryChanges();
    if (!anonymous) {
      queryUrl += "&";
      queryUrl += createQueryChanges();
      queryUrl += "+reviewer:self";
    } else if (hasContent(reviewer)) {
      queryUrl += "&";
      queryUrl += createQueryChanges();
      queryUrl += "+reviewer:" + reviewer;
    }
    return queryUrl;
  }

  private String createQueryChanges() {
    String query = "q=is:open";
    query += createParamProject();
    query += createParamBranch();
    return query;
  }

  private String createParamProject() {
    if (hasContent(project)) {
      return "+project:" + project;
    }
    return EMPTY_STRING;
  }

  private String createParamBranch() {
    if (hasContent(branch)) {
      return "+branch:" + branch;
    }
    return EMPTY_STRING;
  }

}




Java Source Code List

com.plusonelabs.dashclock.gerrit.Change.java
com.plusonelabs.dashclock.gerrit.GerritDashClockExtension.java
com.plusonelabs.dashclock.gerrit.GerritEndpoint.java
com.plusonelabs.dashclock.gerrit.Gerrit.java
com.plusonelabs.dashclock.gerrit.QueryBuilder.java
com.plusonelabs.dashclock.gerrit.SettingsActivity.java
com.plusonelabs.dashclock.gerrit.TestActivity.java
com.plusonelabs.dashclock.gerrit.auth.AnonymousAuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.auth.AuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.auth.BasicAuthWithCookieAuthenticationProvider.java
com.plusonelabs.dashclock.gerrit.prefs.AboutFragment.java
com.plusonelabs.dashclock.gerrit.prefs.DisplayFragment.java
com.plusonelabs.dashclock.gerrit.prefs.GerritPreferences.java
com.plusonelabs.dashclock.gerrit.prefs.SecurePreferences.java
com.plusonelabs.dashclock.gerrit.prefs.ServerFragment.java
com.plusonelabs.dashclock.gerrit.util.ParamCheck.java
com.plusonelabs.dashclock.gerrit.util.StringUtil.java
com.plusonelabs.dashclock.gerrit.util.UrlUtil.java