Package org.eclipse.jetty.util.resource
Class BadResource
java.lang.Object
org.eclipse.jetty.util.resource.Resource
org.eclipse.jetty.util.resource.URLResource
org.eclipse.jetty.util.resource.BadResource
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ResourceFactory
Bad Resource.
A Resource that is returned for a bade URL. Acts as a resource
that does not exist and throws appropriate exceptions.
-
Field Summary
FieldsFields inherited from class org.eclipse.jetty.util.resource.URLResource
_connection, _in, _url, _urlString, _useCaches
Fields inherited from class org.eclipse.jetty.util.resource.Resource
__defaultUseCaches, _associate
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copy the Resource to the new destination file.boolean
delete()
Deletes the given resourceboolean
exists()
Returns true if the represented resource exists.getFile()
Returns an File representing the given resource or NULL if this is not possible.Returns an input stream to the resource.boolean
Returns true if the represented resource is a container/directory.long
Returns the last modified timelong
length()
Return the length of the resourceString[]
list()
Returns a list of resource names contained in the given resourceboolean
Rename the given resourcetoString()
Methods inherited from class org.eclipse.jetty.util.resource.URLResource
addPath, checkConnection, close, equals, getInputStream, getName, getReadableByteChannel, getURL, getUseCaches, hashCode, isContainedIn
Methods inherited from class org.eclipse.jetty.util.resource.Resource
encode, finalize, getAlias, getAllResources, getAssociate, getDefaultUseCaches, getListHTML, getListHTML, getResource, getURI, getWeakETag, getWeakETag, isAlias, isContainedIn, isSame, newClassPathResource, newClassPathResource, newResource, newResource, newResource, newResource, newResource, newResource, newResource, newSystemResource, release, setAssociate, setDefaultUseCaches, toURL, writeTo
-
Field Details
-
_message
-
-
Constructor Details
-
BadResource
-
-
Method Details
-
exists
public boolean exists()Description copied from class:URLResource
Returns true if the represented resource exists.- Overrides:
exists
in classURLResource
- Returns:
- true if the represented resource exists.
-
lastModified
public long lastModified()Description copied from class:URLResource
Returns the last modified time- Overrides:
lastModified
in classURLResource
- Returns:
- the last modified time as milliseconds since unix epoch
-
isDirectory
public boolean isDirectory()Description copied from class:URLResource
Returns true if the represented resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.- Overrides:
isDirectory
in classURLResource
- Returns:
- true if the represented resource is a container/directory. if the resource is not a file, resources ending with "/" are considered directories.
-
length
public long length()Description copied from class:URLResource
Return the length of the resource- Overrides:
length
in classURLResource
- Returns:
- the length of the resource
-
getFile
Description copied from class:URLResource
Returns an File representing the given resource or NULL if this is not possible.- Overrides:
getFile
in classURLResource
- Returns:
- an File representing the given resource or NULL if this is not possible.
-
getInputStream
Description copied from class:URLResource
Returns an input stream to the resource. The underlying url connection will be nulled out to prevent re-use.- Overrides:
getInputStream
in classURLResource
- Returns:
- an input stream to the resource
- Throws:
IOException
- if unable to open the input stream
-
delete
Description copied from class:URLResource
Deletes the given resource- Overrides:
delete
in classURLResource
- Returns:
- true if resource was found and successfully deleted, false if resource didn't exist or was unable to be deleted.
- Throws:
SecurityException
- if unable to delete due to permissions
-
renameTo
Description copied from class:URLResource
Rename the given resource- Overrides:
renameTo
in classURLResource
- Parameters:
dest
- the destination name for the resource- Returns:
- true if the resource was renamed, false if the resource didn't exist or was unable to be renamed.
- Throws:
SecurityException
- if unable to rename due to permissions
-
list
Description copied from class:URLResource
Returns a list of resource names contained in the given resource- Overrides:
list
in classURLResource
- Returns:
- a list of resource names contained in the given resource, or null. Note: The resource names are not URL encoded.
-
copyTo
Description copied from class:Resource
Copy the Resource to the new destination file.Will not replace existing destination file.
- Overrides:
copyTo
in classResource
- Parameters:
destination
- the destination file to create- Throws:
IOException
- if unable to copy the resource
-
toString
- Overrides:
toString
in classURLResource
-