Package dev.getelements.elements.rt
Interface ResourceLoader
- All Superinterfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theResourceLoaderand cleaning up any resources.default Resourceload(InputStream is) Loads theResourcefrom theInputStreamin non-verbose mode.load(InputStream is, boolean verbose) Loads aResourcefrom the suppliedInputStream.load(String moduleName, Attributes attributes, Object... args) Loads theResourcespecified by the supplied module name.default ResourcePerforms the same operation asload(String, Attributes, Object...)usingAttributes.EMPTYas the specifiedAttributes.default Resourceload(ReadableByteChannel rbc) Loads theResourcefrom theReadableByteChannelin non-verbose mode.load(ReadableByteChannel rbc, boolean verbose) Loads aResourcefrom the suppliedReadableByteChannel.
-
Method Details
-
load
Loads theResourcefrom theInputStreamin non-verbose mode.- Parameters:
is- theInputStreamfrom which to load theResource- Returns:
- the
Resource - Throws:
ResourcePersistenceException
-
load
Loads theResourcefrom theReadableByteChannelin non-verbose mode.- Parameters:
rbc- theInputStreamfrom which to load theResource- Returns:
- the
Resource - Throws:
ResourcePersistenceException
-
load
Loads aResourcefrom the suppliedInputStream. The contents of theInputStreamshould be generated form a call toResource.serialize(OutputStream).- Parameters:
is- theInputStreamfrom which to load theResourceverbose- indicates if the resource shoudl be loaded verbosely.- Returns:
- the loaded
Resource - Throws:
ResourcePersistenceException- if the resource was corrupted of failed to load for some reason
-
load
Loads aResourcefrom the suppliedReadableByteChannel. The contents of theInputStreamshould be generated form a call toResource.serialize(OutputStream)orResource.serialize(WritableByteChannel).- Parameters:
rbc- theInputStreamfrom which to load theResourceverbose- indicates if the resource shoudl be loaded verbosely.- Returns:
- the loaded
Resource - Throws:
ResourcePersistenceException- if the resource was corrupted of failed to load for some reason
-
load
Performs the same operation asload(String, Attributes, Object...)usingAttributes.EMPTYas the specifiedAttributes.- Throws:
ModuleNotFoundException
-
load
Resource load(String moduleName, Attributes attributes, Object... args) throws ModuleNotFoundException Loads theResourcespecified by the supplied module name. The supplied module name is specific to the particular implementation of theResourceLoader, but should be a unique identifier specifying the unit or module of code to load. Since aResourcecan be represented by any number of languages, the string passed is highly specific to the underlying implementation's semantics.- Parameters:
moduleName- the module nameattributes-Attributesassocaited with theResourceargs- various initialization arguments to be passed to the underlyingResource- Returns:
- the
Resourceinstance, never null - Throws:
ModuleNotFoundException- if the source for theResourcecannot be found.
-
close
void close()Closes theResourceLoaderand cleaning up any resources. Any openResourceinstances may be closed, but this is not a guarantee. All resources open should be closed before closing thisResourceLoader. UsingResources after closing this instance, or closing this instance while resources are open should be considered undefined behavior. This also closes the resources which may be associated with thisResourceLoader. Invoking this method twice on the same object should also be considered undefined behavior.- Specified by:
closein interfaceAutoCloseable
-