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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
contains(Resource childResource)
Checks if the passed-in resource is a child ofthis
resource.default Resource
createRelative(String relativePath)
Creates a resource relative to this resource.Resource
createRelative(String relativePath, Namespace namespace)
Creates a resource relative to this resource.default Resource
createRelative(Namespace namespace)
Creates a resource relative to this resource.default boolean
delete()
Deletes physical resource thatthis
resource points at.InputStream
getInputStream()
Returns input stream for the resource.Namespace
getNamespace()
Returns namespace of current resource.default OutputStream
getOutputStream()
Returns output stream for the resource if it is writable,null
otherwise.default String
getRelativePath(Resource childResource)
Returns relative path fromthis
resource to the child one, ornull
if 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,null
otherwise.- Returns:
- Throws:
IOException
- when output stream cannot be provided.
-
delete
default boolean delete() throws IOException
Deletes physical resource thatthis
resource points at.- Returns:
true
if successfully deleted orfalse
otherwise.- Throws:
IOException
- when an error happened during deletion.
-
contains
default boolean contains(Resource childResource)
Checks if the passed-in resource is a child ofthis
resource.- Parameters:
childResource
- the checked resource.- Returns:
-
getRelativePath
default String getRelativePath(Resource childResource)
Returns relative path fromthis
resource to the child one, ornull
if such path doesn't exist.- Parameters:
childResource
- child resource ofthis
resource.- Returns:
-
createRelative
default Resource createRelative(Namespace namespace) throws IOException
Creates a resource relative to this resource.- Parameters:
namespace
- name space path relative tothis
resource.- 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 tothis
resource.- 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 tothis
resource.namespace
- name space of the created resource.- Returns:
- Throws:
IOException
- when resource creation failed.
-
getNamespace
Namespace getNamespace()
Returns namespace of current resource.- Returns:
-
-