Package ru.curs.celesta.score.io
Interface Resource
- All Known Implementing Classes:
FileResource,UrlResource
public interface Resource
Score resource abstraction. Its implementation may point to a physical file or a resource in
a JAR-file.
- Since:
- 2019-02-23
- Author:
- Pavel Perminov (packpaul@mail.ru)
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanChecks if the passed-in resource is a child ofthisresource.default ResourcecreateRelative(String relativePath) Creates a resource relative to this resource.createRelative(String relativePath, Namespace namespace) Creates a resource relative to this resource.default ResourcecreateRelative(Namespace namespace) Creates a resource relative to this resource.default booleandelete()Deletes physical resource thatthisresource points at.Returns input stream for the resource.Returns namespace of current resource.default OutputStreamReturns output stream for the resource if it is writable,nullotherwise.default StringgetRelativePath(Resource childResource) Returns relative path fromthisresource to the child one, ornullif such path doesn't exist.
-
Method Details
-
getInputStream
Returns input stream for the resource.- Returns:
- Throws:
IOException- when input stream cannot be provided.
-
getOutputStream
Returns output stream for the resource if it is writable,nullotherwise.- Returns:
- Throws:
IOException- when output stream cannot be provided.
-
delete
Deletes physical resource thatthisresource points at.- Returns:
trueif successfully deleted orfalseotherwise.- Throws:
IOException- when an error happened during deletion.
-
contains
Checks if the passed-in resource is a child ofthisresource.- Parameters:
childResource- the checked resource.- Returns:
-
getRelativePath
Returns relative path fromthisresource to the child one, ornullif such path doesn't exist.- Parameters:
childResource- child resource ofthisresource.- Returns:
-
createRelative
Creates a resource relative to this resource.- Parameters:
namespace- name space path relative tothisresource.- Returns:
- Throws:
IOException- when resource creation failed.
-
createRelative
Creates a resource relative to this resource.- Parameters:
relativePath- path relative tothisresource.- Returns:
- Throws:
IOException- when resource creation failed.
-
createRelative
Creates a resource relative to this resource.- Parameters:
relativePath- path relative tothisresource.namespace- name space of the created resource.- Returns:
- Throws:
IOException- when resource creation failed.
-
getNamespace
Namespace getNamespace()Returns namespace of current resource.- Returns:
-