Package org.jibx.util
Class ClasspathUrlExtender
- java.lang.Object
-
- org.jibx.util.ClasspathUrlExtender
-
public class ClasspathUrlExtender extends java.lang.ObjectSupport class for accessing resources using classpath URLs. ThebuildURL(URL, String)method must be used to construct a URL for a resource on the classpath, and thesetClassLoader(ClassLoader)method must first be used to set the classloader if it differs from the classloader used for loading this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClasspathUrlExtender.ClasspathHandlerHandler for opening a connection to a resource from the classpath.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASSPATH_PROTOCOLProtocol name for classpath access.private static ClasspathUrlExtender.ClasspathHandlers_handlerSingleton instance of handler for stream access to resource.
-
Constructor Summary
Constructors Constructor Description ClasspathUrlExtender()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.URLbuildURL(java.net.URL base, java.lang.String path)Construct a URL which may represent a resource from the classpath.static booleanisClasspathUrl(java.lang.String url)Check if a URL string represents a resource from the classpath.static voidsetClassLoader(java.lang.ClassLoader loader)Set the classloader to be used for accessing resources.
-
-
-
Field Detail
-
CLASSPATH_PROTOCOL
public static final java.lang.String CLASSPATH_PROTOCOL
Protocol name for classpath access.- See Also:
- Constant Field Values
-
s_handler
private static ClasspathUrlExtender.ClasspathHandler s_handler
Singleton instance of handler for stream access to resource.
-
-
Method Detail
-
setClassLoader
public static void setClassLoader(java.lang.ClassLoader loader)
Set the classloader to be used for accessing resources.- Parameters:
loader-
-
isClasspathUrl
public static boolean isClasspathUrl(java.lang.String url)
Check if a URL string represents a resource from the classpath.- Parameters:
url-- Returns:
trueif classpath resource,falseif not
-
buildURL
public static java.net.URL buildURL(java.net.URL base, java.lang.String path) throws java.net.MalformedURLExceptionConstruct a URL which may represent a resource from the classpath.- Parameters:
base- URL base for relative referencespath- resource path- Returns:
- URL for access to resource
- Throws:
java.net.MalformedURLException- if not a valid URL format
-
-