当前位置: 首页>>代码示例>>Java>>正文


Java UrlBuilder类代码示例

本文整理汇总了Java中com.google.gwt.http.client.UrlBuilder的典型用法代码示例。如果您正苦于以下问题:Java UrlBuilder类的具体用法?Java UrlBuilder怎么用?Java UrlBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UrlBuilder类属于com.google.gwt.http.client包,在下文中一共展示了UrlBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private void buildUrl() {
	UrlBuilder urlBuilder = Window.Location.createUrlBuilder();
	PlanRequestBean planRequest = getPlanRequestBean();
	if (planRequest.getDeparture().isSet(false))
		urlBuilder.setParameter("origin",
				getLocationAsStringParam(planRequest.getDeparture()));
	if (planRequest.getArrival().isSet(false))
		urlBuilder.setParameter("destination",
				getLocationAsStringParam(planRequest.getArrival()));
	DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy/MM/[email protected]:mm");
	urlBuilder.setParameter(
			planRequest.isDateDeparture() ? "depart" : "arrive",
			dtf.format(planRequest.getDate()));
	if (planRequest.isWheelchairAccessible())
		urlBuilder.setParameter("wheelchair", "y");
	Set<TransportMode> modes = planRequest.getModes();
	String modesStr = "";
	for (TransportMode mode : modes) {
		modesStr = modesStr + mode.toString() + ",";
	}
	modesStr = modesStr.substring(0, modesStr.length() - 1);
	urlBuilder.setParameter("modes", modesStr);
	url = urlBuilder.buildString();
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:25,代码来源:PlannerState.java

示例2: getUiSwitcherUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private static String getUiSwitcherUrl(String token) {
  UrlBuilder builder = new UrlBuilder();
  builder.setProtocol(Location.getProtocol());
  builder.setHost(Location.getHost());
  String port = Location.getPort();
  if (port != null && !port.isEmpty()) {
    builder.setPort(Integer.parseInt(port));
  }
  String[] tokens = token.split("@", 2);
  if (Location.getPath().endsWith("/") && tokens[0].startsWith("/")) {
    tokens[0] = tokens[0].substring(1);
  }
  builder.setPath(Location.getPath() + tokens[0]);
  if (tokens.length == 2) {
    builder.setHash(tokens[1]);
  }
  builder.setParameter("polygerrit", "1");
  return builder.buildString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:Gerrit.java

示例3: appendToApplicationUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
/**
 * Appends an additional path to the application URL.
 * 
 * @param additionalPath
 *          The additional path to append to the application URL.
 * @return the new URL.
 */
public static String appendToApplicationUrl(String additionalPath) {

	final UrlBuilder urlBuilder = new UrlBuilder();

	urlBuilder.setProtocol(Location.getProtocol());
	urlBuilder.setHost(Location.getHost());
	final Integer port = asInt(Location.getPort());
	if (port != null) {
		urlBuilder.setPort(port);
	}
	urlBuilder.setPath(Location.getPath() + additionalPath);

	return urlBuilder.buildString();

}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:23,代码来源:ClientUtils.java

示例4: select

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
@Override public void select(Drawing drawing) {
    PlaceRequest placeRequest = new PlaceRequest.Builder()
        .nameToken(NameTokens.PLAYER)
        .with("user", "" + drawing.getUserId())
        .with("deal", "" + drawing.getDealId())
        .with("drawing", "" + drawing.getId())
        .build();
    String historyToken = placeManager.buildHistoryToken(placeRequest);
    UrlBuilder urlBuilder = new UrlBuilder()
        .setProtocol(Window.Location.getProtocol())
        .setHost(Window.Location.getHost())
        .setPath(Window.Location.getPath())
        .setHash(historyToken);
    String port = Window.Location.getPort();
    if (port != null && port.length() > 1) {
        urlBuilder.setPort(Integer.parseInt(port));
    }
    getView().displayLink(urlBuilder.buildString());
}
 
开发者ID:Unisay,项目名称:preferanser,代码行数:20,代码来源:DrawingsDialogPresenter.java

示例5: execute

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
@Override
public void execute() {
  final String queryParam = LocaleInfo.getLocaleQueryParam();
  Command savecmd = new SaveAction();
  savecmd.execute();
  if (queryParam != null) {
    UrlBuilder builder = Window.Location.createUrlBuilder().setParameter(
        queryParam, localeName);
    Window.Location.replace(builder.buildString());
  } else {
    // If we are using only cookies, just reload
    Window.Location.reload();
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:15,代码来源:TopPanel.java

示例6: setupLocaleSelect

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById(LANG_ELEMENT_ID);
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }

  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
          LOCALE_URLBUILDER_PARAMETER, select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:30,代码来源:WebClient.java

示例7: switchLocale

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
/**
 * Switches the application locale.
 * @param locale new locale
 */
private void switchLocale(String locale) {
    UrlBuilder urlBuilder = Window.Location.createUrlBuilder();
    urlBuilder.setParameter(LOCALE_ATTRIBUTE, locale);
    String url = urlBuilder.buildString();
    Window.Location.assign(url);
}
 
开发者ID:proarc,项目名称:proarc,代码行数:11,代码来源:Editor.java

示例8: selfRedirect

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
public static String selfRedirect(String suffix) {
  // Clean up the path. Users seem to like putting extra slashes into the URL
  // which can break redirections by misinterpreting at either client or server.
  String path = Location.getPath();
  if (path == null || path.isEmpty()) {
    path = "/";
  } else {
    while (path.startsWith("//")) {
      path = path.substring(1);
    }
    while (path.endsWith("//")) {
      path = path.substring(0, path.length() - 1);
    }
    if (!path.endsWith("/")) {
      path = path + "/";
    }
  }

  if (suffix != null) {
    while (suffix.startsWith("/")) {
      suffix = suffix.substring(1);
    }
    path += suffix;
  }

  UrlBuilder builder = new UrlBuilder();
  builder.setProtocol(Location.getProtocol());
  builder.setHost(Location.getHost());
  String port = Location.getPort();
  if (port != null && !port.isEmpty()) {
    builder.setPort(Integer.parseInt(port));
  }
  builder.setPath(path);
  return builder.buildString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:36,代码来源:Gerrit.java

示例9: addProjectLink

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private static LinkMenuItem addProjectLink(LinkMenuBar m, TopMenuItem item) {
  LinkMenuItem i =
      new ProjectLinkMenuItem(item.getName(), item.getUrl()) {
        @Override
        protected void onScreenLoad(Project.NameKey project) {
          String p = panel.replace(PROJECT_NAME_MENU_VAR, URL.encodeQueryString(project.get()));
          if (!panel.startsWith("/x/") && !isAbsolute(panel)) {
            UrlBuilder builder = new UrlBuilder();
            builder.setProtocol(Location.getProtocol());
            builder.setHost(Location.getHost());
            String port = Location.getPort();
            if (port != null && !port.isEmpty()) {
              builder.setPort(Integer.parseInt(port));
            }
            builder.setPath(Location.getPath());
            p = builder.buildString() + p;
          }
          getElement().setPropertyString("href", p);
        }

        @Override
        public void go() {
          String href = getElement().getPropertyString("href");
          if (href.startsWith("#")) {
            super.go();
          } else {
            Window.open(href, getElement().getPropertyString("target"), "");
          }
        }
      };
  if (item.getTarget() != null && !item.getTarget().isEmpty()) {
    i.getElement().setAttribute("target", item.getTarget());
  }
  if (item.getId() != null) {
    i.getElement().setAttribute("id", item.getId());
  }
  m.addItem(i);
  return i;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:40,代码来源:Gerrit.java

示例10: getApplicationUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
/**
 * Returns the current application URL (with current optional parameters) with the given additional parameter
 * {@code paramName}.
 * 
 * @param withParameters
 *          {@code true} to retrieve existing current URL parameters, {@code false} to forget them.
 * @param paramName
 *          The parameter name.
 * @param paramValues
 *          The parameter value(s).
 * @return the current application URL (with current optional parameters) with the given additional parameter
 *         {@code paramName}.
 */
public static String getApplicationUrl(boolean withParameters, String paramName, String... paramValues) {

	final UrlBuilder urlBuilder = new UrlBuilder();

	urlBuilder.setProtocol(Location.getProtocol());
	urlBuilder.setHost(Location.getHost());
	final Integer port = asInt(Location.getPort());
	if (port != null) {
		urlBuilder.setPort(port);
	}
	urlBuilder.setPath(Location.getPath());

	if (Location.getParameterMap() != null) {
		// "?gwt.codesvr=127.0.0.1:9997" for example.
		for (final Entry<String, List<String>> param : Location.getParameterMap().entrySet()) {

			if ("gwt.codesvr".equalsIgnoreCase(param.getKey()) && isNotEmpty(param.getValue())) {
				// Hosted mode parameter exception.
				urlBuilder.setParameter(param.getKey(), param.getValue().get(0));

			} else if (withParameters) {
				final String[] values = param.getValue() != null ? param.getValue().toArray(new String[param.getValue().size()]) : null;
				urlBuilder.setParameter(param.getKey(), values);
			}
		}
	}

	if (isNotBlank(paramName) && paramValues != null) {
		urlBuilder.setParameter(paramName, paramValues);
	}

	return urlBuilder.buildString();
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:47,代码来源:ClientUtils.java

示例11: addGraphToReport

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
@Override
public void addGraphToReport(final RequestCallback callback, final int kscReportId, final String graphTitle, final String graphName, final String resourceId, final String timeSpan) {
    UrlBuilder builder = new UrlBuilder();
    builder.setPath(BASE_URL + "/" + kscReportId);
    builder.setParameter("title", graphTitle);
    builder.setParameter("reportName", graphName);
    builder.setParameter("resourceId", resourceId);
    builder.setParameter("timespan", timeSpan);

    // we just want a relative URL, so we render it and strip the beginning :)
    final String url = builder.buildString().replace("http:///", "");
    GWT.log("making request: " + url);
    sendRequest(callback, RequestBuilder.PUT, url);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:DefaultKscReportService.java

示例12: buildLocaleUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
/** Build the correct URL for the new locale. */
private String buildLocaleUrl(String selectedLocale) {
	UrlBuilder builder = Window.Location.createUrlBuilder();
	builder.removeParameter("locale");
	if (!"default".equals(selectedLocale)) {
		builder.setParameter("locale", selectedLocale);
	}
	return builder.buildString();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:10,代码来源:LocaleSelect.java

示例13: getCapaUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private String getCapaUrl() {
	UrlBuilder builder = Window.Location.createUrlBuilder();
	String url = builder.buildString();

	int pos = url.indexOf("index.html");
	url = url.substring(0, pos) + "tms_capa.xml";
	return url;
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:9,代码来源:CapabilitiesPanel.java

示例14: getCapaUrl

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private String getCapaUrl() {
	UrlBuilder builder = Window.Location.createUrlBuilder();
	String url = builder.buildString();

	int pos = url.indexOf("index.html");
	url = url.substring(0, pos) + "d/tms/1.0.0";
	return url;
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:9,代码来源:ProfilesPanel.java

示例15: setupLocaleSelect

import com.google.gwt.http.client.UrlBuilder; //导入依赖的package包/类
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById("lang");
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }
  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
              "locale", select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:29,代码来源:WebClient.java


注:本文中的com.google.gwt.http.client.UrlBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。