javax.ws.rs.core.UriBuilder#matrixParam()源码实例Demo

下面列出了javax.ws.rs.core.UriBuilder#matrixParam() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cloud-odata-java   文件: RestUtil.java
private static URI buildBaseUri(final HttpServletRequest request, final javax.ws.rs.core.UriInfo uriInfo, final List<PathSegment> precedingPathSegments) throws ODataException {
  try {
    UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
    for (final PathSegment ps : precedingPathSegments) {
      uriBuilder = uriBuilder.path(ps.getPath());
      for (final String key : ps.getMatrixParameters().keySet()) {
        final Object[] v = ps.getMatrixParameters().get(key).toArray();
        uriBuilder = uriBuilder.matrixParam(key, v);
      }
    }

    /*
     * workaround because of host name is cached by uriInfo
     */
    uriBuilder.host(request.getServerName());

    String uriString = uriBuilder.build().toString();
    if (!uriString.endsWith("/")) {
      uriString = uriString + "/";
    }

    return new URI(uriString);
  } catch (final URISyntaxException e) {
    throw new ODataException(e);
  }
}
 
源代码2 项目: olingo-odata2   文件: RestUtil.java
private static URI buildBaseUri(final UriInfo uriInfo, final HttpServletRequest request,
    final List<PathSegment> precedingPathSegments) throws ODataException {
  try {
    String path = uriInfo.getBaseUri().getPath();
    UriBuilder uriBuilder = UriBuilder.fromUri(path);
    for (final PathSegment ps : precedingPathSegments) {
      uriBuilder = uriBuilder.path(ps.getPath());
      for (final String key : ps.getMatrixParameters().keySet()) {
        final Object[] v = ps.getMatrixParameters().get(key).toArray();
        uriBuilder = uriBuilder.matrixParam(key, v);
      }
    }

    /*
     * workaround because of host name is cached by uriInfo
     */
    uriBuilder.host(request.getServerName()).port(request.getServerPort());
    uriBuilder.scheme(request.getScheme());

    String uriString = uriBuilder.build().toString();
    if (!uriString.endsWith("/")) {
      uriString = uriString + "/";
    }

    return new URI(uriString);
  } catch (final URISyntaxException e) {
    throw new ODataException(e);
  }
}
 
源代码3 项目: cxf   文件: AbstractClient.java
private void addMatrixOrQueryToBuilder(UriBuilder ub,
                                       String paramName,
                                       ParameterType pt,
                                       Object... pValue) {
    if (pt == ParameterType.MATRIX) {
        ub.matrixParam(paramName, pValue);
    } else {
        ub.queryParam(paramName, pValue);
    }
}
 
源代码4 项目: cxf   文件: ClientImpl.java
@Override
public WebTarget matrixParam(String name, Object... values) {
    checkClosed();
    checkNullValues(name, values);

    UriBuilder thebuilder = getUriBuilder();
    if (values == null || values.length == 1 && values[0] == null) {
        thebuilder.replaceMatrixParam(name, (Object[])null);
    } else {
        thebuilder.matrixParam(name, values);
    }
    return newWebTarget(thebuilder);
}