Package org.jibx.util

Class ClasspathUrlExtender


  • public class ClasspathUrlExtender
    extends Object
    Support class for accessing resources using classpath URLs. The buildURL(URL, String) method must be used to construct a URL for a resource on the classpath, and the setClassLoader(ClassLoader) method must first be used to set the classloader if it differs from the classloader used for loading this class.
    • Field Detail

      • CLASSPATH_PROTOCOL

        public static final String CLASSPATH_PROTOCOL
        Protocol name for classpath access.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ClasspathUrlExtender

        public ClasspathUrlExtender()
    • Method Detail

      • setClassLoader

        public static void setClassLoader​(ClassLoader loader)
        Set the classloader to be used for accessing resources.
        Parameters:
        loader - Classloader
      • isClasspathUrl

        public static boolean isClasspathUrl​(String url)
        Check if a URL string represents a resource from the classpath.
        Parameters:
        url - URL
        Returns:
        true if classpath resource, false if not
      • buildURL

        public static URL buildURL​(URL base,
                                   String path)
                            throws MalformedURLException
        Construct a URL which may represent a resource from the classpath.
        Parameters:
        base - URL base for relative references
        path - resource path
        Returns:
        URL for access to resource
        Throws:
        MalformedURLException - if not a valid URL format