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

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

      
    
Rootfs path

      
    
Size
2429 (2.4 KB)
MD5
32ec59a9f4389d4e5ea4dd397a890620
SHA1
61008b375499cd965426d7604b26152867948534
SHA256
6df4c855652e5907af97c414c201b14944bddf9fcdfcc0813513d62ab0fb9864
SHA512

      
    
SHA1_git
5c6686be66a449d8531ec9cce5ee2b3905a1752e
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ByteBufferUtils.java | 2.4 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; import java.nio.ByteBuffer; public class ByteBufferUtils { private ByteBufferUtils() { // Hide the default constructor since this is a utility class. } /** * Expands buffer to the given size unless it is already as big or bigger. Buffers are assumed to be in 'write to' * mode since there would be no need to expand a buffer while it was in 'read from' mode. * * @param in Buffer to expand * @param newSize The size t which the buffer should be expanded * * @return The expanded buffer with any data from the input buffer copied in to it or the original buffer if there * was no need for expansion */ public static ByteBuffer expand(ByteBuffer in, int newSize) { if (in.capacity() >= newSize) { return in; } ByteBuffer out; boolean direct = false; if (in.isDirect()) { out = ByteBuffer.allocateDirect(newSize); direct = true; } else { out = ByteBuffer.allocate(newSize); } // Copy data in.flip(); out.put(in); if (direct) { cleanDirectBuffer(in); } return out; } /** * Clean specified direct buffer. This will cause an unavoidable warning on Java 24 and newer. * * @param buf the buffer to clean */ public static void cleanDirectBuffer(ByteBuffer buf) { ByteBufferUtilsUnsafe.cleanDirectBuffer(buf); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
39.93
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