當前位置: 首頁>>代碼示例>>Java>>正文


Java URI.getQuery方法代碼示例

本文整理匯總了Java中java.net.URI.getQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java URI.getQuery方法的具體用法?Java URI.getQuery怎麽用?Java URI.getQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.URI的用法示例。


在下文中一共展示了URI.getQuery方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ServletURI

import java.net.URI; //導入方法依賴的package包/類
public ServletURI(String rawPath) throws URISyntaxException {
    if (rawPath == null || rawPath.isEmpty() || "/".equals(rawPath)) {
        path = "/";
    } else {
        URI uri = new URI(rawPath);
        path = uri.getPath();
        if (path == null || path.isEmpty()) {
            path = "/";
        } else if (path.charAt(0) != '/') {
            path += "/" + path;
        }

        fragement = uri.getFragment();
        query = uri.getQuery();
    }
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:17,代碼來源:ServletURI.java

示例2: streamdataUri

import java.net.URI; //導入方法依賴的package包/類
private static URI streamdataUri(String aApiUrl, String aToken, Map<String, String> aHeaders) throws URISyntaxException {
    Objects.requireNonNull(aApiUrl);
    Objects.requireNonNull(aToken);
    Objects.requireNonNull(aHeaders);

    URI uri = new URI(aApiUrl);
    String queryParamSeparator =
        (uri.getQuery() == null || uri.getQuery().isEmpty() ) ? "?" : "&" ;

    return new URI("https://streamdata.motwin.net/"
                       + aApiUrl
                       + queryParamSeparator
                       + "X-Sd-Token="
                       + aToken
                       + apiHeaders(aHeaders).map(h -> "&" + h).orElse("")
    );
}
 
開發者ID:streamdataio,項目名稱:streamdataio-spring-webflux,代碼行數:18,代碼來源:StreamdataioSpringWebfluxApplication.java

示例3: getPathAndQuery

import java.net.URI; //導入方法依賴的package包/類
private String getPathAndQuery(URI uri) {
    String path = uri.getPath();
    String query = uri.getQuery();
    if (path == null || path.equals("")) {
        path = "/";
    }
    if (query == null) {
        query = "";
    }
    if (query.equals("")) {
        return path;
    } else {
        return path + "?" + query;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Http1Request.java

示例4: intercept

import java.net.URI; //導入方法依賴的package包/類
@Override
public Response intercept(Chain chain) throws IOException {
    Response response = null;


    Log.d(TAG, "----                FAKE SERVER RESPONSES                ----");
    String responseString;
    // Get Request URI.
    final URI uri = chain.request().url().uri();
    // Get Query String.
    final String query = uri.getQuery();
    // Parse the Query String.
    final String[] parsedQuery = query.split("=");
    if (parsedQuery[0].equalsIgnoreCase("repoTitle") && parsedQuery[1].equalsIgnoreCase("GCI")) {
        responseString = TEACHER_ID_1;
    } else if (parsedQuery[0].equalsIgnoreCase("repoTitle") && parsedQuery[1].equalsIgnoreCase("rest-android")) {
        responseString = TEACHER_ID_2;
    } else {
        responseString = "";
    }

    response = new Response.Builder()
            .code(200)
            .message(responseString)
            .request(chain.request())
            .protocol(Protocol.HTTP_1_0)
            .body(ResponseBody.create(MediaType.parse("application/json"), responseString.getBytes()))
            .addHeader("content-type", "application/json")
            .build();



    return response;
}
 
開發者ID:jboss-outreach,項目名稱:rest-android,代碼行數:35,代碼來源:FakeInterceptor.java

示例5: removePort

import java.net.URI; //導入方法依賴的package包/類
private URI removePort(URI uri) throws StatusException {
    try {
        return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), -1 /* port */,
                uri.getPath(), uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw Status.UNAUTHENTICATED
                .withDescription("Unable to construct service URI after removing port")
                .withCause(e).asException();
    }
}
 
開發者ID:hsavaliya,項目名稱:GoogleAssistantSDK,代碼行數:11,代碼來源:SpeechService.java

示例6: fromServer

import java.net.URI; //導入方法依賴的package包/類
/**
 * Convert given server URL into project's file.
 * @param projectContext see {@link #CONTEXT_PROJECT_SOURCES} and {@link #CONTEXT_PROJECT_TESTS};
 *   it is very unlikely that server URL could be translated into two different sources
 *   but for API parity with toServer the context param is available here as well
 * @return returns null if nothing is known about this server URL
 */
public static FileObject fromServer(Project p, int projectContext, URL serverURL) {
    Parameters.notNull("project", p); //NOI18N
    Parameters.notNull("serverURL", serverURL); //NOI18N
    ServerURLMappingImplementation impl = p.getLookup().lookup(ServerURLMappingImplementation.class);
    if (impl != null) {
        FileObject fo = impl.fromServer(projectContext, serverURL);
        if (fo != null) {
            return fo;
        }
    }
    if ("file".equals(serverURL.getProtocol())) { //NOI18N
        try {
            URI serverURI = serverURL.toURI();
            if (serverURI.getQuery() != null || serverURI.getFragment() != null) {
                // #236532 - strip down query part from the URL:
                serverURI = WebUtils.stringToUrl(WebUtils.urlToString(serverURL, true)).toURI();
            }
            File f = FileUtil.normalizeFile(BaseUtilities.toFile(serverURI));
            return FileUtil.toFileObject(f);
            //FileObject fo = URLMapper.findFileObject(serverURL);
        } catch (URISyntaxException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:ServerURLMapping.java

示例7: request

import java.net.URI; //導入方法依賴的package包/類
/**
 * The request to send.
 * @param req Original request
 * @param uri Destination URI
 * @return Request
 */
private static Request request(final Request req, final URI uri) {
    final StringBuilder path = new StringBuilder(0);
    path.append(uri.getRawPath());
    if (path.length() == 0) {
        path.append('/');
    }
    if (uri.getQuery() != null) {
        path.append('?').append(uri.getRawQuery());
    }
    if (uri.getFragment() != null) {
        path.append('#').append(uri.getRawFragment());
    }
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return new Concat<>(
                Collections.singleton(
                    String.format(
                        "%s %s HTTP/1.1",
                        new RqMethod.Base(req).method(),
                        path
                    )
                ),
                new Skipped<>(req.head(), 1)
            );
        }
        @Override
        public InputStream body() throws IOException {
            return req.body();
        }
    };
}
 
開發者ID:yegor256,項目名稱:rehttp,代碼行數:39,代碼來源:DyTake.java

示例8: logoutURI

import java.net.URI; //導入方法依賴的package包/類
@Override
public URI logoutURI(UserState state, URI loggedOutURI)
{
	QueryBuilder loggedOutQB = QueryBuilder.create();
	String loggedOutQuery = loggedOutURI.getQuery();
	if( loggedOutQuery != null )
	{
		loggedOutQB.parse(loggedOutQuery);
	}
	loggedOutQB.addParam(PARAM_NO_AUTO_LOGIN, "true");
	UriBuilder builder = UriBuilder.create(loggedOutURI);
	builder.setQuery(loggedOutQB);
	return builder.build();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:CanvasLogonFilter.java

示例9: checkUri

import java.net.URI; //導入方法依賴的package包/類
private void checkUri(URI uri) {
    if (!uri.getScheme().equalsIgnoreCase(getScheme()))
        throw new IllegalArgumentException("URI does not match this provider");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("Authority component present");
    if (uri.getPath() == null)
        throw new IllegalArgumentException("Path component is undefined");
    if (!uri.getPath().equals("/"))
        throw new IllegalArgumentException("Path component should be '/'");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("Query component present");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("Fragment component present");
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:WindowsFileSystemProvider.java

示例10: getUrl

import java.net.URI; //導入方法依賴的package包/類
public String getUrl() {
    try {
        URI o = new URI(this.url);
        URI injected = new URI("http", null, o.getHost(), reverseProxy.getPortForUrl(this.url),
                o.getPath(), o.getQuery(), o.getFragment());
        return injected.toString();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:Kroger-Technology,項目名稱:Snow-Globe,代碼行數:11,代碼來源:TestRequest.java

示例11: getHealthCheckUrl

import java.net.URI; //導入方法依賴的package包/類
public String getHealthCheckUrl() {
    if (null != this.healthCheckUrl) {
        try {
            URI o = new URI(this.url + this.healthCheckUrl);
            URI injected = new URI("http", null, o.getHost(), reverseProxy.getPortForUrl(this.url),
                    o.getPath(), o.getQuery(), o.getFragment());
            return injected.toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return this.healthCheckUrl;
}
 
開發者ID:Kroger-Technology,項目名稱:Snow-Globe,代碼行數:14,代碼來源:TestRequest.java

示例12: replacePath

import java.net.URI; //導入方法依賴的package包/類
public static URI replacePath(URI uri, String path) {
    try {
        return new URI(uri.getScheme(), uri.getAuthority(), path, uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Invalid URI/Scheme: replacing path with '"+path+"' for "+uri);
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:8,代碼來源:URIUtils.java

示例13: getEncodeRequestSize

import java.net.URI; //導入方法依賴的package包/類
private int getEncodeRequestSize(URI requestURI, String[] names, String[] values) {
    int size = 0;

    // Encode Request line
    size += GET_BYTES.length;
    size += SPACE_BYTES.length;
    String path = requestURI.getPath();
    if (requestURI.getQuery() != null) {
        path += "?" + requestURI.getQuery();
    }
    size += path.getBytes().length;
    size += SPACE_BYTES.length;
    size += HTTP_1_1_BYTES.length;
    size += CRLF_BYTES.length;

    // Encode headers
    for (int i = 0; i < names.length; i++) {
        String headerName = names[i];
        String headerValue = values[i];
        if (headerName != null && headerValue != null) {
            size += headerName.getBytes().length;
            size += COLON_BYTES.length;
            size += SPACE_BYTES.length;
            size += headerValue.getBytes().length;
            size += CRLF_BYTES.length;
        }
    }

    size += CRLF_BYTES.length;

    LOG.fine("Returning a request size of " + size);
    return size;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:34,代碼來源:WebSocketDelegateImpl.java

示例14: absoluteTo

import java.net.URI; //導入方法依賴的package包/類
public static URI absoluteTo(final HttpServletRequest httpRequest, final URI url) {
    final URI current = currentUri(httpRequest);

    try {
        return new URI(current.getScheme(), null, current.getHost(), current.getPort(), url.getPath(),
            url.getQuery(), url.getFragment());
    } catch (final URISyntaxException e) {
        throw new IllegalArgumentException(
            "Unable to generate URI based on the current (`" + current + "`) and the return (`" + url + "`) URLs",
            e);
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:13,代碼來源:Urls.java

示例15: urlFromSocket

import java.net.URI; //導入方法依賴的package包/類
private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception {
    int listenPort = serverSocket.getLocalPort();

    return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(),
            uri.getFragment());
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:7,代碼來源:SocketProxy.java


注:本文中的java.net.URI.getQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。