io.vertx.ext.web.impl.ParsableHeaderValuesContainer Maven / Gradle / Ivy
package io.vertx.ext.web.impl;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.ext.web.LanguageHeader;
import io.vertx.ext.web.MIMEHeader;
import io.vertx.ext.web.ParsedHeaderValue;
import io.vertx.ext.web.ParsedHeaderValues;
import java.util.Collection;
import java.util.List;
public class ParsableHeaderValuesContainer implements ParsedHeaderValues {
private final List accept;
private final List acceptCharset;
private final List acceptEncoding;
private final List acceptLanguage;
private final ParsableMIMEValue contentType;
public ParsableHeaderValuesContainer(
List accept, List acceptCharset, List acceptEncoding,
List acceptLanguage, ParsableMIMEValue contentType) {
this.accept = accept;
this.acceptCharset = acceptCharset;
this.acceptEncoding = acceptEncoding;
this.acceptLanguage = acceptLanguage;
this.contentType = contentType;
}
@Override
public List accept() {
return accept;
}
@Override
public List acceptCharset() {
return acceptCharset;
}
@Override
public List acceptEncoding() {
return acceptEncoding;
}
@Override
public List acceptLanguage() {
return acceptLanguage;
}
@Override
public ParsableMIMEValue contentType() {
return contentType;
}
@Override
public @Nullable MIMEHeader findBestUserAcceptedIn(List userAccepted, Collection in) {
for (MIMEHeader acceptableType: userAccepted) {
MIMEHeader acceptedType = acceptableType.findMatchedBy(in);
if (acceptedType != null) {
if ("*".equals(acceptedType.subComponent()) || "*".equals(acceptedType.component()))
return acceptableType;
else
return acceptedType;
}
}
return null;
}
}