本文整理汇总了Java中com.google.gwt.http.client.UrlBuilder.setProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java UrlBuilder.setProtocol方法的具体用法?Java UrlBuilder.setProtocol怎么用?Java UrlBuilder.setProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.http.client.UrlBuilder
的用法示例。
在下文中一共展示了UrlBuilder.setProtocol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}