- java.lang.Object
-
- org.arakhne.afc.vmutil.StandardJREResourceWrapper
-
- All Implemented Interfaces:
ResourceWrapper
class StandardJREResourceWrapper extends Object implements ResourceWrapper
This interface provides the standard JRE implementation to load resources. The following heuristics are applied:- search the resource in class paths;
- search the resource in ./resources subdirectory in class paths.
- Since:
- 7.0
- Version:
- 17.0 2020-01-04 14:41:35
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- vmutils
-
-
Field Summary
Fields Modifier and Type Field Description static StringRESOURCE_PREFIXPrefix (or directory name) where resources may be located.
-
Constructor Summary
Constructors Constructor Description StandardJREResourceWrapper()Construct a wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description URLgetResource(Class<?> clazz, String path)Replies the URL of a resource.URLgetResource(ClassLoader classLoader, String path)Deprecated.InputStreamgetResourceAsStream(Class<?> clazz, String path)Replies the input stream of a resource.InputStreamgetResourceAsStream(ClassLoader classLoader, String path)Deprecated.StringtranslateResourceName(String resourceName)Translate the given resource name according to the current JVM standard.
-
-
-
Field Detail
-
RESOURCE_PREFIX
public static final String RESOURCE_PREFIX
Prefix (or directory name) where resources may be located.- See Also:
- Constant Field Values
-
-
Method Detail
-
getResource
@Pure @Deprecated(since="17.0") public URL getResource(ClassLoader classLoader, String path)
Deprecated.Description copied from interface:ResourceWrapperReplies the URL of a resource.You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
If the
classLoaderparameter isnull, the class loader replied byClassLoaderFinderis used. If this last isnull, the class loader of the Resources class is used.- Specified by:
getResourcein interfaceResourceWrapper- Parameters:
classLoader- is the research scope. Ifnull, the class loader replied byClassLoaderFinderis used.path- is the absolute path of the resource.- Returns:
- the url of the resource or
nullif the resource was not found in class paths.
-
getResource
@Pure public URL getResource(Class<?> clazz, String path)
Description copied from interface:ResourceWrapperReplies the URL of a resource.You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames.
If the
classLoaderparameter isnull, the class loader replied byClassLoaderFinderis used. If this last isnull, the class loader of the Resources class is used.- Specified by:
getResourcein interfaceResourceWrapper- Parameters:
clazz- is the research scope. It cannot benull.path- is the absolute path of the resource.- Returns:
- the url of the resource or
nullif the resource was not found in class paths.
-
getResourceAsStream
@Pure @Deprecated(since="17.0") public InputStream getResourceAsStream(ClassLoader classLoader, String path)
Deprecated.Description copied from interface:ResourceWrapperReplies the input stream of a resource.You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames, and may not start the path with a slash.
If the
classLoaderparameter isnull, the class loader replied byClassLoaderFinderis used. If this last isnull, the class loader of the Resources class is used.- Specified by:
getResourceAsStreamin interfaceResourceWrapper- Parameters:
classLoader- is the research scope. Ifnull, the class loader replied byClassLoaderFinderis used.path- is the absolute path of the resource.- Returns:
- the url of the resource or
nullif the resource was not found in class paths.
-
getResourceAsStream
@Pure public InputStream getResourceAsStream(Class<?> clazz, String path)
Description copied from interface:ResourceWrapperReplies the input stream of a resource.You may use Unix-like syntax to write the resource path, ie. you may use slashes to separate filenames, and may not start the path with a slash.
If the
classLoaderparameter isnull, the class loader replied byClassLoaderFinderis used. If this last isnull, the class loader of the Resources class is used.- Specified by:
getResourceAsStreamin interfaceResourceWrapper- Parameters:
clazz- is the research scope. It cannot benull.path- is the absolute path of the resource.- Returns:
- the url of the resource or
nullif the resource was not found in class paths.
-
translateResourceName
@Pure public String translateResourceName(String resourceName)
Description copied from interface:ResourceWrapperTranslate the given resource name according to the current JVM standard.The
resourceNameargument should be a fully qualified class name. However, for compatibility with earlier versions, Sun's Java SE Runtime Environments do not verify this, and so it is possible to accessPropertyResourceBundles by specifying a path name (using "/") instead of a fully qualified class name (using "."). In several VM, such as Dalvik, the translation from "." to "/" is not automatically done by the VM to retreive the file.- Specified by:
translateResourceNamein interfaceResourceWrapper- Parameters:
resourceName- the name to translate.- Returns:
- the translated resource name.
-
-