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


Java UrlBuilder.setPath方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: runAnalysis

import com.google.gwt.http.client.UrlBuilder; //导入方法依赖的package包/类
protected void runAnalysis() {
	
	String pagename = Window.Location.getPath().substring( 0, Window.Location.getPath().lastIndexOf( "/" ) );
	
	pagename += "/report.jsp";
	
	UrlBuilder ub = Window.Location.createUrlBuilder();
	
	ub.setPath( pagename );
	ub.setParameter( "target", entityLabel.getText() );
	ub.setParameter( "rc", rcLabel.getText() );
	Window.Location.replace( ub.buildString() );
}
 
开发者ID:RISCOSS,项目名称:riscoss-corporate,代码行数:14,代码来源:RiskAnalysisModule.java


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