public class AssetResource extends AbstractResource
Resource implementation for Android asset resources.| Constructor and Description |
|---|
AssetResource(android.content.res.AssetManager assetManager,
java.lang.String fileName)
Create a new AssetResource.
|
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
This implementation checks the length of the underlying AssetFileDescriptor, if available.
|
boolean |
equals(java.lang.Object obj)
This implementation compares the file names of the resources.
|
boolean |
exists()
This implementation returns whether the underlying asset exists.
|
java.lang.String |
getDescription()
Return a description for this resource,
to be used for error output when working with the resource.
|
java.io.InputStream |
getInputStream()
Return an
InputStream. |
int |
hashCode()
This implementation returns the hash code of the file name.
|
createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isOpen, isReadable, lastModified, toStringpublic AssetResource(android.content.res.AssetManager assetManager,
java.lang.String fileName)
The Android AssetManager will be used for loading the resource.
fileName - the name of the asset to open.AssetManager.open(String)public boolean exists()
exists in interface Resourceexists in class AbstractResourcepublic long contentLength()
throws java.io.IOException
contentLength in interface ResourcecontentLength in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)AssetFileDescriptor.getLength()public java.lang.String getDescription()
ResourceImplementations are also encouraged to return this value
from their toString method.
Object.toString()public java.io.InputStream getInputStream()
throws java.io.IOException
InputStreamSourceInputStream.
It is expected that each call creates a fresh stream.
This requirement is particularly important when you consider an API such
as JavaMail, which needs to be able to read the stream multiple times when
creating mail attachments. For such a use case, it is required
that each getInputStream() call returns a fresh stream.
java.io.IOException - if the stream could not be openedpublic boolean equals(java.lang.Object obj)
equals in class AbstractResourceResource.getDescription()public int hashCode()
hashCode in class AbstractResourceResource.getDescription()