Package io.guise.framework.model
Interface ResourceImport
- All Known Implementing Classes:
FileItemResourceImport
public interface ResourceImport
An interface to a resource being imported, such as a web file upload. All resource access methods must be synchronized on the resource import instance.
- Author:
- Garret Wilson
-
Method Summary
Modifier and TypeMethodDescriptionlong
com.globalmentor.net.MediaType
Retrieves an input stream to the resource.getName()
Returns the simple name, such as the filename, of the resource.boolean
void
Convenience method for storing the imported resource in a file.
-
Method Details
-
getName
String getName()- Returns:
- The name of the resource, which may be, for example, a simple name, a path and filename, or
null
if the name is not known. - See Also:
-
getSimpleName
String getSimpleName()Returns the simple name, such as the filename, of the resource. The returned string does not include any path information.- Returns:
- The simple name of the resource, or
null
if the name is not known. - See Also:
-
getContentType
com.globalmentor.net.MediaType getContentType()- Returns:
- The content type of the resource to be imported, or
null
if the content type of the resource is not known.
-
getContentLength
long getContentLength()- Returns:
- The length of the resource to be imported, or -1 if the length of the resource is not known.
-
isImported
boolean isImported()- Returns:
- Whether the resource has been accessed, either by retrieving its input stream or by storing the resource in a file.
-
getInputStream
Retrieves an input stream to the resource. There can only be at most a single call to this method orstore(File)
.- Returns:
- An input stream to the resource to be imported.
- Throws:
IllegalStateException
- if this resource has already been stored in a file, or an input stream to the resource has already been retrieved.IOException
- if there is an error getting an input stream to the resource.
-
store
Convenience method for storing the imported resource in a file. Depending on the implementation, this may allow greater efficiency than reading from the stream. There can only be at most a single call to this method orgetInputStream()
.- Parameters:
file
- The file to which the resource should be written.- Throws:
IllegalStateException
- if this resource has already been stored in a file, or an input stream to the resource has already been retrieved.IOException
- If there is an error writing the resource to the file.
-