ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/buf/Ascii.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/buf/Ascii.java
Status
scanned
Type
file
Name
Ascii.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3103 (3.0 KB)
MD5
c9b1aa3fa3f5b02a53290a7c70ff256b
SHA1
c78580bad9bfacc086fb93c04c6e9a0b32f83cfc
SHA256
703f03ee6fd893400cf3898febe817c826a9f169464c340860ce0763896d6032
SHA512

      
    
SHA1_git
0ac9d795c237a9ce8590a829a82463e7d1abda87
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Ascii.java | 3.0 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.buf; /** * This class implements some basic ASCII character handling functions. */ public final class Ascii { /* * Character translation tables. */ private static final byte[] toLower = new byte[256]; /* * Character type tables. */ private static final boolean[] isDigit = new boolean[256]; private static final long OVERFLOW_LIMIT = Long.MAX_VALUE / 10; /* * Initialize character translation and type tables. */ static { for (int i = 0; i < 256; i++) { toLower[i] = (byte) i; } for (int lc = 'a'; lc <= 'z'; lc++) { int uc = lc + 'A' - 'a'; toLower[uc] = (byte) lc; } for (int d = '0'; d <= '9'; d++) { isDigit[d] = true; } } /** * Returns the lower case equivalent of the specified ASCII character. * * @param c The char * * @return the lower case equivalent char */ public static int toLower(int c) { return toLower[c & 0xff] & 0xff; } /** * @return <code>true</code> if the specified ASCII character is a digit. * * @param c The char */ private static boolean isDigit(int c) { return isDigit[c & 0xff]; } /** * Parses an unsigned long from the specified sub array of bytes. * * @param b the bytes to parse * @param off the start offset of the bytes * @param len the length of the bytes * * @return the long value * * @exception NumberFormatException if the long format was invalid */ public static long parseLong(byte[] b, int off, int len) throws NumberFormatException { int c; if (b == null || len <= 0 || !isDigit(c = b[off++])) { throw new NumberFormatException(); } long n = c - '0'; while (--len > 0) { if (isDigit(c = b[off++]) && (n < OVERFLOW_LIMIT || (n == OVERFLOW_LIMIT && (c - '0') < 8))) { n = n * 10 + c - '0'; } else { throw new NumberFormatException(); } } return n; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
32.43
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