test_class.declarator: variantsHandler
test_class.modifier: private
test_class.original_string: private VariantsHandler variantsHandler;
test_class.type: VariantsHandler
test_class.var_name: variantsHandler
test_class.file: everrest-core/src/test/java/org/everrest/core/impl/VariantsHandlerTest.java
test_class.identifier: VariantsHandlerTest
test_case.body: @Test
      public void selectsVariant() throws Exception {
          List<Variant> variantList = Variant.mediaTypes(MediaType.valueOf("image/jpeg")).add()
                                             .mediaTypes(MediaType.valueOf("text/xml")).languages(new Locale("en", "gb")).add()
                                             .mediaTypes(MediaType.valueOf("text/xml;charset=utf-8")).languages(new Locale("en", "us")).add()
                                             .mediaTypes(MediaType.valueOf("text/xml;charset=utf-8")).languages(new Locale("en", "us")).encodings("gzip").add()
                                             .build();
  
          MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
          headers.putSingle(ACCEPT, Joiner.on(',').join("text/xml", "image/png", "text/html;q=0.9", "text/plain;q=0.8", "application/xml", "*/*;q=0.5"));
          headers.putSingle(ACCEPT_LANGUAGE, "en-us,en;q=0.5");
          headers.putSingle(ACCEPT_CHARSET, "utf-8,koi8;q=0.7");
          headers.putSingle(ACCEPT_ENCODING, "gzip");
  
          ContainerRequest request = new ContainerRequest("GET", null, null, null, headers, null);
  
          Variant variant = variantsHandler.handleVariants(request, variantList);
          assertNotNull(variant);
          assertEquals(new MediaType("text", "xml", ImmutableMap.of("charset", "utf-8")), variant.getMediaType());
          assertEquals(new Locale("en", "us"), variant.getLanguage());
          assertEquals("gzip", variant.getEncoding());
      }
