當前位置: 首頁>>代碼示例>>Java>>正文


Java MultivaluedMap.entrySet方法代碼示例

本文整理匯總了Java中javax.ws.rs.core.MultivaluedMap.entrySet方法的典型用法代碼示例。如果您正苦於以下問題:Java MultivaluedMap.entrySet方法的具體用法?Java MultivaluedMap.entrySet怎麽用?Java MultivaluedMap.entrySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.core.MultivaluedMap的用法示例。


在下文中一共展示了MultivaluedMap.entrySet方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: urlEncodeMultivaluedParams

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/**
 * Encodes a collection of key-value pairs as a URL encoded string.
 *
 * @param params The parameters.
 * @return The URL encoded string.
 */
public static String urlEncodeMultivaluedParams(final MultivaluedMap<String, String> params) {
    if (params == null || params.isEmpty()) {
        return "";
    }

    final StringBuilder b = new StringBuilder();

    for (final Entry<String, List<String>> entry : params.entrySet()) {
        for (final String value : entry.getValue()) {
            if (b.length() > 0) {
                b.append("&");
            }

            b.append(urlEncode(entry.getKey()));
            b.append("=");
            b.append(urlEncode(value));
        }
    }

    return b.toString();
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:28,代碼來源:UrlUtils.java

示例2: serializeMultipartForm

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
public static InputStream serializeMultipartForm(final Form form) {
    final String boundary = "------Boundary" + UUID.randomUUID().toString();

    final StringBuilder b = new StringBuilder();

    final MultivaluedMap<String, String> map = form.asMap();

    for (final Entry<String, List<String>> entry : map.entrySet()) {
        for (final String value : entry.getValue()) {
            b.append(boundary);
            b.append("\nContent-Disposition: form-data; name=\"");
            b.append(entry.getKey());
            b.append("\"\n\n");
            b.append(value);
            b.append("\n");
        }
    }

    b.append(boundary);
    return new ByteArrayInputStream(b.toString().getBytes(StandardCharsets.UTF_8));
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:22,代碼來源:MultipartUtils.java

示例3: logHttpHeaders

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
protected void logHttpHeaders(MultivaluedMap<String, String> headers) {
    StringBuilder msg = new StringBuilder("The HTTP headers are: \n");
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        msg.append(entry.getKey()).append(": ");
        for (int i = 0; i < entry.getValue().size(); i++) {
            msg.append(entry.getValue().get(i));
            if (i < entry.getValue().size() - 1) {
                msg.append(", ");
            }
        }
        msg.append("\n");
    }
    logger.info(msg.toString());
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:15,代碼來源:LoggingFilter.java

示例4: equalsRequestHeader

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
private boolean equalsRequestHeader(ContainerRequestContext containerRequestContext) {

        MultivaluedMap<String, String> requestHeader = containerRequestContext.getHeaders();
        MultivaluedMap<String, Object> desiredHeader = endpoint.getHeader().getContent();

        if (!StringUtils.isEmpty(desiredHeader)) {

            if (!requestHeader.isEmpty()) {

                for (Map.Entry<String, List<Object>> map : desiredHeader.entrySet()) {
                    if (!requestHeader.containsKey(map.getKey()) || !requestHeader.get(map.getKey()).containsAll(map.getValue()))
                        return false;
                }

            } else
                return false;
        }

        return true;
    }
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:21,代碼來源:APIxInflector.java

示例5: getFilterAttributes

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
public Map<String, String> getFilterAttributes() {

        if (uriInfo != null) {
            MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();

            for (Map.Entry<String, List<String>> queryParam : queryParams.entrySet()) {
                String queryParamAttribute = queryParam.getKey();
                if (StringUtils.isBlank(queryParamAttribute) || !queryParamAttribute.startsWith("filter-")) {
                    continue;
                }
                queryParamAttribute = queryParamAttribute.substring("filter-".length(), queryParamAttribute.length());
                String filterVal = StringUtils.trimToNull(queryParam.getValue().get(0));
                if (filterVal != null) {
                    filterAttributes.put(queryParamAttribute, filterVal);
                }
            }
        }
        return filterAttributes;
    }
 
開發者ID:coodoo-io,項目名稱:coodoo-listing,代碼行數:20,代碼來源:ListingParameters.java

示例6: mapResponse

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Override
public Response mapResponse(StatusType status, Object response) {
  javax.ws.rs.core.Response jaxrsResponse = (javax.ws.rs.core.Response) response;

  Response cseResponse = Response.status(jaxrsResponse.getStatusInfo()).entity(jaxrsResponse.getEntity());
  MultivaluedMap<String, Object> headers = jaxrsResponse.getHeaders();
  for (Entry<String, List<Object>> entry : headers.entrySet()) {
    if (entry.getValue() == null || entry.getValue().isEmpty()) {
      continue;
    }

    cseResponse.getHeaders().addHeader(entry.getKey(), entry.getValue());
  }
  return cseResponse;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:16,代碼來源:JaxrsProducerResponseMapper.java

示例7: executeQuery

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@GET
@javax.ws.rs.Path("/commands/{commandName}/query")
@Consumes(MediaType.MEDIA_TYPE_WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
public Response executeQuery(@Context UriInfo uriInfo,
                             @PathParam("commandName") String commandName,
                             @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    String stepIndex = null;
    MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters();
    List<String> stepValues = parameters.get("stepIndex");
    if (stepValues != null && !stepValues.isEmpty()) {
        stepIndex = stepValues.get(0);
    }
    if (stepIndex == null) {
        stepIndex = "0";
    }
    final JsonBuilder jsonBuilder = new JsonBuilder().createJson(Integer.valueOf(stepIndex));
    for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
        String key = entry.getKey();
        if (!"stepIndex".equals(key)) {
            jsonBuilder.addInput(key, entry.getValue());
        }
    }

    final Response response = executeCommandJson(jsonBuilder.build(), commandName, headers);
    if (response.getEntity() instanceof JsonObject) {
        JsonObject responseEntity = (JsonObject) response.getEntity();
        String error = ((JsonObject) responseEntity.getJsonArray("messages").get(0)).getString("description");
        return Response.status(Status.PRECONDITION_FAILED).entity(unwrapJsonObjects(error)).build();
    }
    return response;
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:35,代碼來源:LaunchResource.java

示例8: commitHeaders

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
protected void commitHeaders(ClientInvocation request, HttpRequestBase httpMethod) {
  MultivaluedMap<String, String> headers = request.getHeaders().asMap();
  for (Map.Entry<String, List<String>> header : headers.entrySet()) {
    List<String> values = header.getValue();
    for (String value : values) {
      //               System.out.println(String.format("setting %s = %s", header.getKey(), value));
      httpMethod.addHeader(header.getKey(), value);
    }
  }
}
 
開發者ID:cerner,項目名稱:beadledom,代碼行數:11,代碼來源:ApacheHttpClient4Dot3Engine.java

示例9: getHeaders

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/**
 * Get all response headers.
 *
 * @return the response headers
 */
@PublicAtsApi
public RestHeader[] getHeaders() {

    List<RestHeader> headers = new ArrayList<RestHeader>();

    MultivaluedMap<String, Object> respHeaders = response.getHeaders();
    for (Entry<String, List<Object>> respHeaderEntry : respHeaders.entrySet()) {
        headers.add(RestHeader.constructRESTHeader(respHeaderEntry.getKey(), respHeaderEntry.getValue()));
    }

    return headers.toArray(new RestHeader[headers.size()]);
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:18,代碼來源:RestResponse.java

示例10: filter

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Override
public void filter( ClientRequestContext context ) throws IOException {

    if (debugLevel == RESTDebugLevel.NONE || debugLevel == RESTDebugLevel.TARGET_URI) {
        return;
    }

    MultivaluedMap<String, Object> reqHeaders = context.getHeaders();
    StringBuilder requestMessage = new StringBuilder();
    requestMessage.append("Sending the following request: \n");
    if ( (debugLevel & RESTDebugLevel.HEADERS) == RESTDebugLevel.HEADERS) {
        requestMessage.append(context.getMethod() + " " + context.getUri() + " \n");

        for (Entry<String, List<Object>> reqHeaderEntry : reqHeaders.entrySet()) {
            requestMessage.append(reqHeaderEntry.getKey() + ": "
                                  + Arrays.toString(reqHeaderEntry.getValue().toArray()) + " \n");
        }
    }
    if ( (debugLevel & RESTDebugLevel.BODY) == RESTDebugLevel.BODY && context.hasEntity()) {
        //log request body
        Object entity = context.getEntity();
        if (entity instanceof Form) {
            requestMessage.append("Body: " + ((Form) entity).asMap());
        } else {
            requestMessage.append("Body: " + entity.toString());
        }
    }
    log.info(requestMessage);
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:30,代碼來源:RestClient.java

示例11: getParameters

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
private Map<String, Set<String>> getParameters(UriInfo uriInfo) {
	MultivaluedMap<String, String> queryParametersMultiMap = uriInfo.getQueryParameters();
	Map<String, Set<String>> queryParameters = new HashMap<>();

	for (Map.Entry<String, List<String>> queryEntry : queryParametersMultiMap.entrySet()) {
		queryParameters.put(queryEntry.getKey(), new LinkedHashSet<>(queryEntry.getValue()));
	}
	return queryParameters;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:10,代碼來源:JaxrsRequestContext.java

示例12: setMultivaluedMapParams

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
private static void setMultivaluedMapParams(MultivaluedMap<String,String> params, Run run, String... excluded) throws IOException {
	Collection<String> ex = new HashSet<String>(Arrays.asList(excluded));
	for (Map.Entry<String,List<String>> e : params.entrySet()) {
		String name = e.getKey();
		if (ex.contains(name)) {
			continue;
		}
		List<String> values = e.getValue();
		if (values.isEmpty()) {
			continue;
		}
		String value = values.get(values.size() - 1);
		setParam(run, name, value);
	}
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:16,代碼來源:RunLauncher.java

示例13: rebuildQuery

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/** Rebuild the URI query with lower case parameter names. */
private static URI rebuildQuery(final URI uri,
    final MultivaluedMap<String, String> parameters) {
  UriBuilder b = UriBuilder.fromUri(uri).replaceQuery("");
  for(Map.Entry<String, List<String>> e : parameters.entrySet()) {
    final String key = StringUtils.toLowerCase(e.getKey());
    for(String v : e.getValue()) {
      b = b.queryParam(key, v);
    }
  }
  return b.build();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:ParamFilter.java

示例14: toResponse

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Override
public Response toResponse(WebApplicationException exception) {

  LOGGER.error("WebApplicationException:", exception);
  LOGGER.debug("Constructing Error Response for: [{}]", exception.toString());
  ErrorResponse errorResponse = new ErrorResponse();

  Response exceptionResponse = exception.getResponse();
  Response.StatusType statusInfo = exceptionResponse.getStatusInfo();

  errorResponse.setCode(statusInfo.getStatusCode());
  errorResponse.setStatus(statusInfo.getReasonPhrase());
  errorResponse.setMessage(exception.getMessage());

  Response.ResponseBuilder responseBuilder = Response.status(statusInfo)
      .entity(errorResponse)
      .type(MediaType.APPLICATION_JSON);

  MultivaluedMap<String, Object> headers = exceptionResponse.getHeaders();
  if (headers.size() > 0) {
    LOGGER.debug("Adding headers:");
    for (Map.Entry<String, List<Object>> entry : headers.entrySet()) {
      String headerKey = entry.getKey();
      List<Object> headerValues = entry.getValue();
      LOGGER.debug("  {} -> {}", headerKey, headerValues);
      if (headerValues.size() == 1) {
        responseBuilder.header(headerKey, headerValues.get(0));
      } else {
        responseBuilder.header(headerKey, headerValues);
      }
    }
  }

  return responseBuilder.build();
}
 
開發者ID:durimkryeziu,項目名稱:jersey-2.x-webapp-for-servlet-container,代碼行數:36,代碼來源:WebApplicationExceptionMapper.java


注:本文中的javax.ws.rs.core.MultivaluedMap.entrySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。