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


Java UriComponent.encode方法代码示例

本文整理汇总了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;
}
 
开发者ID:okean,项目名称:alm-rest-api,代码行数:27,代码来源:RestConnector.java

示例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"));
}
 
开发者ID:proarc,项目名称:proarc,代码行数:25,代码来源:OaiCatalogTest.java

示例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();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:12,代码来源:DefaultUsersApi.java

示例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();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:12,代码来源:DefaultServersApi.java

示例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();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:11,代码来源:DefaultKeyTransactionsApi.java

示例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);
}
 
开发者ID:proarc,项目名称:proarc,代码行数:9,代码来源:RemoteStorage.java

示例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);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:5,代码来源:WhoisRestServiceTestIntegration.java

示例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);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:4,代码来源:PasswordFilterTest.java

示例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);
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:9,代码来源:OEClientReadOnly.java

示例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);
}
 
开发者ID:hrnr,项目名称:MatroskaBatch,代码行数:9,代码来源:RemoteUtils.java


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