public class ResourceHandler
extends java.lang.Object
This class acts as a manager for discovering and creating resource objects in ICE. Resources in ICE can be used in Model Items for things such as displaying the contents of a mesh file, or in Launcher Items for tasks such as plotting the contents of a post-processed CSV file.
Some resources contain visualization data and can be rendered via the
visualization service. A private list of all file extensions that have a
IVizService implementation is maintained and used for cross reference. If a
file extension matches one found in this private list, the associated
recourse will be a VizResource
, otherwise it will be just a regular
ICEResource
.
This class' methods are intended to be called by Items directly, using the
Item.getProcess(...)
methods. method.
Constructor and Description |
---|
ResourceHandler()
Nullary constructor.
|
Modifier and Type | Method and Description |
---|---|
ICEResource |
getResource(java.lang.String filePath)
This method is the star of the
ResourceHandler class and does the
majority of the heavy-lifting. |
ICEResource |
getResource(java.lang.String filePath,
java.lang.String name)
This method calls
getResource(String) and then sets the
resource's name. |
ICEResource |
getResource(java.lang.String filePath,
java.lang.String name,
int id)
This method calls
getResource(String, String) and then sets the
resource's ID. |
ICEResource |
getResource(java.lang.String filePath,
java.lang.String name,
int id,
java.lang.String desc)
This method calls
getResource(String, String, int) and then sets
the resource's description. |
public ResourceHandler()
vizFileExtensions
list.public ICEResource getResource(java.lang.String filePath) throws java.io.IOException
This method is the star of the ResourceHandler
class and does the
majority of the heavy-lifting.
Based on the filepath passed in, it will create and return a
VizResource
if it has a file extension found in the
vizFileExtensions
list. If the file extension is not found in
the list, then it will create and return a regular ICEResource
.
If no valid file extension was found, it will return null.
filePath
- The file path to the resource file.VizResource
or ICEResource
depending on
the file path, or null if the file path was invalid.java.io.IOException
public ICEResource getResource(java.lang.String filePath, java.lang.String name) throws java.io.IOException
getResource(String)
and then sets the
resource's name.filePath
- The file path to the resource file.name
- The name of the resource object.VizResource
or ICEResource
depending on
the file path, or null if the file path was invalid.java.io.IOException
public ICEResource getResource(java.lang.String filePath, java.lang.String name, int id) throws java.io.IOException
getResource(String, String)
and then sets the
resource's ID.filePath
- The file path to the resource file.name
- The name of the resource object.id
- The ID of the resource object.VizResource
or ICEResource
depending on
the file path, or null if the file path was invalid.java.io.IOException
public ICEResource getResource(java.lang.String filePath, java.lang.String name, int id, java.lang.String desc) throws java.io.IOException
getResource(String, String, int)
and then sets
the resource's description.filePath
- The file path to the resource file.name
- The name of the resource object.id
- The ID of the resource object.desc
- The description of the resource object.VizResource
or ICEResource
depending on
the file path, or null if the file path was invalid.java.io.IOException