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

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

      
    
Rootfs path

      
    
Size
4054 (4.0 KB)
MD5
e4f86495d19c9cb209450cbcfb26fd1b
SHA1
792e11de519888fd72f87a4ad7f19191f01868d2
SHA256
15a33702926661fa32048f91c74b67626fdc807d16ca1daba8d14802d62495a2
SHA512

      
    
SHA1_git
a8fe053f5bac3e35f34f674da72f4b1ed57a4e30
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ToStringUtil.java | 4.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; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import org.apache.tomcat.util.res.StringManager; /** * Utility class used to provide String representations of objects. It is typically used in debug logging. */ public class ToStringUtil { private static final StringManager sm = StringManager.getManager(ToStringUtil.class); private static final String INDENT = " "; private ToStringUtil() { // Utility class. Hide default constructor. } /** * Generate a String representation of the class path for the given class loader and any parent class loaders to aid * debugging of {@link ClassNotFoundException}. * * @param classLoader The class loader to analyse * * @return A String representation of the class path. The format is undefined and may change in future point * releases. The output includes new lines. */ public static String classPathForCNFE(ClassLoader classLoader) { // The result is expected to be fairly large StringBuilder result = new StringBuilder(4096); result.append(sm.getString("toStringUtil.classpath.header")); result.append(" "); while (classLoader != null) { classPathForCNFE(classLoader, result); classLoader = classLoader.getParent(); } return result.toString(); } private static void classPathForCNFE(ClassLoader classLoader, StringBuilder result) { result.append(INDENT); result.append(sm.getString("toStringUtil.classpath.classloader", classLoader)); result.append(" "); if (classLoader instanceof URLClassLoader) { URL[] urls = ((URLClassLoader) classLoader).getURLs(); for (URL url : urls) { result.append(INDENT); result.append(INDENT); result.append(url); result.append(" "); } } else if (classLoader == ClassLoader.getSystemClassLoader()) { // From Java 9 the internal class loaders no longer extend // URLCLassLoader String cp = System.getProperty("java.class.path"); if (cp != null && !cp.isEmpty()) { String[] paths = cp.split(File.pathSeparator); for (String path : paths) { result.append(INDENT); result.append(INDENT); result.append(path); result.append(" "); } } } else if (classLoader == ClassLoader.getPlatformClassLoader()) { // From Java 9 the internal class loaders no longer extend // URLCLassLoader result.append(INDENT); result.append(INDENT); result.append(sm.getString("toStringUtil.classpath.platform")); result.append(" "); } else { result.append(INDENT); result.append(INDENT); result.append(sm.getString("toStringUtil.classpath.unknown")); result.append(" "); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.31
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