Package ru.curs.celesta.score.io
Interface Resource
-
- All Known Implementing Classes:
FileResource,UrlResource
public interface ResourceScore 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleancontains(Resource childResource)Checks if the passed-in resource is a child ofthisresource.default ResourcecreateRelative(String relativePath)Creates a resource relative to this resource.ResourcecreateRelative(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.InputStreamgetInputStream()Returns input stream for the resource.NamespacegetNamespace()Returns namespace of current resource.default OutputStreamgetOutputStream()Returns 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 Detail
-
getInputStream
InputStream getInputStream() throws IOException
Returns input stream for the resource.- Returns:
- Throws:
IOException- when input stream cannot be provided.
-
getOutputStream
default OutputStream getOutputStream() throws IOException
Returns output stream for the resource if it is writable,nullotherwise.- Returns:
- Throws:
IOException- when output stream cannot be provided.
-
delete
default boolean delete() throws IOExceptionDeletes physical resource thatthisresource points at.- Returns:
trueif successfully deleted orfalseotherwise.- Throws:
IOException- when an error happened during deletion.
-
contains
default boolean contains(Resource childResource)
Checks if the passed-in resource is a child ofthisresource.- Parameters:
childResource- the checked resource.- Returns:
-
getRelativePath
default String getRelativePath(Resource childResource)
Returns relative path fromthisresource to the child one, ornullif such path doesn't exist.- Parameters:
childResource- child resource ofthisresource.- Returns:
-
createRelative
default Resource createRelative(Namespace namespace) throws IOException
Creates a resource relative to this resource.- Parameters:
namespace- name space path relative tothisresource.- Returns:
- Throws:
IOException- when resource creation failed.
-
createRelative
default Resource createRelative(String relativePath) throws IOException
Creates a resource relative to this resource.- Parameters:
relativePath- path relative tothisresource.- Returns:
- Throws:
IOException- when resource creation failed.
-
createRelative
Resource createRelative(String relativePath, Namespace namespace) throws IOException
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:
-
-