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:
java.io.Closeable,java.lang.AutoCloseable,ResourceFactory
class BadResource extends URLResource
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
Fields Modifier and Type Field Description private java.lang.String_message-
Fields 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 Constructor Description BadResource(java.net.URL url, java.lang.String message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyTo(java.io.File destination)Copy the Resource to the new destination file.booleandelete()Deletes the given resourcebooleanexists()Returns true if the represented resource exists.java.io.FilegetFile()Returns an File representing the given resource or NULL if this is not possible.java.io.InputStreamgetInputStream()Returns an input stream to the resource.booleanisDirectory()Returns true if the represented resource is a container/directory.longlastModified()Returns the last modified timelonglength()Return the length of the resourcejava.lang.String[]list()Returns a list of resource names contained in the given resourcebooleanrenameTo(Resource dest)Rename the given resourcejava.lang.StringtoString()-
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
-
-
-
-
Method Detail
-
exists
public boolean exists()
Description copied from class:URLResourceReturns true if the represented resource exists.- Overrides:
existsin classURLResource- Returns:
- true if the represented resource exists.
-
lastModified
public long lastModified()
Description copied from class:URLResourceReturns the last modified time- Overrides:
lastModifiedin classURLResource- Returns:
- the last modified time as milliseconds since unix epoch
-
isDirectory
public boolean isDirectory()
Description copied from class:URLResourceReturns true if the represented resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.- Overrides:
isDirectoryin 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:URLResourceReturn the length of the resource- Overrides:
lengthin classURLResource- Returns:
- the length of the resource
-
getFile
public java.io.File getFile()
Description copied from class:URLResourceReturns an File representing the given resource or NULL if this is not possible.- Overrides:
getFilein classURLResource- Returns:
- an File representing the given resource or NULL if this is not possible.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionDescription copied from class:URLResourceReturns an input stream to the resource. The underlying url connection will be nulled out to prevent re-use.- Overrides:
getInputStreamin classURLResource- Returns:
- an input stream to the resource
- Throws:
java.io.IOException- if unable to open the input stream
-
delete
public boolean delete() throws java.lang.SecurityExceptionDescription copied from class:URLResourceDeletes the given resource- Overrides:
deletein classURLResource- Returns:
- true if resource was found and successfully deleted, false if resource didn't exist or was unable to be deleted.
- Throws:
java.lang.SecurityException- if unable to delete due to permissions
-
renameTo
public boolean renameTo(Resource dest) throws java.lang.SecurityException
Description copied from class:URLResourceRename the given resource- Overrides:
renameToin 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:
java.lang.SecurityException- if unable to rename due to permissions
-
list
public java.lang.String[] list()
Description copied from class:URLResourceReturns a list of resource names contained in the given resource- Overrides:
listin classURLResource- Returns:
- a list of resource names contained in the given resource, or null. Note: The resource names are not URL encoded.
-
copyTo
public void copyTo(java.io.File destination) throws java.io.IOExceptionDescription copied from class:ResourceCopy the Resource to the new destination file.Will not replace existing destination file.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classURLResource
-
-