ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/parser/AcceptLanguage.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/parser/AcceptLanguage.java
Status
scanned
Type
file
Name
AcceptLanguage.java
Extension
.java
Programming language
Java
Mime type
text/x-Algol68
File type
Algol 68 source, ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2626 (2.6 KB)
MD5
ee0e326a446b58b642cc379bd69d3c9b
SHA1
b2b7b716cd31b4c35ca35d7b1a08f725e1fb8c29
SHA256
df5a8942c69137e9068429cb620df8f340596c2494cd14570f8a2a89fac30849
SHA512

      
    
SHA1_git
975608bb0ed9e03d40bb59b40af1ae78ba1bb704
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
AcceptLanguage.java | 2.6 KB |

/* * 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.tomcat.util.http.parser; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Locale; public class AcceptLanguage { private final Locale locale; private final double quality; protected AcceptLanguage(Locale locale, double quality) { this.locale = locale; this.quality = quality; } public Locale getLocale() { return locale; } public double getQuality() { return quality; } public static List<AcceptLanguage> parse(StringReader input) throws IOException { List<AcceptLanguage> result = new ArrayList<>(); do { // Token is broader than what is permitted in a language tag // (alphanumeric + '-') but any invalid values that slip through // will be caught later String languageTag = HttpParser.readToken(input); if (languageTag == null) { // Invalid tag, skip to the next one HttpParser.skipUntil(input, 0, ','); continue; } if (languageTag.isEmpty()) { // No more data to read break; } // See if a quality has been provided double quality = 1; SkipResult lookForSemiColon = HttpParser.skipConstant(input, ";"); if (lookForSemiColon == SkipResult.FOUND) { quality = HttpParser.readWeight(input, ','); } if (quality > 0) { result.add(new AcceptLanguage(Locale.forLanguageTag(languageTag), quality)); } } while (true); return result; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
42.35
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9