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


Java MultiMap类代码示例

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


MultiMap类属于io.vertx.core包,在下文中一共展示了MultiMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
public static JsonObject call(HttpServerRequest httpServerRequest) {
    JsonObject jsonObject = new JsonObject();

    String query = httpServerRequest.query();
    String requestLine = String.format("%s %s%s %s", httpServerRequest.method(), httpServerRequest.path(), query != null ? '?' + query : "", httpServerRequest.version().toString());
    jsonObject.put("request_line", requestLine);
    MultiMap headers = httpServerRequest.headers();
    JsonArray jsonHeaders = new JsonArray();
    for (String headerName : headers.names()) {
        List<String> values = headers.getAll(headerName);
        JsonObject jsonHeader = new JsonObject();
        jsonHeader.put(headerName, values);
        jsonHeaders.add(jsonHeader);
    }
    jsonObject.put("headers", jsonHeaders);
    return jsonObject;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:18,代码来源:HttpServerRequestHeaderToJsonObject.java

示例2: getFormattedElement

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public String getFormattedElement(AccessLogParam accessLogParam) {
  HttpServerResponse response = accessLogParam.getRoutingContext().response();
  if (null == response) {
    return RESULT_NOT_FOUND;
  }

  MultiMap headers = response.headers();
  if (null == headers) {
    return RESULT_NOT_FOUND;
  }

  String result = headers.get(identifier);
  if (null == result) {
    return RESULT_NOT_FOUND;
  }

  return result;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:20,代码来源:ResponseHeaderElement.java

示例3: TileCtx

import io.vertx.core.MultiMap; //导入依赖的package包/类
/**
 * Default constructor.
 * @param params {@link io.vertx.core.http.HttpServerRequest} parameters
 * required for rendering an image region.
 * @param omeroSessionKey OMERO session key.
 */
TileCtx(MultiMap params, String omeroSessionKey) {
    this.omeroSessionKey = omeroSessionKey;
    imageId = Long.parseLong(params.get("imageId"));
    z = Integer.parseInt(params.get("z"));
    c = Integer.parseInt(params.get("c"));
    t = Integer.parseInt(params.get("t"));
    Integer x = Optional.ofNullable(params.get("x"))
            .map(Integer::parseInt)
            .orElse(0);
    Integer y = Optional.ofNullable(params.get("y"))
            .map(Integer::parseInt)
            .orElse(0);
    Integer width = Optional.ofNullable(params.get("w"))
            .map(Integer::parseInt)
            .orElse(0);
    Integer height = Optional.ofNullable(params.get("h"))
            .map(Integer::parseInt)
            .orElse(0);
    region = new RegionDef(x, y, width, height);
    resolution = Optional.ofNullable(params.get("resolution"))
            .map(Integer::parseInt)
            .orElse(null);
    format = params.get("format");
}
 
开发者ID:glencoesoftware,项目名称:omero-ms-pixel-buffer,代码行数:31,代码来源:TileCtx.java

示例4: set

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public MultiMap set(final String name, final Iterable<String> values) {
    Objects.requireNonNull(values, "values");

    int h = hash(name);
    int i = index(h);

    remove0(h, i, name);
    for (String v : values) {
        if (v == null) {
            break;
        }
        add0(h, i, name, v);
    }

    return this;
}
 
开发者ID:noseka1,项目名称:vertx-aws-lambda,代码行数:18,代码来源:CaseSensitiveMultiMapImpl.java

示例5: in

import io.vertx.core.MultiMap; //导入依赖的package包/类
public static void in(final IpcData data, final Envelop envelop) {
    if (null != envelop) {
        // User
        final User user = envelop.user();
        final JsonObject sendData = new JsonObject();
        if (null != user) {
            sendData.put("user", user.principal());
        }
        // Header
        final MultiMap headers = envelop.headers();
        if (null != headers) {
            final JsonObject headerData = new JsonObject();
            headers.forEach((entry) -> headerData.put(entry.getKey(), entry.getValue()));
            sendData.put("header", headerData);
        }
        // Data
        final Object content = envelop.data();
        sendData.put("data", content);
        sendData.put("config", data.getConfig());
        // Data Prepared finished.
        sendData.put("address", data.getAddress());
        data.setData(sendData.toBuffer());
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:25,代码来源:DataEncap.java

示例6: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    String value = headers.get(headerName);
    if (value != null) {
        boolean failed = false;
        BaseEncoding baseEncoding = base64();
        try {
            byte[] decoded = baseEncoding.decode(value);
            if (decoded == null || !value.equals(baseEncoding.encode(decoded))) {
                failed = true;
            }
        } catch (Throwable e) {
            // do nothing
        }
        if (failed) {
            JsonObject jsonObject = new JsonObject()
                    .put("message", format("%s must be Base64 encoded", headerName));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }
    return httpServerRequest;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:26,代码来源:ValidateHeaderIsBase64Encoded.java

示例7: testArrayMulti

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Test()
public void testArrayMulti() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("multi");
    List<String> paramsList = new ArrayList<>();
    paramsList.add("toto");
    paramsList.add("tutu");
    paramsList.add("titi");
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, paramsList);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(paramsList.toArray(), ((List) result).toArray());
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:18,代码来源:AbstractSerializableParameterExtractorTest.java

示例8: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    String value = headers.get(headerName);
    if (value != null) {
        Long parsed = tryParse(value);
        if (parsed == null || parsed < min || parsed > max) {
            JsonObject jsonObject = new JsonObject()
                    .put("message", format("%s must be between %d and %d", headerName, min, max));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }
    return httpServerRequest;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:17,代码来源:ValidateHeaderBetweenLong.java

示例9: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public HttpClientResponse call(HttpClientResponse httpClientResponse) {
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("\r\nHttp Header Dump >>>>>\r\n\r\n");
        sb.append(format("HTTP/1.1 %d %s\r\n", httpClientResponse.statusCode(), httpClientResponse.statusMessage()));
        MultiMap headers = httpClientResponse.headers();
        for (String headerName : headers.names()) {
            List<String> values = headers.getAll(headerName);
            sb.append(format("%s: %s\r\n", headerName, on(',').join(values)));
        }
        sb.append("\r\n");
        sb.append("Http Header Dump <<<<<\r\n");
        LOGGER.debug(sb.toString());
    }
    return httpClientResponse;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:18,代码来源:HttpClientResponseHeaderLogger.java

示例10: getQueryParameters

import io.vertx.core.MultiMap; //导入依赖的package包/类
/**
 * Return the query parameters which do not include the the first &amp; or ? character.
 * 
 * @return Query string
 */
default String getQueryParameters() {
	StringBuilder query = new StringBuilder();
	MultiMap params = getParameters();
	for (Entry<String, String> entry : params.entries()) {
		String value = entry.getValue();
		if (value != null) {
			if (query.length() != 0) {
				query.append("&");
			}
			// try {
			query.append(entry.getKey() + "=" + value);// URLEncoder.encode(value, "UTF-8"));
			// } catch (UnsupportedEncodingException e) {
			// }
		}
	}
	return query.toString();
}
 
开发者ID:gentics,项目名称:mesh,代码行数:23,代码来源:ParameterProvider.java

示例11: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public T call(T httpServerRequest) {
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("\r\nHttp Header Dump >>>>>\r\n\r\n");
        String query = httpServerRequest.query();
        sb.append(format("%s %s%s %s\r\n", httpServerRequest.method(), httpServerRequest.path(), query != null ? '?' + query : "", httpServerRequest.version().toString()));
        MultiMap headers = httpServerRequest.headers();
        for (String headerName : headers.names()) {
            List<String> values = headers.getAll(headerName);
            sb.append(format("%s: %s\r\n", headerName, on(',').join(values)));
        }
        sb.append("\r\n");
        sb.append("Http Header Dump <<<<<\r\n");
        LOGGER.debug(sb.toString());
    }
    return httpServerRequest;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:19,代码来源:HttpServerRequestHeaderLogger.java

示例12: testRequestBegin

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Test
public void testRequestBegin() {

    SocketAddress socketMetric = mock(SocketAddress.class);
    SocketAddress localAddress = mock(SocketAddress.class);
    SocketAddress remoteAddress = mock(SocketAddress.class);
    HttpClientRequest request = mock(HttpClientRequest.class);
    MultiMap headers = mock(MultiMap.class);

    when(headers.get(eq(Tags.TRACK_HEADER.toString()))).thenReturn("tag");
    when(request.headers()).thenReturn(headers);

    HttpRequestMetrics metrics = victim.requestBegin(null, socketMetric, localAddress, remoteAddress, request);

    assertNotNull(metrics);
    assertEquals(remoteAddress, metrics.getAddress());
}
 
开发者ID:statful,项目名称:statful-client-vertx,代码行数:18,代码来源:HttpClientMetricsImplTest.java

示例13: call

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public HttpClientResponse call(HttpClientResponse httpClientResponse) {
    out.println("Assert #" + assertIndex);
    MultiMap headers = httpClientResponse.headers();
    String etag = headers.get(ETAG);
    String contentMd5 = headers.get(CONTENT_MD5);
    String contentSha512 = headers.get(X_CONTENT_SHA512);
    String versionId = headers.get(X_CONTENT_VERSION);
    String contentLength = headers.get(CONTENT_LENGTH);
    String acceptRanges = headers.get(ACCEPT_RANGES);
    String lastModified = headers.get(LAST_MODIFIED);
    String date = headers.get(DATE);
    String serverSideEncryption = headers.get(X_SERVER_SIDE_ENCRYPTION);

    assertEquals(context, base16().lowerCase().encode(dataMd5), etag);
    assertEquals(context, base64().encode(dataMd5), contentMd5);
    assertEquals(context, base64().encode(dataSha512), contentSha512);
    assertEquals(context, expectedVersion, parseLong(versionId));
    //VertxAssert.assertEquals(context, expectedContentLength, Long.parseLong(contentLength));
    assertEquals(context, "none", acceptRanges);
    assertNotNull(context, lastModified);
    assertNotNull(context, date);
    assertEquals(context, this.serverSideEncryption, parseBoolean(serverSideEncryption));

    return httpClientResponse;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:27,代码来源:AssertObjectHeaders.java

示例14: execute

import io.vertx.core.MultiMap; //导入依赖的package包/类
public Observable<Void> execute(VertxContext<Server> vertxContext, String jobId, MultiMap parameters) {
    return Defer.aVoid()
            .doOnNext(aVoid -> checkMaster(vertxContext))
            .map(aVoid -> getJob(jobId))
            .map(this::newInstance)
            .flatMap(job ->
                    Observable.using(
                            () -> runningJobs.putIfAbsent(jobId, job) == null,
                            running -> {
                                if (running) {
                                    return job.execute(vertxContext, parameters);
                                } else {
                                    return Observable.error(new JobAlreadyRunning());
                                }
                            },
                            running -> {
                                if (running) {
                                    runningJobs.remove(jobId);
                                }
                            }));
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:22,代码来源:Jobs.java

示例15: push

import io.vertx.core.MultiMap; //导入依赖的package包/类
@Override
public HttpServerResponse push(HttpMethod method, String host, String path, MultiMap headers, Handler<AsyncResult<HttpServerResponse>> handler) {
    ObservableFuture<Void> h = RxHelper.observableFuture();
    stopKeepAlive(h);
    h.subscribe(new Subscriber<Void>() {
        @Override
        public void onCompleted() {
            delegate.push(method, host, path, headers, handler);
        }

        @Override
        public void onError(Throwable e) {
            handleThrowable(e);
        }

        @Override
        public void onNext(Void aVoid) {

        }
    });
    return this;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:23,代码来源:KeepAliveHttpServerResponse.java


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