Class DatasourceConnectionInfo
- java.lang.Object
-
- com.supermap.data.DatasourceConnectionInfo
-
public class DatasourceConnectionInfo extends java.lang.Object
The DatasourceConnectionInfo class.
All the connection information about a datasource will be stored in an instance of this class, including the name of the server that the datasource will connect to, the name of the database, the user name and password needed to login the database etc. When saving a workspace, the connection information of all the datasources in it will be stored in the workspace file. The connection information for different types of datasource may be different. So when calling any member in this class, please pay attention to the type or types of datasource it applies.
SuperMap iMobile for Android support the memory datasource of UDB engine, and allows user to to create datasource in the memory.
- Example:
- The following code shows how to open UDB engine datasource.
public void main() { //Define the Workspace. Workspace workspace = new Workspace(); // Define DatasourceConnectionInfo, assume all the following datasources exists. DatasourceConnectionInfo datasourceconnection = new DatasourceConnectionInfo(); // The parameters needed for setting the datasourceConnectInfo datasourceconnection.setEngineType(EngineType.UDB); datasourceconnection.setServer("../../SampleData/World/World.udb"); datasourceconnection.setAlias("UDB"); datasourceconnection.setPassword(""); // Open datasource Datasource datasource = workspace.getDatasources().open(datasourceconnection); if (datasource == null) { System.out.println("Failed to open datasource"); return; } else { System.out.println("Opened datasource successfully!"); } //Release the workspace resource datasourceconnection.dispose(); workspace.dispose(); }
-
-
Constructor Summary
Constructors Constructor and Description DatasourceConnectionInfo()
Initializes a new instance of the DatasourceConnectionInfo class, and the default EngineType is UDB engine.DatasourceConnectionInfo(java.lang.String file, java.lang.String alias, java.lang.String password)
Creates a new DatasourceConnectionInfo object according to the specified arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
dispose()
Release the resource occupy by this object.java.lang.String
getAlias()
Returns the alias of the datasource.java.lang.String
getDriver()
Returns the driver name needed for the datasource connection.EngineType
getEngineType()
Return the engine type of the datasource connection.java.lang.String
getPassword()
Gets the password in connection info.java.lang.String
getProxyAddress()
Gets the proxy server address and port.java.lang.String
getProxyPort()
Gets the proxy server address and port.java.lang.String
getRequestHeader()
Gets the custom request header that has been setjava.lang.String
getServer()
Returns the name of the database server or file.java.lang.String
getUser()
Returns the user name when logging on the database.Rectangle2D
getWebBBox()
Gets the map extent of WMS service.java.lang.String
getWebCoordinate()
Gets the coordinate reference system for Web service type (Rest/OGC) datasource.java.lang.String
getWebExtendParam()
Gets the extending parameter of WMS service.java.lang.String
getWebFormat()
Gets the WMS service picture format.boolean
getWebTransparent()
Gets whether tiles requested by WMS service are transparentjava.lang.String
getWebVersion()
Gets the WMS service version.java.lang.String
getWebVisibleLayers()
Gets the visible layer set of WMS service.boolean
isReadOnly()
Returns whether to open the datasource readOnly.void
setAlias(java.lang.String value)
Returns the alias of the datasource.void
setDriver(java.lang.String value)
Sets the driver name needed for the datasource connection.void
setEngineType(EngineType value)
Sets the engine type of the datasource connection.void
setPassword(java.lang.String value)
Sets the password in the connection info.void
setPassword(java.lang.String value, DatasourceEncrytionType type)
Sets the password in the connection info.void
setProxy(java.lang.String address, java.lang.String port)
Sets the proxy server address and port.void
setReadOnly(boolean value)
Sets whether to open the datasource in readonly manner.void
setRequestHeader(<any> headers)
Set the request header The current version is only available for REST map servicesvoid
setServer(java.lang.String value)
Sets the path name of the database server or file.void
setUser(java.lang.String value)
Sets the user name when logging on the database.void
setWebBBox(Rectangle2D rect)
Sets the map extent of WMS service.void
setWebCoordinate(java.lang.String value)
Sets the coordinate reference system for Web service type (Rest/OGC) datasource; The default is to get from the service.void
setWebExtendParam(java.lang.String value)
Sets the extending parameter of WMS service.void
setWebFormat(java.lang.String value)
Sets the WMS service picture format.void
setWebImageSize(int value)
Sets google map tile size ,only for http://maps.google.com.void
setWebTransparent(boolean value)
Sets whether tiles requested by WMS service are transparentvoid
setWebVersion(java.lang.String value)
Sets the WMS service version.void
setWebVisibleLayers(java.lang.String value)
Sets the visible layer set of WMS service.
-
-
-
Constructor Detail
-
DatasourceConnectionInfo
public DatasourceConnectionInfo()
Initializes a new instance of the DatasourceConnectionInfo class, and the default EngineType is UDB engine.
-
DatasourceConnectionInfo
public DatasourceConnectionInfo(java.lang.String file, java.lang.String alias, java.lang.String password)
Creates a new DatasourceConnectionInfo object according to the specified arguments.- Parameters:
file
- UDB file name.alias
- Datasource aliaspassword
- Password.
-
-
Method Detail
-
getAlias
public java.lang.String getAlias()
Returns the alias of the datasource. The alias is the unique identifier of a datasource and the identifier is not case sensitive.- Returns:
- Datasource alias
- Default:
- The default value is UntitledPlacemark.
-
setAlias
public void setAlias(java.lang.String value)
Returns the alias of the datasource. The alias is the unique identifier of a datasource and the identifier is not case sensitive.- Parameters:
value
- Datasource alias
-
getEngineType
public EngineType getEngineType()
Return the engine type of the datasource connection. Including UDBUDB
and so on. Please refer to the example for theEngineType
class.- Returns:
- The engine type of datasource connection.
- See Also:
EngineType
- Default:
- The default value is
UDB
.
-
setEngineType
public void setEngineType(EngineType value)
Sets the engine type of the datasource connection. Including UDBUDB
and so on. Please refer to the example for theEngineType
class.- Parameters:
value
- The engine type of datasource connection.- See Also:
EngineType
-
getServer
public java.lang.String getServer()
Returns the name of the database server or file.For UDB file, its the file name, including the path name and the postfix of the file. It is the absolute path.
- Returns:
- the name of the database server or file name.
- Default:
- The default is a null string.
-
setServer
public void setServer(java.lang.String value)
Sets the path name of the database server or file.For UDB file, its the file name, including the path name and the postfix of the file. It is the absolute path.
- Parameters:
value
- the name of the database server or file name.
-
getUser
public java.lang.String getUser()
Returns the user name when logging on the database. Only applies to the database datasource.- Returns:
- The user name to log in the database.
- Default:
- The default is a null string.
-
setUser
public void setUser(java.lang.String value)
Sets the user name when logging on the database. Only applies to the database datasource.- Parameters:
value
- The user name to log in the database.
-
getPassword
public java.lang.String getPassword()
Gets the password in connection info. It only supports the original encryption type, namely, the DEFAULT type. If it is AES encryption, return the null string- Returns:
- The password of the database of file login the datasource connection.
- Default:
- The default is a null string.
-
setPassword
public void setPassword(java.lang.String value)
Sets the password in the connection info. The password type is Default- Parameters:
value
- Password
-
setPassword
public void setPassword(java.lang.String value, DatasourceEncrytionType type)
Sets the password in the connection info. It needs to specify the encryption type- Parameters:
value
- Passwordtype
- The encryption is used by encryption. If this parameter is null, press DEFAULT to process
-
isReadOnly
public boolean isReadOnly()
Returns whether to open the datasource readOnly. If it does, the related info and data in the datasource can not be edited.- Returns:
- whether to open the datasource as readOnly.
- Default:
- The default value is false.
-
setReadOnly
public void setReadOnly(boolean value)
Sets whether to open the datasource in readonly manner. If the database is opened in readonly manner, the related information about the datasource together with the data of the datasource can not be modified.For UDB datasource, if the file property is read only, it is needed to set the parameter of the
DatasourceConnectionInfo.setReadOnly()
as true.- Parameters:
value
- whether to open in readonly mode.
-
getDriver
public java.lang.String getDriver()
Returns the driver name needed for the datasource connection.For the WMTS service published by iServer, the driver name returned is WMTS.
- Returns:
- the driver name needed for the datasource connection.
- Default:
- The default is a null string.
-
setDriver
public void setDriver(java.lang.String value)
Sets the driver name needed for the datasource connection.For the WMTS services published by iServer, the driver name is WMTS and WMTS map should call this method to set the driver name.
- Parameters:
value
- the driver name needed for the datasource connection.- Example:
DatasourceConnectionInfo info = new DatasourceConnectionInfo(); info.setEngineType(EngineType.OGC); info.setDriver("WMTS");
-
dispose
public void dispose()
Release the resource occupy by this object.
-
setWebCoordinate
public void setWebCoordinate(java.lang.String value)
Sets the coordinate reference system for Web service type (Rest/OGC) datasource; The default is to get from the service. The EPSG:4326 is priority.- Parameters:
value
- The coordinate system include three types: EPSG:4326, EPSG:3857 and CRS:84.
-
getWebCoordinate
public java.lang.String getWebCoordinate()
Gets the coordinate reference system for Web service type (Rest/OGC) datasource.- Returns:
- The coordinate reference system for Web service type (Rest/OGC) datasource.
-
setWebVersion
public void setWebVersion(java.lang.String value)
Sets the WMS service version.- Parameters:
value
- the WMS service version.
-
getWebVersion
public java.lang.String getWebVersion()
Gets the WMS service version.- Returns:
- The WMS service version.
-
setWebFormat
public void setWebFormat(java.lang.String value)
Sets the WMS service picture format.- Parameters:
value
- the WMS service picture format.
-
getWebFormat
public java.lang.String getWebFormat()
Gets the WMS service picture format.- Returns:
- The WMS service picture format..
-
setWebVisibleLayers
public void setWebVisibleLayers(java.lang.String value)
Sets the visible layer set of WMS service.- Parameters:
value
- the visible layer set of WMS service.
-
getWebVisibleLayers
public java.lang.String getWebVisibleLayers()
Gets the visible layer set of WMS service.- Returns:
- The visible layer set of WMS service..
-
setWebBBox
public void setWebBBox(Rectangle2D rect)
Sets the map extent of WMS service.- Parameters:
rect
- the map extent of WMS service.
-
getWebBBox
public Rectangle2D getWebBBox()
Gets the map extent of WMS service.- Returns:
- The map extent of the MS services
-
getWebExtendParam
public java.lang.String getWebExtendParam()
Gets the extending parameter of WMS service.- Returns:
- The extending parameter of WMS service.
-
setWebExtendParam
public void setWebExtendParam(java.lang.String value)
Sets the extending parameter of WMS service.- Parameters:
value
- The extending parameter of WMS service.
-
setProxy
public void setProxy(java.lang.String address, java.lang.String port)
Sets the proxy server address and port.- Parameters:
address
- Proxy server addressport
- the proxy server address and port.
-
getProxyAddress
public java.lang.String getProxyAddress()
Gets the proxy server address and port.- Returns:
- Returns the proxy server address and port.
-
getProxyPort
public java.lang.String getProxyPort()
Gets the proxy server address and port.- Returns:
- Returns the proxy server address and port.
-
setWebImageSize
public void setWebImageSize(int value)
Sets google map tile size ,only for http://maps.google.com.- Parameters:
value
- the tile size
-
setWebTransparent
public void setWebTransparent(boolean value)
Sets whether tiles requested by WMS service are transparent- Parameters:
value
- Whether tiles are transparent
-
getWebTransparent
public boolean getWebTransparent()
Gets whether tiles requested by WMS service are transparent- Returns:
- Whether tiles are transparent
-
getRequestHeader
public java.lang.String getRequestHeader()
Gets the custom request header that has been set- Returns:
-
setRequestHeader
public void setRequestHeader(<any> headers)
Set the request headerThe current version is only available for REST map services
- Parameters:
value
-
-
-