public class

ServerFile

extends Object
java.lang.Object
   ↳ com.esri.core.map.ServerFile

Class Overview

This class represents a file on a server that is contained in a ServerFolder. Generally this file will have been created by a geoprocessing tool or a request for an offline tiled layer.

Summary

Nested Classes
interface ServerFile.ProgressListener  
Fields
protected long _downloadSize
Public Constructors
ServerFile(ServerFolder parentFolder)
Creates a new server file.
ServerFile(String url)
Public Methods
File download(File saveToPath)
Download this file from the server and save to the given path.
File download(File saveToPath, boolean renameFile)
Download this file from the server and save to the given path.
static ServerFile fromJson(JsonParser parser, ServerFolder parentFolder, UserCredentials userCredentials)
Create a new instance of this class from the given JSON.
String getName()
Gets the name.
ServerFolder getParent()
Gets the parent folder, or null if this is a top level item.
String getPath()
Gets the path.
String getUrl()
Gets the url of this file on the server.
void setCredentials(UserCredentials userCredentials)
Sets the credentials.
void setProgressListener(ServerFile.ProgressListener listener)
Used to set a listener that will be notified of the current download progress.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected long _downloadSize

Public Constructors

public ServerFile (ServerFolder parentFolder)

Creates a new server file.

Parameters
parentFolder ServerFolder: the parent folder

public ServerFile (String url)

Parameters
url String
Throws
MalformedURLException

Public Methods

public File download (File saveToPath)

Download this file from the server and save to the given path. The downloaded file will retain the name it had on the server.

Parameters
saveToPath File: the save to path
Returns
File
Throws
Exception
EsriSecurityException
Exception

public File download (File saveToPath, boolean renameFile)

Download this file from the server and save to the given path. If renameFile is true, the downloaded file will be renamed to the filename given as part of saveToPath.

Parameters
saveToPath File: the save to path
renameFile boolean: set true to rename the file, false leave it with the name set by the server. If this is true, saveToPath is assumed to be a full path and file name. If it's false, saveToPath is assumed to be a directory path.
Returns
File
Throws
Exception
EsriSecurityException
Exception

public static ServerFile fromJson (JsonParser parser, ServerFolder parentFolder, UserCredentials userCredentials)

Create a new instance of this class from the given JSON. This string will generally be returned by a query to a REST endpoint while opening a ServerFolder.

Parameters
parser JsonParser: the parser
parentFolder ServerFolder: the parent folder
userCredentials UserCredentials: the user credentials
Returns
ServerFile the server file
Throws
JsonParseException the json parse exception
IOException Signals that an I/O exception has occurred.

public String getName ()

Gets the name.

Returns
String the name

public ServerFolder getParent ()

Gets the parent folder, or null if this is a top level item.

Returns
ServerFolder the parent folder

public String getPath ()

Gets the path. If the parent folder of this file has been downloaded to disk, the path will be the absolute path on disk. If it hasn't been downloaded, the path will be relative to the root folder.

Returns
String the path

public String getUrl ()

Gets the url of this file on the server.

Returns
String the url

public void setCredentials (UserCredentials userCredentials)

Sets the credentials.

Parameters
userCredentials UserCredentials: the new credentials

public void setProgressListener (ServerFile.ProgressListener listener)

Used to set a listener that will be notified of the current download progress.

Parameters
listener ServerFile.ProgressListener: will be notified of the current download progress

public String toString ()

Returns
String