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


Java URI.getRawPath方法代码示例

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


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

示例1: QueryStringDecoderV2

import java.net.URI; //导入方法依赖的package包/类
public QueryStringDecoderV2(URI uri, Charset charset, int maxParams) {
	if (uri == null) {
		throw new NullPointerException("getUri");
	}
	if (charset == null) {
		throw new NullPointerException("charset");
	}
	if (maxParams <= 0) {
		throw new IllegalArgumentException("maxParams: " + maxParams + " (expected: a positive integer)");
	}

	String rawPath = uri.getRawPath();
	if (rawPath != null) {
		hasPath = true;
	} else {
		rawPath = "";
		hasPath = false;
	}
	// Also take care of cut of things like "http://localhost"
	this.uri = rawPath + (uri.getRawQuery() == null ? "" : '?' + uri.getRawQuery());

	this.charset = charset;
	this.maxParams = maxParams;
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:25,代码来源:QueryStringDecoderV2.java

示例2: getAuthObj

import java.net.URI; //导入方法依赖的package包/类
private String getAuthObj(String remoteDomain, String method, URI target, JsonObject content) {
    String uri = target.getRawPath();
    if (StringUtils.isNotBlank(target.getRawQuery())) {
        uri += "?" + target.getRawQuery();
    }

    JsonObject authObj = new JsonObject();
    authObj.addProperty("method", method);
    authObj.addProperty("uri", uri);
    authObj.addProperty("origin", global.getDomain());
    authObj.addProperty("destination", remoteDomain);
    Optional.ofNullable(content).ifPresent(c -> authObj.add("content", c));
    String data = MatrixJson.encodeCanonical(authObj);
    log.info("Auth object: {}", data);
    return data;
}
 
开发者ID:kamax-io,项目名称:mxhsd,代码行数:17,代码来源:HttpFederationClient.java

示例3: toRequestOptions

import java.net.URI; //导入方法依赖的package包/类
/**
 * Builds the request options suitable for HttpClient from a URI and a relative
 * path.
 *
 * @param uri
 *            URI
 * @return request options
 */
public static RequestOptions toRequestOptions(final URI uri,
    final String relativeUri) {

    final RequestOptions options = new RequestOptions()
        .setSsl("https".equals(uri.getScheme()))
        .setHost(uri.getHost());
    if (uri.getPort() > 0) {
        options.setPort(uri.getPort());
    } else if (options.isSsl()) {
        options.setPort(443);
    } else {
        options.setPort(80);
    }
    final String rawPath = uri.getRawPath() + relativeUri;
    if (uri.getRawQuery() == null) {
        options.setURI(rawPath);
    } else {
        options.setURI(rawPath + "?" + uri.getRawQuery());
    }
    return options;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:30,代码来源:Conversions.java

示例4: signRequest

import java.net.URI; //导入方法依赖的package包/类
/**
 * 生成HTTP请求签名字符串
 *
 * @param urlString
 * @param body
 * @param contentType
 * @return
 */
public String signRequest(String urlString, byte[] body, String contentType) {
    URI uri = URI.create(urlString);
    String path = uri.getRawPath();
    String query = uri.getRawQuery();

    Mac mac = createMac();

    mac.update(StringUtils.utf8Bytes(path));

    if (query != null && query.length() != 0) {
        mac.update((byte) ('?'));
        mac.update(StringUtils.utf8Bytes(query));
    }
    mac.update((byte) '\n');
    if (body != null && body.length > 0 && !StringUtils.isNullOrEmpty(contentType)) {
        if (contentType.equals(Client.FormMime)
                || contentType.equals(Client.JsonMime)) {
            mac.update(body);
        }
    }

    String digest = UrlSafeBase64.encodeToString(mac.doFinal());

    return this.accessKey + ":" + digest;
}
 
开发者ID:lqxue,项目名称:QiNiuTest,代码行数:34,代码来源:Auth.java

示例5: isRoot

import java.net.URI; //导入方法依赖的package包/类
/**
 * Returns {@code true} if and only if the path component of this file
 *         system node name is empty and no query component is defined.
 * 
 * @return {@code true} if and only if the path component of this file
 *         system node name is empty and no query component is defined.
 */
public boolean isRoot() {
    //return getUri().toString().isEmpty();
    final URI uri = getUri();
    final String path = uri.getRawPath();
    if (null != path && !path.isEmpty())
        return false;
    final String query = uri.getRawQuery();
    return null == query;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:17,代码来源:FsNodeName.java

示例6: relativePath

import java.net.URI; //导入方法依赖的package包/类
public static String relativePath(String line) throws RuntimeException {
    String connects[] = line.split(" +");
    if (connects[1].toLowerCase().startsWith("http://")) {
        URI uri = Uri.create(connects[1]);
        String path = uri.getRawPath();
        String query = uri.getRawQuery();
        String frag = uri.getRawFragment();

        if (path == null) {
            path = "/";
        }

        if (query == null) {
            query = "";
        } else {
            query = "?" + query;
        }

        if (frag == null) {
            frag = "";
        } else {
            frag = "#" + frag;
        }
        return connects[0] + " " + path + query + frag + " " + connects[2];
    } else {
        return line;
    }
}
 
开发者ID:android-notes,项目名称:vase,代码行数:29,代码来源:HttpUtils.java

示例7: displayLink

import java.net.URI; //导入方法依赖的package包/类
private BaseComponent displayLink(URI uri) {
    String display = uri.getHost();

    // Don't append the path if it's just "/"
    // Use the raw path with illegal chars, which tends to look nicer.
    if(!"/".equals(uri.getRawPath())) {
        display = display + uri.getRawPath();
    }

    if(!compact) {
        display = uri.getScheme() + "://" + display;
    }
    return new Component(display);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:LinkComponent.java

示例8: doGET

import java.net.URI; //导入方法依赖的package包/类
public HttpResponse doGET(URI url) throws IOException, HttpException {
  String uri = url.getRawPath() + (url.getRawQuery() != null ? "?" + url.getRawQuery() : "");
  HttpRequest request = new BasicHttpRequest("GET", uri);
  String hostHeader = (url.getPort() == 0 || url.getPort() == 80)
      ? url.getHost() : (url.getHost() + ":" + url.getPort());
  request.addHeader("Host", hostHeader);
  return execute(request);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:9,代码来源:RequestExecutorBasedClientInstrumentationTest.java

示例9: digestURI

import java.net.URI; //导入方法依赖的package包/类
private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:URIBuilder.java

示例10: getRequestString

import java.net.URI; //导入方法依赖的package包/类
/**
 * Generate an HMAC request string.
 * <p>
 * This method trusts its inputs to be valid as per the MAC Authentication spec.
 *
 * @param request HTTP request.
 * @param timestamp to use.
 * @param nonce to use.
 * @param extra to use.
 * @return request string.
 */
protected static String getRequestString(HttpUriRequest request, long timestamp, String nonce, String extra) {
  String method = request.getMethod().toUpperCase();

  URI uri = request.getURI();
  String host = uri.getHost();

  String path = uri.getRawPath();
  if (uri.getRawQuery() != null) {
    path += "?";
    path += uri.getRawQuery();
  }
  if (uri.getRawFragment() != null) {
    path += "#";
    path += uri.getRawFragment();
  }

  int port = uri.getPort();
  String scheme = uri.getScheme();
  if (port != -1) {
  } else if ("http".equalsIgnoreCase(scheme)) {
    port = 80;
  } else if ("https".equalsIgnoreCase(scheme)) {
    port = 443;
  } else {
    throw new IllegalArgumentException("Unsupported URI scheme: " + scheme + ".");
  }

  String requestString = timestamp + "\n" +
      nonce       + "\n" +
      method      + "\n" +
      path        + "\n" +
      host        + "\n" +
      port        + "\n" +
      extra       + "\n";

  return requestString;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:49,代码来源:HMACAuthHeaderProvider.java

示例11: fromUri

import java.net.URI; //导入方法依赖的package包/类
/**
 * Converts URI to Path
 */
static Path fromUri(NetFileSystem fs, URI uri) {
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("URI has an authority component");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");

    // compatibility with java.io.File
    if (!uri.toString().startsWith("file:///"))
        return new File(uri).toPath();

    // transformation use raw path
    String p = uri.getRawPath();
    int len = p.length();
    if (len == 0)
        throw new IllegalArgumentException("URI path component is empty");

    // transform escaped octets and unescaped characters to bytes
    if (p.endsWith("/") && len > 1)
        p = p.substring(0, len - 1);

    return new NetPath(fs, p);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:UnixUriUtils.java

示例12: constructRelativeClasspathUri

import java.net.URI; //导入方法依赖的package包/类
private static String constructRelativeClasspathUri(File jarFile, File file) {
    URI jarFileUri = jarFile.getParentFile().toURI();
    URI fileUri = file.toURI();
    URI relativeUri = jarFileUri.relativize(fileUri);
    return relativeUri.getRawPath();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:7,代码来源:ManifestUtil.java

示例13: findUriPath

import java.net.URI; //导入方法依赖的package包/类
protected String findUriPath(URI uri) {
  return uri.getRawPath();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:4,代码来源:CseClientHttpRequest.java

示例14: findUriPath

import java.net.URI; //导入方法依赖的package包/类
@Override
protected String findUriPath(URI uri) {
  return "/" + uri.getAuthority() + uri.getRawPath();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:5,代码来源:UrlWithServiceNameClientHttpRequestFactory.java

示例15: HgURL

import java.net.URI; //导入方法依赖的package包/类
/**
 *
 * @param urlString
 * @param username
 * @param password value is cloned, if you want to null the field, call {@link #clearPassword()}
 * @throws URISyntaxException
 */
public HgURL(String urlString, String username, char[] password) throws URISyntaxException {
    URI originalUri;

    if (urlString == null) {
        throw new IllegalArgumentException("<null> URL string");    //NOI18N
    }

    if (urlString.length() == 0) {
        throw new IllegalArgumentException("empty URL string");     //NOI18N
    }

    if (looksLikePlainFilePath(urlString)) {
        originalUri = new File(urlString).toURI();
        scheme = Scheme.FILE;
    } else {
        originalUri = new URI(urlString).parseServerAuthority();
        String originalScheme = originalUri.getScheme();
        scheme = (originalScheme != null) ? determineScheme(originalScheme)
                                          : null;
    }

    if (scheme == null) {
        throw new URISyntaxException(
                urlString,
                NbBundle.getMessage(HgURL.class,
                                    "MSG_UNSUPPORTED_PROTOCOL",     //NOI18N
                                    originalUri.getScheme()));
    }

    verifyUserInfoData(scheme, username, password);

    if (username != null) {
        this.username = username;
        this.password = password == null ? null : (char[])password.clone();
    } else {
        String rawUserInfo = originalUri.getRawUserInfo();
        if (rawUserInfo == null) {
            this.username = null;
            this.password = null;
        } else {
            int colonIndex = rawUserInfo.indexOf(':');
            if (colonIndex == -1) {
                this.username = rawUserInfo;
                this.password = null;
            } else {
                this.username = rawUserInfo.substring(0, colonIndex);
                this.password = rawUserInfo.substring(colonIndex + 1).toCharArray();
            }
        }
    }

    host = originalUri.getHost();
    port = originalUri.getPort();
    rawPath     = originalUri.getRawPath();
    rawQuery    = originalUri.getRawQuery();
    rawFragment = originalUri.getRawFragment();

    path = originalUri.getPath();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:HgURL.java


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