Interface ResourceFile
-
- All Superinterfaces:
it.tidalwave.util.As
,it.tidalwave.role.Composite<ResourceFile,ResourceFile.Finder>
- All Known Implementing Classes:
DecoratedResourceFileSupport
public interface ResourceFile extends it.tidalwave.util.As, it.tidalwave.role.Composite<ResourceFile,ResourceFile.Finder>
A file backing aResource
. There can be various implementations of this interface: plain files on the local disk, items in a zip file, elements of a repository such as Mercurial or Git, objects stored within a database, etc...- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ResourceFile.Finder
AResourceFile.Finder
for retrieving children ofResourceFile
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
asBytes()
Returns the full contents of this file as binary data.java.lang.String
asText(java.lang.String encoding)
Returns the full contents of this file as text.void
copyTo(ResourceFile targetFolder)
Don't useResourceFile
createFolder(java.lang.String name)
Don't usevoid
delete()
Don't useResourceFileSystem
getFileSystem()
Returns theResourceFileSystem
this file belongs to.java.io.InputStream
getInputStream()
Returns anInputStream
that allows to read contents of this file.java.time.ZonedDateTime
getLatestModificationTime()
Returns the latest modification time of this file.java.lang.String
getMimeType()
Returns the MIME type associated to the contents of this file.java.lang.String
getName()
Returns the name of this file (it doesn't include the full path).ResourceFile
getParent()
Returns the parent of this file.ResourcePath
getPath()
Returns the full path of this file.boolean
isData()
Returnstrue
whether this file is a plain file.boolean
isFolder()
Returnstrue
whether this file is a folder.java.io.File
toFile()
FIXME: drop this - it won't work with virtual file systems
-
-
-
Method Detail
-
getFileSystem
@Nonnull ResourceFileSystem getFileSystem()
Returns theResourceFileSystem
this file belongs to.- Returns:
- the
ResourceFileSystem
-
getName
@Nonnull java.lang.String getName()
Returns the name of this file (it doesn't include the full path).- Returns:
- the name of the file
-
getPath
@Nonnull ResourcePath getPath()
Returns the full path of this file. FIXME: the root object returns "" in place of "/" - this will change in future- Returns:
- the full path of the file
-
isFolder
boolean isFolder()
Returnstrue
whether this file is a folder.- Returns:
true
for a folder
-
isData
boolean isData()
Returnstrue
whether this file is a plain file.- Returns:
true
for a file
-
getMimeType
@Nonnull java.lang.String getMimeType()
Returns the MIME type associated to the contents of this file. The value is achieved by querying the web server context.- Returns:
- the MIME type
-
getInputStream
@Nonnull java.io.InputStream getInputStream() throws java.io.FileNotFoundException
Returns anInputStream
that allows to read contents of this file.- Returns:
- the
InputStream
- Throws:
java.io.FileNotFoundException
- if the physical data can't be accessed
-
asText
@Nonnull java.lang.String asText(@Nonnull java.lang.String encoding) throws java.io.IOException
Returns the full contents of this file as text.- Parameters:
encoding
- the content encoding- Returns:
- the contents
- Throws:
java.io.IOException
- if an I/O error occurs
-
asBytes
@Nonnull byte[] asBytes() throws java.io.IOException
Returns the full contents of this file as binary data.- Returns:
- the contents
- Throws:
java.io.IOException
- if an I/O error occurs
-
getLatestModificationTime
@Nonnull java.time.ZonedDateTime getLatestModificationTime()
Returns the latest modification time of this file.- Returns:
- the latest modification time
-
getParent
ResourceFile getParent()
Returns the parent of this file. FIXME: make @Nonnull, use Optional- Returns:
- the parent or null if no parent
-
toFile
@Nonnull java.io.File toFile()
FIXME: drop this - it won't work with virtual file systems
-
delete
void delete() throws java.io.IOException
Don't use- Throws:
java.io.IOException
-
createFolder
@Nonnull ResourceFile createFolder(@Nonnull java.lang.String name) throws java.io.IOException
Don't use- Throws:
java.io.IOException
-
copyTo
void copyTo(@Nonnull ResourceFile targetFolder) throws java.io.IOException
Don't use- Throws:
java.io.IOException
-
-