Package org.jmxtrans.agent.util.io
Class UrlResource
java.lang.Object
org.jmxtrans.agent.util.io.AbstractResource
org.jmxtrans.agent.util.io.UrlResource
- All Implemented Interfaces:
Resource
public class UrlResource extends AbstractResource implements Resource
- Author:
- Cyrille Le Clerc
-
Field Summary
-
Constructor Summary
Constructors Constructor Description UrlResource(java.lang.String url) -
Method Summary
Modifier and Type Method Description protected voidconfigureUrlConnection(java.net.URLConnection conn)booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.java.lang.StringgetDescription()Return a description for this resource, to be used for error output when working with the resource.java.io.FilegetFile()Return a File handle for this resource.java.io.InputStreamgetInputStream()Return anInputStream.longlastModified()Determine the last-modified timestamp for this resource.Methods inherited from class org.jmxtrans.agent.util.io.AbstractResource
getURI, getURL, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
logger
-
-
Constructor Details
-
UrlResource
public UrlResource(@Nonnull java.lang.String url)
-
-
Method Details
-
getFile
@Nonnull public java.io.File getFile()Description copied from interface:ResourceReturn a File handle for this resource.- Specified by:
getFilein interfaceResource- Overrides:
getFilein classAbstractResource
-
exists
public boolean exists()Description copied from class:AbstractResourceThis implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.- Specified by:
existsin interfaceResource- Overrides:
existsin classAbstractResource
-
lastModified
public long lastModified()Description copied from interface:ResourceDetermine the last-modified timestamp for this resource.- Specified by:
lastModifiedin interfaceResource- Overrides:
lastModifiedin classAbstractResource
-
configureUrlConnection
protected void configureUrlConnection(java.net.URLConnection conn) -
getInputStream
@Nonnull public java.io.InputStream getInputStream()Description copied from interface:ResourceReturn anInputStream.It is expected that each call creates a fresh stream.
- Specified by:
getInputStreamin interfaceResource- Returns:
- the input stream for the underlying resource (must not be
null)
-
getDescription
public java.lang.String getDescription()Description copied from interface:ResourceReturn a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their
toStringmethod.- Specified by:
getDescriptionin interfaceResource- See Also:
Object.toString()
-