test_case.class_method_signature: VariantsHandlerTest.selectsVariant()
test_case.full_signature: @Test public void selectsVariant()
test_case.identifier: selectsVariant
test_case.invocations: build add encodings languages mediaTypes add languages mediaTypes add languages mediaTypes add mediaTypes valueOf valueOf valueOf valueOf putSingle join on putSingle putSingle putSingle handleVariants assertNotNull assertEquals of getMediaType assertEquals getLanguage assertEquals getEncoding
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void selectsVariant()
focal_class.file: everrest-core/src/main/java/org/everrest/core/impl/VariantsHandler.java
focal_class.identifier: VariantsHandler
focal_class.class_method_signature: VariantsHandler.handleVariants(ContainerRequest request, List<Variant> variants)
focal_class.full_signature: public Variant handleVariants(ContainerRequest request, List<Variant> variants)
focal_class.identifier: handleVariants
focal_class.modifiers: public
focal_class.parameters: (ContainerRequest request, List<Variant> variants)
focal_class.return: Variant
focal_class.signature: Variant handleVariants(ContainerRequest request, List<Variant> variants)
focal_class.class_method_signature: VariantsHandler.filterByMediaType(List<AcceptMediaType> acceptMediaTypes, List<Variant> variants)
focal_class.full_signature: private List<Variant> filterByMediaType(List<AcceptMediaType> acceptMediaTypes, List<Variant> variants)
focal_class.identifier: filterByMediaType
focal_class.modifiers: private
focal_class.parameters: (List<AcceptMediaType> acceptMediaTypes, List<Variant> variants)
focal_class.return: List<Variant>
focal_class.signature: List<Variant> filterByMediaType(List<AcceptMediaType> acceptMediaTypes, List<Variant> variants)
focal_class.class_method_signature: VariantsHandler.filterByLanguage(List<AcceptLanguage> acceptLanguages, List<Variant> variants)
focal_class.full_signature: private List<Variant> filterByLanguage(List<AcceptLanguage> acceptLanguages, List<Variant> variants)
focal_class.identifier: filterByLanguage
focal_class.modifiers: private
focal_class.parameters: (List<AcceptLanguage> acceptLanguages, List<Variant> variants)
focal_class.return: List<Variant>
focal_class.signature: List<Variant> filterByLanguage(List<AcceptLanguage> acceptLanguages, List<Variant> variants)
focal_class.class_method_signature: VariantsHandler.filterByCharset(List<AcceptToken> acceptCharsets, List<Variant> variants)
focal_class.full_signature: private List<Variant> filterByCharset(List<AcceptToken> acceptCharsets, List<Variant> variants)
focal_class.identifier: filterByCharset
focal_class.modifiers: private
focal_class.parameters: (List<AcceptToken> acceptCharsets, List<Variant> variants)
focal_class.return: List<Variant>
focal_class.signature: List<Variant> filterByCharset(List<AcceptToken> acceptCharsets, List<Variant> variants)
focal_class.class_method_signature: VariantsHandler.getCharset(MediaType mediaType)
focal_class.full_signature: private String getCharset(MediaType mediaType)
focal_class.identifier: getCharset
focal_class.modifiers: private
focal_class.parameters: (MediaType mediaType)
focal_class.return: String
focal_class.signature: String getCharset(MediaType mediaType)
focal_class.class_method_signature: VariantsHandler.filterByEncoding(List<AcceptToken> acceptEncodings, List<Variant> variants)
focal_class.full_signature: private List<Variant> filterByEncoding(List<AcceptToken> acceptEncodings, List<Variant> variants)
focal_class.identifier: filterByEncoding
focal_class.modifiers: private
focal_class.parameters: (List<AcceptToken> acceptEncodings, List<Variant> variants)
focal_class.return: List<Variant>
focal_class.signature: List<Variant> filterByEncoding(List<AcceptToken> acceptEncodings, List<Variant> variants)
focal_method.body: public Variant handleVariants(ContainerRequest request, List<Variant> variants) {
          List<AcceptMediaType> acceptMediaTypes = createAcceptMediaTypeList(convertToString(request.getRequestHeader(ACCEPT)));
          List<AcceptLanguage> acceptLanguages = createAcceptedLanguageList(convertToString(request.getRequestHeader(ACCEPT_LANGUAGE)));
          List<AcceptToken> acceptCharset = createAcceptedCharsetList(convertToString(request.getRequestHeader(ACCEPT_CHARSET)));
          List<AcceptToken> acceptEncoding = createAcceptedEncodingList(convertToString(request.getRequestHeader(ACCEPT_ENCODING)));
  
          List<Variant> filteredVariants = new ArrayList<>(variants);
  
          filteredVariants = filterByMediaType(acceptMediaTypes, filteredVariants);
          filteredVariants = filterByLanguage(acceptLanguages, filteredVariants);
          filteredVariants = filterByCharset(acceptCharset, filteredVariants);
          filteredVariants = filterByEncoding(acceptEncoding, filteredVariants);
  
          return filteredVariants.isEmpty() ? null : filteredVariants.get(0);
      }
focal_method.class_method_signature: VariantsHandler.handleVariants(ContainerRequest request, List<Variant> variants)
focal_method.full_signature: public Variant handleVariants(ContainerRequest request, List<Variant> variants)
focal_method.identifier: handleVariants
focal_method.invocations: createAcceptMediaTypeList convertToString getRequestHeader createAcceptedLanguageList convertToString getRequestHeader createAcceptedCharsetList convertToString getRequestHeader createAcceptedEncodingList convertToString getRequestHeader filterByMediaType filterByLanguage filterByCharset filterByEncoding isEmpty get
focal_method.modifiers: public
focal_method.parameters: (ContainerRequest request, List<Variant> variants)
focal_method.return: Variant
focal_method.signature: Variant handleVariants(ContainerRequest request, List<Variant> variants)