本文整理汇总了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();
}
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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();
}
};
}
示例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();
}
示例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");
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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());
}