Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.undertow.server.handlers.encoding;
 
 

Author(s):
Stuart Douglas
public class ContentEncodingRepository {
    public static final String IDENTITY = "identity";
    private final Map<StringEncodingMappingencodingMap = new CopyOnWriteMap<StringEncodingMapping>();

    
Gets all allow

Parameters:
exchange
Returns:
        final List<Stringres = exchange.getRequestHeaders().get(.);
        if (res == null || res.isEmpty()) {
            return null;
        }
        final List<EncodingMappingresultingMappings = new ArrayList<EncodingMapping>();
        final List<List<QValueParser.QValueResult>> found = QValueParser.parse(res);
        for (List<QValueParser.QValueResultresult : found) {
            List<EncodingMappingavailable = new ArrayList<EncodingMapping>();
            boolean includesIdentity = false;
            boolean isQValue0 = false;
            for (final QValueParser.QValueResult value : result) {
                EncodingMapping encoding;
                if (value.getValue().equals("*")) {
                    includesIdentity = true;
                    encoding = new EncodingMapping(., 0, Predicates.truePredicate());
                } else {
                    encoding = .get(value.getValue());
                }
                if (value.isQValueZero()) {
                    isQValue0 = true;
                }
                if (encoding != null) {
                    available.add(encoding);
                }
            }
            if (isQValue0) {
                if (resultingMappings.isEmpty()) {
                    if (includesIdentity) {
                        return new AllowedContentEncodings(exchange, Collections.<EncodingMapping>emptyList());
                    } else {
                        return null;
                    }
                }
            } else if (!available.isEmpty()) {
                Collections.sort(available, Collections.reverseOrder());
                resultingMappings.addAll(available);
            }
        }
        if (!resultingMappings.isEmpty()) {
            return new AllowedContentEncodings(exchangeresultingMappings);
        }
        return null;
    }
    public synchronized ContentEncodingRepository addEncodingHandler(final String encodingfinal ContentEncodingProvider encoderint priority) {
        addEncodingHandler(encodingencoderpriority, Predicates.truePredicate());
        return this;
    }
    public synchronized ContentEncodingRepository addEncodingHandler(final String encodingfinal ContentEncodingProvider encoderint priorityfinal Predicate enabledPredicate) {
        this..put(encodingnew EncodingMapping(encodingencoderpriorityenabledPredicate));
        return this;
    }
    public synchronized ContentEncodingRepository removeEncodingHandler(final String encoding) {
        .remove(encoding);
        return this;
    }
New to GrepCode? Check out our FAQ X