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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getContentLength()
com.globalmentor.net.ContentType
getContentType()
java.io.InputStream
getInputStream()
Retrieves an input stream to the resource.java.lang.String
getName()
java.lang.String
getSimpleName()
Returns the simple name, such as the filename, of the resource.boolean
isImported()
void
store(java.io.File file)
Convenience method for storing the imported resource in a file.
-
-
-
Method Detail
-
getName
java.lang.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()
-
getSimpleName
java.lang.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:
getName()
-
getContentType
com.globalmentor.net.ContentType 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
java.io.InputStream getInputStream() throws java.io.IOException
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:
java.lang.IllegalStateException
- if this resource has already been stored in a file, or an input stream to the resource has already been retrieved.java.io.IOException
- if there is an error getting an input stream to the resource.
-
store
void store(java.io.File file) throws java.io.IOException
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:
java.lang.IllegalStateException
- if this resource has already been stored in a file, or an input stream to the resource has already been retrieved.java.io.IOException
- If there is an error writing the resource to the file.
-
-