Class Get
- All Implemented Interfaces:
- Cloneable
- Since:
- Ant 1.1
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classProvide this for Backward Compatibility.static interfaceInterface implemented for reporting progress of downloading.static classdo nothing with progress infostatic classverbose progress system prints to some output stream
- 
Field SummaryFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds URLs to get.voidadd(FileNameMapper fileNameMapper) Add a nested filenamemapper.voidaddConfiguredHeader(Header header) Add a nested headerDefine the mapper to map source to destination files.booleandoGet(int logLevel, Get.DownloadProgress progress) Deprecated.only gets the first configured resourcebooleandoGet(URL source, File dest, int logLevel, Get.DownloadProgress progress) make a get request, with the supplied progress and logging info.voidexecute()Does the work.static booleanisMoved(int responseCode) Does the response code represent a redirection?voidLogs a message with the given priority.voidsetAuthenticateOnRedirect(boolean v) If true, credentials are set when following a redirect to a new location.voidWhere to copy the source file.voidsetHttpUseCaches(boolean httpUseCache) HTTP connections only - control caching on the HttpUrlConnection: httpConnection.setUseCaches(); if false, do not allow caching on the HttpUrlConnection.voidsetIgnoreErrors(boolean v) If true, log errors but do not treat as fatal.voidsetMaxTime(long maxTime) The time in seconds the download is allowed to take before being terminated.voidpassword for the basic authentication.voidsetQuiet(boolean v) If true, set default log level to Project.MSG_ERR.voidsetRetries(int r) The number of attempts to make for opening the URI, defaults to 3.voidsetSkipExisting(boolean s) Skip files that already exist locally.voidSet an URL to get.voidsetTryGzipEncoding(boolean b) Whether to transparently try to reduce bandwidth by telling the server ant would support gzip encoding.voidsetUserAgent(String userAgent) HTTP connections only - set the user-agent to be used when communicating with remote server.voidUsername for basic auth.voidsetUseTimestamp(boolean v) If true, conditionally download a file based on the timestamp of the local copy.voidsetVerbose(boolean v) If true, show verbose progress information.Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
- 
Constructor Details- 
Getpublic Get()
 
- 
- 
Method Details- 
executeDoes the work.- Overrides:
- executein class- Task
- Throws:
- BuildException- Thrown in unrecoverable error.
 
- 
doGetDeprecated.only gets the first configured resourcemake a get request, with the supplied progress and logging info. All the other config parameters are set at the task level, source, dest, ignoreErrors, etc.- Parameters:
- logLevel- level to log at, see- Project.log(String, int)
- progress- progress callback; null for no-callbacks
- Returns:
- true for a successful download, false otherwise.
 The return value is only relevant when ignoreErrorsis true, as when false all failures raise BuildExceptions.
- Throws:
- IOException- for network trouble
- BuildException- for argument errors, or other trouble when ignoreErrors is false.
 
- 
doGetpublic boolean doGet(URL source, File dest, int logLevel, Get.DownloadProgress progress) throws IOException make a get request, with the supplied progress and logging info. All the other config parameters like ignoreErrors are set at the task level.- Parameters:
- source- the URL to get
- dest- the target file
- logLevel- level to log at, see- Project.log(String, int)
- progress- progress callback; null for no-callbacks
- Returns:
- true for a successful download, false otherwise.
 The return value is only relevant when ignoreErrorsis true, as when false all failures raise BuildExceptions.
- Throws:
- IOException- for network trouble
- BuildException- for argument errors, or other trouble when ignoreErrors is false.
- Since:
- Ant 1.8.0
 
- 
logDescription copied from class:TaskLogs a message with the given priority. This delegates the actual logging to the project.
- 
setSrc
- 
addAdds URLs to get.- Parameters:
- rc- ResourceCollection
- Since:
- Ant 1.8.0
 
- 
setDest
- 
setVerbosepublic void setVerbose(boolean v) If true, show verbose progress information.- Parameters:
- v- if "true" then be verbose
 
- 
setQuietpublic void setQuiet(boolean v) If true, set default log level to Project.MSG_ERR.- Parameters:
- v- if "true" then be quiet
- Since:
- Ant 1.9.4
 
- 
setIgnoreErrorspublic void setIgnoreErrors(boolean v) If true, log errors but do not treat as fatal.- Parameters:
- v- if "true" then don't report download errors up to ant
 
- 
setUseTimestamppublic void setUseTimestamp(boolean v) If true, conditionally download a file based on the timestamp of the local copy.In this situation, the if-modified-since header is set so that the file is only fetched if it is newer than the local file (or there is no local file) This flag is only valid on HTTP connections, it is ignored in other cases. When the flag is set, the local copy of the downloaded file will also have its timestamp set to the remote file time. Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and web servers often serve files with a timestamp in the future by replacing their timestamp with that of the current time. Also, inter-computer clock differences can cause no end of grief. - Parameters:
- v- "true" to enable file time fetching
 
- 
setUsernameUsername for basic auth.- Parameters:
- u- username for authentication
 
- 
setPasswordpassword for the basic authentication.- Parameters:
- p- password for authentication
 
- 
setAuthenticateOnRedirectpublic void setAuthenticateOnRedirect(boolean v) If true, credentials are set when following a redirect to a new location.- Parameters:
- v- "true" to enable sending the credentials on redirect; "false" otherwise
- Since:
- Ant 1.10.13
 
- 
setMaxTimepublic void setMaxTime(long maxTime) The time in seconds the download is allowed to take before being terminated.- Parameters:
- maxTime- long
- Since:
- Ant 1.8.0
 
- 
setRetriespublic void setRetries(int r) The number of attempts to make for opening the URI, defaults to 3.The name of the method is misleading as a value of 1 means "don't retry on error" and a value of 0 meant don't even try to reach the URI at all. - Parameters:
- r- number of attempts to make
- Since:
- Ant 1.8.0
 
- 
setSkipExistingpublic void setSkipExisting(boolean s) Skip files that already exist locally.- Parameters:
- s- "true" to skip existing destination files
- Since:
- Ant 1.8.0
 
- 
setUserAgentHTTP connections only - set the user-agent to be used when communicating with remote server. if null, then the value is considered unset and the behaviour falls back to the default of the http API.- Parameters:
- userAgent- String
- Since:
- Ant 1.9.3
 
- 
setHttpUseCachespublic void setHttpUseCaches(boolean httpUseCache) HTTP connections only - control caching on the HttpUrlConnection: httpConnection.setUseCaches(); if false, do not allow caching on the HttpUrlConnection.Defaults to true (allow caching, which is also the HttpUrlConnection default value. - Parameters:
- httpUseCache- boolean
- Since:
- Ant 1.8.0
 
- 
setTryGzipEncodingpublic void setTryGzipEncoding(boolean b) Whether to transparently try to reduce bandwidth by telling the server ant would support gzip encoding.Setting this to true also means Ant will uncompress .tar.gzand similar files automatically.- Parameters:
- b- boolean
- Since:
- Ant 1.9.5
 
- 
addConfiguredHeader
- 
createMapperDefine the mapper to map source to destination files.- Returns:
- a mapper to be configured.
- Throws:
- BuildException- if more than one mapper is defined.
- Since:
- Ant 1.8.0
 
- 
addAdd a nested filenamemapper.- Parameters:
- fileNameMapper- the mapper to add.
- Since:
- Ant 1.8.0
 
- 
isMovedpublic static boolean isMoved(int responseCode) Does the response code represent a redirection?- Since:
- 1.10.10
 
 
-