Package org.grails.io.support
Class AbstractFileResolvingResource
- java.lang.Object
-
- org.grails.io.support.AbstractFileResolvingResource
-
- All Implemented Interfaces:
Resource
- Direct Known Subclasses:
ClassPathResource,UrlResource
public abstract class AbstractFileResolvingResource extends java.lang.Object implements Resource
Abstract base class for resources which resolve URLs into File references, such asorg.springframework.core.io.UrlResourceororg.springframework.core.io.ClassPathResource.Detects the "file" protocol as well as the JBoss "vfs" protocol in URLs, resolving file system references accordingly.
- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description AbstractFileResolvingResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcontentLength()Determine the content length for this resource.booleanexists()Return whether this resource actually exists in physical form.java.io.FilegetFile()This implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.protected java.io.FilegetFile(java.net.URI uri)This implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.protected java.io.FilegetFileForLastModifiedCheck()This implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).booleanisReadable()Return whether the contents of this resource can be read, e.g.longlastModified()Determine the last-modified timestamp for this resource.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.grails.io.support.Resource
createRelative, getDescription, getFilename, getInputStream, getURI, getURL
-
-
-
-
Method Detail
-
getFile
public java.io.File getFile() throws java.io.IOExceptionThis implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.
-
getFileForLastModifiedCheck
protected java.io.File getFileForLastModifiedCheck() throws java.io.IOExceptionThis implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).- Throws:
java.io.IOException
-
getFile
protected java.io.File getFile(java.net.URI uri) throws java.io.IOExceptionThis implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.- Throws:
java.io.IOException
-
exists
public boolean exists()
Description copied from interface:ResourceReturn whether this resource actually exists in physical form.This method performs a definitive existence check, whereas the existence of a
Resourcehandle only guarantees a valid descriptor handle.
-
isReadable
public boolean isReadable()
Description copied from interface:ResourceReturn whether the contents of this resource can be read, e.g. viaResource.getInputStream()orResource.getFile().Will be
truefor typical resource descriptors; note that actual content reading may still fail when attempted. However, a value offalseis a definitive indication that the resource content cannot be read.- Specified by:
isReadablein interfaceResource- See Also:
Resource.getInputStream()
-
contentLength
public long contentLength() throws java.io.IOExceptionDescription copied from interface:ResourceDetermine the content length for this resource.- Specified by:
contentLengthin interfaceResource- Throws:
java.io.IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
lastModified
public long lastModified() throws java.io.IOExceptionDescription copied from interface:ResourceDetermine the last-modified timestamp for this resource.- Specified by:
lastModifiedin interfaceResource- Throws:
java.io.IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
-