Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.encoders;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
import static org.apache.juneau.internal.CollectionUtils.*;
import static java.util.stream.Collectors.*;
import java.util.*;
import java.util.concurrent.*;
import org.apache.juneau.*;
import org.apache.juneau.cp.*;
import org.apache.juneau.internal.*;
/**
* Represents the set of {@link Encoder encoders} keyed by codings.
*
*
Description
*
* Maintains a set of encoders and the codings that they can handle.
*
*
* The {@link #getEncoderMatch(String)} and {@link #getEncoder(String)} methods are then used to find appropriate
* encoders for specific Accept-Encoding and Content-Encoding header values.
*
*
Match ordering
*
* Encoders are matched against Accept-Encoding strings in the order they exist in this group.
*
*
* Encoders are tried in the order they appear in the set. The {@link Builder#add(Class...)}/{@link Builder#add(Encoder...)}
* methods prepend the values to the list to allow them the opportunity to override encoders already in the list.
*
*
* For example, calling groupBuilder.add(E1.class,E2.class).add(E3.class,
* E4.class) will result in the order E3, E4, E1, E2.
*
*
Example:
*
* // Create an encoder group with support for gzip compression.
* EncoderSet encoders = EncoderSet
* .create()
* .add(GzipEncoder.class)
* .build();
*
* // Should return "gzip"
* String matchedCoding = encoders.findMatch("compress;q=1.0, gzip;q=0.8, identity;q=0.5, *;q=0");
*
* // Get the encoder
* Encoder encoder = encoders.getEncoder(matchedCoding);
*
*/
public final class EncoderSet {
//-----------------------------------------------------------------------------------------------------------------
// Static
//-----------------------------------------------------------------------------------------------------------------
/**
* An identifier that the previous encoders in this group should be inherited.
*
* Used by {@link Builder#set(Class...)}
*/
public static abstract class Inherit extends Encoder {}
/**
* An identifier that the previous encoders in this group should not be inherited.
*
* Used by {@link Builder#add(Class...)}
*/
public static abstract class NoInherit extends Encoder {}
/**
* Static creator.
*
* @param beanStore The bean store to use for creating beans.
* @return A new builder for this object.
*/
public static Builder create(BeanStore beanStore) {
return new Builder(beanStore);
}
/**
* Static creator.
*
* @return A new builder for this object.
*/
public static Builder create() {
return new Builder(BeanStore.INSTANCE);
}
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
/**
* Builder class.
*/
@FluentSetters
public static class Builder extends BeanBuilder {
List