本文整理汇总了Java中org.glassfish.jersey.uri.UriComponent.encode方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponent.encode方法的具体用法?Java UriComponent.encode怎么用?Java UriComponent.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.jersey.uri.UriComponent
的用法示例。
在下文中一共展示了UriComponent.encode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWebTarget
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
private static WebTarget createWebTarget(String uri, Map<String, String> queryParams) throws URISyntaxException
{
WebTarget webTarget = null;
URI u = new URI(uri);
Client client = ClientBuilder.newClient();
webTarget = client.target(u);
if (MapUtils.isNotEmpty(queryParams))
{
for (Entry<String, String> entry : queryParams.entrySet())
{
if (StringUtils.isNotBlank(entry.getKey()) && StringUtils.isNotBlank(entry.getValue()))
{
String value = UriComponent.encode(
entry.getValue(),
UriComponent.Type.QUERY_PARAM_SPACE_ENCODED);
webTarget = webTarget.queryParam(entry.getKey(), value);
}
}
}
return webTarget;
}
示例2: testIdentifierPrefix
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
@Test
public void testIdentifierPrefix() throws Exception {
String url = "http://arXiv.org/oai2";
String metadataPrefix = "marc21";
String identifierPrefix = "oai:arXiv.org:quant-ph/";
OaiCatalog c = new OaiCatalog(url, metadataPrefix, identifierPrefix);
WebTarget wr = c.buildOaiQuery(OaiCatalog.FIELD_ID, "4");
String resultQuery = wr.getUri().toString();
String encIdParam = "identifier=" + UriComponent.encode(
"oai:arXiv.org:quant-ph/4",
UriComponent.Type.QUERY_PARAM_SPACE_ENCODED);
assertTrue(resultQuery, resultQuery.contains(encIdParam));
// do not prefix ID with prefix
wr = c.buildOaiQuery(OaiCatalog.FIELD_ID, "oai:arXiv.org:quant-ph/4");
resultQuery = wr.getUri().toString();
assertTrue(resultQuery, resultQuery.contains(encIdParam));
// no prefix
c.setIdentifierPrefix(null);
wr = c.buildOaiQuery(OaiCatalog.FIELD_ID, "4");
resultQuery = wr.getUri().toString();
assertTrue(resultQuery, resultQuery.contains("identifier=4"));
}
示例3: getByEmail
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
@Override
public Optional<User> getByEmail(String userEmail) {
String userEmailEncoded = UriComponent.encode(userEmail, QUERY_PARAM_SPACE_ENCODED);
Invocation.Builder builder = client
.target(USERS_URL)
.queryParam("filter[email]", userEmailEncoded)
.request(APPLICATION_JSON_TYPE);
return getPageable(builder, UserList.class)
.filter(user -> user.getEmail().equals(userEmail))
.getSingle();
}
示例4: getByName
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
@Override
public Optional<Server> getByName(String serverName) {
String serverNameEncoded = UriComponent.encode(serverName, QUERY_PARAM_SPACE_ENCODED);
Invocation.Builder builder = client
.target(SERVERS_URL)
.queryParam("filter[name]", serverNameEncoded)
.request(APPLICATION_JSON_TYPE);
return getPageable(builder, ServerList.class)
.filter(application -> application.getName().equals(serverName))
.getSingle();
}
示例5: getByName
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
@Override
public Optional<KeyTransaction> getByName(String keyTransactionName) {
String keyTransactionNameEncoded = UriComponent.encode(keyTransactionName, QUERY_PARAM_SPACE_ENCODED);
return client
.target(KEY_TRANSACTIONS_URL)
.queryParam("filter[name]", keyTransactionNameEncoded)
.request(APPLICATION_JSON_TYPE)
.get(KeyTransactionList.class)
.getSingle();
}
示例6: qpEncode
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
/**
* Encodes query parameter as Jersey 2 uses query templates by default.
*/
private static String qpEncode(String p) {
return p == null || p.isEmpty()
? p
: UriComponent.encode(p, UriComponent.Type.QUERY_PARAM_SPACE_ENCODED);
}
示例7: encode
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
private String encode(final String input) {
// do not interpret template parameters
return UriComponent.encode(input, UriComponent.Type.QUERY_PARAM, false);
}
示例8: encodeQueryParam
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
private static String encodeQueryParam(final String value) {
return UriComponent.encode(value, UriComponent.Type.QUERY_PARAM, false);
}
示例9: getEscapedUri
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
/**
* Return the string representation of a URI when it is to be used when generating the URL for a request.
* @param uriToEscape - the URI that is to be escaped
* @return - the URI supplied encoded so that it can be used as part of a URL
*/
protected String getEscapedUri(String uriToEscape) {
return UriComponent.encode(uriToEscape, UriComponent.Type.PATH_SEGMENT);
}
示例10: encodeQueryParam
import org.glassfish.jersey.uri.UriComponent; //导入方法依赖的package包/类
/**
* Encodes query parameter according to RFC
* @param path path which URI will be encoded as query parameter
* @return encoded URI part
*/
private String encodeQueryParam(Path path) {
return UriComponent.encode(path.toUri().toString(), Type.QUERY_PARAM_SPACE_ENCODED);
}