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


Java UriComponent类代码示例

本文整理汇总了Java中org.glassfish.jersey.uri.UriComponent的典型用法代码示例。如果您正苦于以下问题:Java UriComponent类的具体用法?Java UriComponent怎么用?Java UriComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UriComponent类属于org.glassfish.jersey.uri包,在下文中一共展示了UriComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: makeSlug

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
/** Apply slug conventions. In practice, this means
 * (a) replacing punctuation with hyphens,
 * (b) replacing whitespace with hyphen,
 * (c) converting to lowercase,
 * (d) encoding as a URL,
 * (e) replacing percents with hyphens,
 * (f) coalescing multiple consecutive hyphens into one,
 * (g) removing any leading and trailing hyphens,
 * (h) trimming the result to a maximum length of
 *     MAX_SLUG_COMPONENT_LENGTH,
 * (i) removing any remaining trailing hyphen.
 * @param aString The string that is to be converted.
 * @return The value of aString with slug conventions applied.
 */
public static String makeSlug(final String aString) {
    String slug = StringUtils.strip(
            UriComponent.encode(aString.
            replaceAll("\\p{Punct}", "-").
            replaceAll("\\s", "-").
            toLowerCase(),
            UriComponent.Type.PATH_SEGMENT).
            replaceAll("%", "-").
            replaceAll("-+", "-"),
            "-");

    return StringUtils.stripEnd(
            slug.substring(0, Math.min(MAX_SLUG_COMPONENT_LENGTH,
            slug.length())),
            "-");
}
 
开发者ID:au-research,项目名称:ANDS-Vocabs-Toolkit,代码行数:31,代码来源:ToolkitFileUtils.java

示例4: query

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
/**
 * Query prometheus and return the result
 *
 * @param expression
 * @return
 * @throws PrometheusException
 */
public PrometheusResponse query(String expression) throws PrometheusException
{
    WebTarget queryTarget = target.queryParam(
        "expr",
        UriComponent.encode(expression, UriComponent.Type.QUERY_PARAM_SPACE_ENCODED)
    );
    logger.debug(expression);
    String json = queryTarget.request().get(String.class);

    PrometheusResponse response = gson.fromJson(json, PrometheusResponse.class);
    if (response instanceof PrometheusError) {
        throw new PrometheusQueryException(expression, ((PrometheusError) response).getError());
    }

    return response;
}
 
开发者ID:Marmelatze,项目名称:docker-controller,代码行数:24,代码来源:PrometheusClient.java

示例5: getBatchToken

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
public String getBatchToken() {
    Link link = this.response.getLink("'next'");

    if (link != null) {
        MultivaluedMap<String, String> parameters = UriComponent.decodeQuery(link.getUri(), true);
        return parameters.getFirst("batch_token");
    }

    return null;
}
 
开发者ID:square,项目名称:connect-java-sdk,代码行数:11,代码来源:CompleteResponse.java

示例6: 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

示例7: 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

示例8: 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

示例9: _createContext

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
@Nonnull
private static WebappContext _createContext (final URI u,
                                             final Class <? extends Servlet> aServletClass,
                                             final Servlet aServlet,
                                             final Map <String, String> aInitParams,
                                             final Map <String, String> aContextInitParams)
{
  String path = u.getPath ();
  if (path == null)
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be non-null");
  if (path.isEmpty ())
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be present");
  if (path.charAt (0) != '/')
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ". must start with a '/'");
  path = String.format ("/%s", UriComponent.decodePath (u.getPath (), true).get (1).toString ());

  final WebappContext aContext = new WebappContext ("GrizzlyContext", path);
  ServletRegistration registration;
  if (aServletClass != null)
    registration = aContext.addServlet (aServletClass.getName (), aServletClass);
  else
    registration = aContext.addServlet (aServlet.getClass ().getName (), aServlet);
  registration.addMapping ("/*");

  if (aContextInitParams != null)
    for (final Map.Entry <String, String> e : aContextInitParams.entrySet ())
      aContext.setInitParameter (e.getKey (), e.getValue ());

  if (aInitParams != null)
    registration.setInitParameters (aInitParams);

  return aContext;
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:34,代码来源:MockServer.java

示例10: 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

示例11: make

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
public Command make(Operation operation, String target,  String parameters) {
    return make(operation, target, UriComponent.decodeQuery(parameters, true));
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:4,代码来源:Registry.java

示例12: makeParams

import org.glassfish.jersey.uri.UriComponent; //导入依赖的package包/类
private MultivaluedMap<String, String> makeParams(String params) {
    return UriComponent.decodeQuery(params, true);
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:4,代码来源:TestRequestLogging.java

示例13: 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

示例14: 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

示例15: 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


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